BARE2D
Vertex.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <GL/glew.h>
4
#include <glm/glm.hpp>
5
6
namespace
BARE2D
{
7
8
/**
9
* @class Position
10
* @brief Positional data
11
*/
12
struct
Position
{
13
float
x
,
y
,
z
;
14
};
15
16
/**
17
* @class Colour
18
* @brief An RGBA 8-bit colour value
19
*/
20
struct
Colour
{
21
Colour
() {}
22
Colour
(GLubyte R, GLubyte G, GLubyte B, GLubyte A) :
r
(R),
g
(G),
b
(B),
a
(A) {}
23
24
GLubyte
r
,
g
,
b
,
a
;
25
};
26
27
/**
28
* @class UV
29
* @brief Holds two floats which can act as UV sizes or positions
30
*/
31
struct
UV
{
32
float
u
,
v
;
33
};
34
35
/**
36
* @class Vertex
37
* @brief Just holds vertex data for convenience
38
*/
39
struct
Vertex
{
40
Position
position
;
41
42
Colour
colour
;
43
44
UV
uv
;
45
46
/**
47
* @brief Literally just sets the position. Convenient
48
* @param x
49
* @param y
50
* @param z
51
*/
52
void
setPosition
(
float
x,
float
y,
float
z) {
53
position
.
x
= x;
54
position
.
y
= y;
55
position
.
z
= z;
56
}
57
58
/**
59
* @brief Sets the colour.
60
* @param r
61
* @param g
62
* @param b
63
* @param a
64
*/
65
void
setColour
(GLubyte r, GLubyte g, GLubyte b, GLubyte a) {
66
colour
.
r
= r;
67
colour
.
g
= g;
68
colour
.
b
= b;
69
colour
.
a
= a;
70
}
71
72
/**
73
* @brief Sets the UV coords/dimensions.
74
* @param u
75
* @param v
76
*/
77
void
setUV
(
float
u,
float
v) {
78
uv
.
u
= u;
79
uv
.
v
= v;
80
}
81
};
82
83
/**
84
* @class Glyph
85
* @brief The glyph represents a renderbatch's primitive data, which is created from each draw call in the basic renderer.
86
*/
87
class
Glyph
{
88
public
:
89
Glyph
(glm::vec4& destRect, glm::vec4& uvRect, GLuint&
Texture
,
float
& Depth,
Colour
& colour);
90
Glyph
(glm::vec4& destRect, glm::vec4& uvRect, GLuint&
Texture
,
float
& Depth,
Colour
& colour,
float
& angle);
91
Glyph
(glm::vec4& destRect, glm::vec4& uvRect, GLuint&
Texture
,
float
& Depth,
Colour
& colour,
float
& angle, glm::vec2& COR);
92
93
// Texture handle from opengl
94
GLuint
texture
;
95
96
// Depth for depth-culling.
97
float
depth
;
98
99
// Vertices prettty much just hold vertex data together. Useful in creating render batches
100
Vertex
topLeft
,
bottomLeft
,
topRight
,
bottomRight
;
101
102
protected
:
103
glm::vec2
rotatePoint
(
const
glm::vec2& pos,
float
& angle);
104
};
105
}
BARE2D::Vertex
Just holds vertex data for convenience.
Definition:
Vertex.hpp:39
BARE2D::Vertex::uv
UV uv
Definition:
Vertex.hpp:44
BARE2D
Definition:
App.cpp:13
BARE2D::Glyph::depth
float depth
Definition:
Vertex.hpp:97
BARE2D::Vertex::setColour
void setColour(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
Sets the colour.
Definition:
Vertex.hpp:65
BARE2D::Colour::Colour
Colour(GLubyte R, GLubyte G, GLubyte B, GLubyte A)
Definition:
Vertex.hpp:22
BARE2D::Texture
The texture struct holds very basic stuff - the filepath, width, height, and ID,.
Definition:
Texture.hpp:13
BARE2D::Glyph::topRight
Vertex topRight
Definition:
Vertex.hpp:100
BARE2D::Glyph::bottomRight
Vertex bottomRight
Definition:
Vertex.hpp:100
BARE2D::Vertex::position
Position position
Definition:
Vertex.hpp:40
BARE2D::Position::x
float x
Definition:
Vertex.hpp:13
BARE2D::Glyph::bottomLeft
Vertex bottomLeft
Definition:
Vertex.hpp:100
BARE2D::UV
Holds two floats which can act as UV sizes or positions.
Definition:
Vertex.hpp:31
BARE2D::Vertex::setUV
void setUV(float u, float v)
Sets the UV coords/dimensions.
Definition:
Vertex.hpp:77
BARE2D::Colour::a
GLubyte a
Definition:
Vertex.hpp:24
BARE2D::Colour::Colour
Colour()
Definition:
Vertex.hpp:21
BARE2D::Glyph::rotatePoint
glm::vec2 rotatePoint(const glm::vec2 &pos, float &angle)
Definition:
Vertex.cpp:87
BARE2D::Colour::b
GLubyte b
Definition:
Vertex.hpp:24
BARE2D::Glyph
The glyph represents a renderbatch's primitive data, which is created from each draw call in the basi...
Definition:
Vertex.hpp:87
BARE2D::Glyph::topLeft
Vertex topLeft
Definition:
Vertex.hpp:100
BARE2D::Vertex::colour
Colour colour
Definition:
Vertex.hpp:42
BARE2D::Glyph::texture
GLuint texture
Definition:
Vertex.hpp:94
BARE2D::Colour::r
GLubyte r
Definition:
Vertex.hpp:24
BARE2D::Colour::g
GLubyte g
Definition:
Vertex.hpp:24
BARE2D::Glyph::Glyph
Glyph(glm::vec4 &destRect, glm::vec4 &uvRect, GLuint &Texture, float &Depth, Colour &colour)
Definition:
Vertex.cpp:4
BARE2D::Position::y
float y
Definition:
Vertex.hpp:13
BARE2D::Vertex::setPosition
void setPosition(float x, float y, float z)
Literally just sets the position. Convenient.
Definition:
Vertex.hpp:52
BARE2D::UV::u
float u
Definition:
Vertex.hpp:32
BARE2D::Position::z
float z
Definition:
Vertex.hpp:13
BARE2D::Colour
An RGBA 8-bit colour value.
Definition:
Vertex.hpp:20
BARE2D::UV::v
float v
Definition:
Vertex.hpp:32
BARE2D::Position
Positional data.
Definition:
Vertex.hpp:12
Source
Vertex.hpp
Generated by
1.8.17