Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Vertex.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  *
21  * Part of this file comes from SFML, with the same license:
22  * Copyright (C) 2007-2015 Laurent Gomila (laurent@sfml-dev.org)
23  */
24 #ifndef GF_VERTEX_H
25 #define GF_VERTEX_H
26 
27 #include "Color.h"
28 #include "Portability.h"
29 #include "Vector.h"
30 
31 namespace gf {
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 inline namespace v1 {
34 #endif
35 
36  /**
37  * @ingroup graphics
38  * @brief A point associated with a color and a texture coordinate
39  *
40  * gf::Vertex represents the association between a position in the world, a
41  * color and texture coordinates.
42  *
43  * A vertex is the building block for drawing. Everything which is visible
44  * on screen is made of vertices. They are grouped as 2D primitives
45  * (triangles, etc), and these primitives are grouped to create even more
46  * complex 2D entities such as sprites, shapes, etc.
47  *
48  * If you use the graphical entities of gf (sprite, shape), you won't have
49  * to deal with vertices directly. But if you want to define your own 2D
50  * entities, using vertices will allow you to get maximum performances.
51  *
52  * The texture coordinates are in the @f$ [0, 1] @f$ range. @f$ (0,0) @f$
53  * is the top-left of the texture while @f$ (1,1) @f$ is the bottom right
54  * of the texture. If a coordinate is outside the @f$ [0, 1] @f$ range, the
55  * texture is clamped or repeated (see Texture::setRepeated).
56  *
57  * Example:
58  *
59  * ~~~{.cc}
60  * // define a triangle
61  * gf::Vertex triangle[3];
62  * triangle[0].position = { 0.0f, 0.5f };
63  * triangle[0].color = gf::Color::Red;
64  * triangle[1].position = { 0.5f, -0.5f };
65  * triangle[1].color = gf::Color::Green;
66  * triangle[2].position = { -0.5f, -0.5f };
67  * triangle[2].color = gf::Color::Yellow;
68  *
69  * // and draw it
70  * renderer.draw(triangle, 3, gf::PrimitiveType::Triangles);
71  * ~~~
72  *
73  * @sa gf::PrimitiveType, gf::RenderTarget::draw
74  */
75  struct GF_API Vertex {
76  Vector2f position; ///< Position of the vertex in world coordinates
77  Color4f color = Color::White; ///< %Color of the vertex (default: white)
78  Vector2f texCoords = Vector2f{ 0.0f, 0.0f }; ///< Coordinates of the texture
79  };
80 
81 #ifndef DOXYGEN_SHOULD_SKIP_THIS
82 }
83 #endif
84 }
85 
86 #endif // GF_VERTEX_H
A point associated with a color and a texture coordinate.
Definition: Vertex.h:75
Color4f color
Color of the vertex (default: white)
Definition: Vertex.h:77
Definition: Action.h:34
Vector2f position
Position of the vertex in world coordinates.
Definition: Vertex.h:76
#define GF_API
Definition: Portability.h:35
Vector2f texCoords
Coordinates of the texture.
Definition: Vertex.h:78