Neo  0.5.0
Developer Documentation
Render.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 (C) Yannick Pflanzer <neo-engine.de>
3  *
4  * This file is part of Neo2D.
5  *
6  * Neo2D is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Neo2D is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with Neo2D. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Diese Datei ist Teil von Neo2D.
20  *
21  * Neo2D ist Freie Software: Sie können es unter den Bedingungen
22  * der GNU Lesser General Public License, wie von der Free Software Foundation,
23  * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
24  * veröffentlichten Version, weiterverbreiten und/oder modifizieren.
25  *
26  * Neo2D wird in der Hoffnung, dass es nützlich sein wird, aber
27  * OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
28  * Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
29  * Siehe die GNU Lesser General Public License für weitere Details.
30  *
31  * Sie sollten eine Kopie der GNU Lesser General Public License zusammen mit
32  *diesem
33  * Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
34  */
35 
36 #ifndef __RENDER_H__
37 #define __RENDER_H__
38 
39 #include <NeoEngine.h>
40 #include <Neo2D.h>
41 
42 namespace Neo2D
43 {
44 
45 using namespace Neo;
46 
56 class NEO2D_EXPORT Render
57 {
58 private:
59  unsigned int m_colorOnlyFx;
60  unsigned int m_texturedFx;
61  int m_right, m_left, m_top, m_bottom;
62 
63  unsigned int m_colorVao;
64  unsigned int m_textureVao;
65 
66  Vector2 m_resolution;
67 
68  void init(unsigned int fx, unsigned int* vao);
69 
70 public:
71  static Render* getInstance()
72  {
73  static Render m_instance;
74  return &m_instance;
75  }
76 
77  Vector2 getResolution() { return m_resolution; }
78 
89  void drawColoredQuad(float x, float y, float w, float h, Vector4 color,
90  float rotation = 0);
101  void drawTexturedQuad(float x, float y, float w, float h, int texture,
102  float rotation = 0);
114  void drawTexturedQuad(float x, float y, float w, float h, int texture,
115  float rotation, Vector2 scale);
116 
129  void drawTexturedQuad(float x, float y, float w, float h, int texture,
130  float rotation, Vector2 scale, Vector2 flip);
131 
145  void drawTexturedQuad(float x, float y, float w, float h, int texture,
146  float rotation, Vector2 scale, Vector2 flip,
147  Vector4 texcoords);
148 
157  void drawText(OText* text, float x, float y, float rotation = 0);
158 
165  void set2D(float w, float h);
166 
177  void loadShader(const char* vert, const char* frag, unsigned int* fx);
178 
186  OText* createText(const char* font, float size);
187 
188  Render();
189 };
190 }
191 #endif
Definition: Vector4.h:31
Definition: OText.h:40
Vector2 getResolution()
Definition: Render.h:77
The Render class contains helper methods for rendering 2D shapes.
Definition: Render.h:56
Definition: Vector2.h:31
Definition: Button.h:42
static Render * getInstance()
Definition: Render.h:71
Definition: Color.h:29