My Project
GLType.h
1 #pragma once
2 #include <string>
3 #include "PERef.h"
4 
5 #define GL_CONTENT_SCALE_FACTOR() 1
6 
7 
8 namespace ParaEngine {
9 
10 
11 enum class GlyphCollection {
12  DYNAMIC,
13  NEHE,
14  ASCII,
15  CUSTOM
16 };
17 
18 class GL {
19 public:
20  static void bindTexture2D(GLuint textureId);
21  static void bindTexture2DN(GLuint textureUnit, GLuint textureId);
22 
23  static void deleteTexture(GLuint textureId);
24 
25  static void deleteProgram(GLuint program);
26  static void useProgram(GLuint program);
27  static void bindVAO(GLuint vaoId);
28  static void enableVertexAttribs(uint32_t flags);
29 };
30 
31 typedef struct _ttfConfig
32 {
33  std::string fontFilePath;
34  float fontSize;
35 
36  GlyphCollection glyphs;
37  const char *customGlyphs;
38 
39  bool distanceFieldEnabled;
40  int outlineSize;
41 
42  bool italics;
43  bool bold;
44  bool underline;
45  bool strikethrough;
46 
47  _ttfConfig(const std::string& filePath = "", float size = 12, const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC,
48  const char *customGlyphCollection = nullptr, bool useDistanceField = false, int outline = 0,
49  bool useItalics = false, bool useBold = false, bool useUnderline = false, bool useStrikethrough = false)
50  : fontFilePath(filePath)
51  , fontSize(size)
52  , glyphs(glyphCollection)
53  , customGlyphs(customGlyphCollection)
54  , distanceFieldEnabled(useDistanceField)
55  , outlineSize(outline)
56  , italics(useItalics)
57  , bold(useBold)
58  , underline(useUnderline)
59  , strikethrough(useStrikethrough)
60  {
61  if (outline > 0)
62  {
63  distanceFieldEnabled = false;
64  }
65  }
66 } TTFConfig;
67 
69 {
70  unsigned short letteCharUTF16;
71  float U;
72  float V;
73  float width;
74  float height;
75  float offsetX;
76  float offsetY;
77  int textureID;
78  bool validDefinition;
79  int xAdvance;
80 
81  int clipBottom;
82 };
83 
84 
85 struct Color4B;
86 struct Color4F;
87 
91 struct Color3B
92 {
93  Color3B();
94  Color3B(GLubyte _r, GLubyte _g, GLubyte _b);
95  explicit Color3B(const Color4B& color);
96  explicit Color3B(const Color4F& color);
97 
98  bool operator==(const Color3B& right) const;
99  bool operator==(const Color4B& right) const;
100  bool operator==(const Color4F& right) const;
101  bool operator!=(const Color3B& right) const;
102  bool operator!=(const Color4B& right) const;
103  bool operator!=(const Color4F& right) const;
104 
105  bool equals(const Color3B& other)
106  {
107  return (*this == other);
108  }
109 
110  GLubyte r;
111  GLubyte g;
112  GLubyte b;
113 
114  static const Color3B WHITE;
115  static const Color3B YELLOW;
116  static const Color3B BLUE;
117  static const Color3B GREEN;
118  static const Color3B RED;
119  static const Color3B MAGENTA;
120  static const Color3B BLACK;
121  static const Color3B ORANGE;
122  static const Color3B GRAY;
123 };
124 
128 struct Color4B
129 {
130  Color4B();
131  Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a);
132  explicit Color4B(const Color3B& color);
133  explicit Color4B(const Color4F& color);
134 
135  bool operator==(const Color4B& right) const;
136  bool operator==(const Color3B& right) const;
137  bool operator==(const Color4F& right) const;
138  bool operator!=(const Color4B& right) const;
139  bool operator!=(const Color3B& right) const;
140  bool operator!=(const Color4F& right) const;
141 
142  GLubyte r;
143  GLubyte g;
144  GLubyte b;
145  GLubyte a;
146 
147  static const Color4B WHITE;
148  static const Color4B YELLOW;
149  static const Color4B BLUE;
150  static const Color4B GREEN;
151  static const Color4B RED;
152  static const Color4B MAGENTA;
153  static const Color4B BLACK;
154  static const Color4B ORANGE;
155  static const Color4B GRAY;
156 };
157 
158 
162 struct Color4F
163 {
164  Color4F();
165  Color4F(float _r, float _g, float _b, float _a);
166  explicit Color4F(const Color3B& color);
167  explicit Color4F(const Color4B& color);
168 
169  bool operator==(const Color4F& right) const;
170  bool operator==(const Color3B& right) const;
171  bool operator==(const Color4B& right) const;
172  bool operator!=(const Color4F& right) const;
173  bool operator!=(const Color3B& right) const;
174  bool operator!=(const Color4B& right) const;
175 
176  bool equals(const Color4F &other)
177  {
178  return (*this == other);
179  }
180 
181  GLfloat r;
182  GLfloat g;
183  GLfloat b;
184  GLfloat a;
185 
186  static const Color4F WHITE;
187  static const Color4F YELLOW;
188  static const Color4F BLUE;
189  static const Color4F GREEN;
190  static const Color4F RED;
191  static const Color4F MAGENTA;
192  static const Color4F BLACK;
193  static const Color4F ORANGE;
194  static const Color4F GRAY;
195 };
196 
197 
198 
199 
201 {
202 public:
203 
204 
205  float x;
206  float y;
207 
208  CCVector2();
209  CCVector2(float vx, float vy);
210 
211  bool equals(const CCVector2& v) const;
212 
213  static CCVector2 ZERO;
214 
215 };
216 
217 class Size
218 {
219 public:
220 
221  Size();
222 
223  Size(float width, float height);
224 
225 
226  bool equals(const Size& v) const;
227 
228 
229  float width;
230  float height;
231 
232  static const Size ZERO;
233 };
234 
235 
236 
237 class CCRect
238 {
239 public:
244 
245 public:
250  CCRect();
255  CCRect(float x, float y, float width, float height);
260  CCRect(const CCVector2& pos, const Size& dimension);
266  CCRect(const CCRect& other);
271  CCRect& operator= (const CCRect& other);
277  void setRect(float x, float y, float width, float height);
282  float getMinX() const;
283 
287  float getMidX() const;
288 
292  float getMaxX() const;
293 
297  float getMinY() const;
298 
302  float getMidY() const;
303 
307  float getMaxY() const;
308 
312  bool equals(const CCRect& rect) const;
317  bool containsPoint(const CCVector2& point) const;
322  bool intersectsRect(const CCRect& rect) const;
327  bool intersectsCircle(const CCVector2& center, float radius) const;
333  CCRect unionWithRect(const CCRect & rect) const;
335  void merge(const CCRect& rect);
337  static const CCRect ZERO;
338 };
339 }
RGB color composed of bytes 3 bytes.
Definition: GLType.h:91
Definition: GLType.h:217
static const CCRect ZERO
An empty Rect.
Definition: GLType.h:337
different physics engine has different winding order.
Definition: EventBinding.h:32
Definition: GLType.h:200
Definition: other.hpp:41
CCVector2 origin
Low left point of rect.
Definition: GLType.h:241
RGBA color composed of 4 floats.
Definition: GLType.h:162
Definition: GLType.h:18
RGBA color composed of 4 bytes.
Definition: GLType.h:128
static const Color3B WHITE
Color constants.
Definition: GLType.h:114
Size size
Width and height of the rect.
Definition: GLType.h:243
Definition: GLType.h:237
Definition: GLType.h:68
Definition: GLType.h:31