aboutsummaryrefslogtreecommitdiffstats
path: root/include/YAGE/vertex.hpp
blob: a3848490a56973cb9163efdf92a2922077a250ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* ----------------------------------------------------------------------------
 * vertex.hpp
 *
 * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com> -- MIT License
 * See file LICENSE for more details
 * ----------------------------------------------------------------------------
 */

#ifndef VERTEX_HPP
#define VERTEX_HPP

#include <GL/glew.h>

namespace yage
{

struct Position
{
    float x;
    float y;

    Position()
    {}
    
    Position(float x_, float y_) :
	x(x_), y(y_)
    {}
};

struct Color
{
    GLubyte r;
    GLubyte g;
    GLubyte b;
    GLubyte a;

    Color()
    {}

    Color(GLubyte r_, GLubyte g_, GLubyte b_, GLubyte a_) :
	r(r_), g(g_), b(b_), a(a_)
    {}
};

struct UV
{
    float u;
    float v;

    UV()
    {}

    UV(float u_, float v_) :
	u(u_), v(v_)
    {}
};

struct Vertex
{
    Position position;
    Color color;
    UV uv;

    Vertex()
    {}

    Vertex(const Position &position_, const Color &color_, const UV &uv_) :
	position(position_), color(color_), uv(uv_)
    {}

    void setPosition(float x, float y)
    {
	position.x = x;
	position.y = y;
    }
    
    void setColor(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
    {
	color.r = r;
	color.g = g;
	color.b = b;
	color.a = a;
    }
    
    void setUv(float u, float v)
    {
	uv.u = u;
	uv.v = v;
    }
};
    
} // yage

#endif