PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
gl_renderer.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef GL_RENDERER_H
20 #define GL_RENDERER_H
21 
22 #include <QString>
23 #include <common_features/pge_texture.h>
24 #include <common_features/rectf.h>
25 #include <common_features/point.h>
26 #include <common_features/pointf.h>
27 
28 struct SDL_Thread;
30 {
31 public:
32  static bool init();
33  static bool uninit();
34  static PGE_PointF mapToOpengl(PGE_Point s);
35 
36  static QString ScreenshotPath;
37  static void makeShot();
38  static int makeShot_action(void *_pixels);
39  static bool ready();
40  static void setRGB(float Red, float Green, float Blue, float Alpha=1.0);
41  static void resetRGB();
42 
43  static void renderTexture(PGE_Texture *texture, float x, float y);
44  static void renderTexture(PGE_Texture *texture, float x, float y, float w, float h, float ani_top=0, float ani_bottom=1, float ani_left=0, float ani_right=1);
45  static void renderTextureCur(float x, float y, float w, float h, float ani_top=0, float ani_bottom=1, float ani_left=0, float ani_right=1);
46  static void renderRect(float x, float y, float w, float h, GLfloat red=1.f, GLfloat green=1.f, GLfloat blue=1.f, GLfloat alpha=1.f, bool filled=true);
47  static void renderRectBR(float _left, float _top, float _right, float _bottom, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
48 
49  static PGE_PointF MapToGl(PGE_Point point);
50  static PGE_PointF MapToGl(float x, float y);
51  static PGE_Point MapToScr(PGE_Point point);
52  static PGE_Point MapToScr(int x, int y);
53  static int alignToCenter(int x, int w);
54  static void setViewport(int x, int y, int w, int h);
55  static void resetViewport();
56  static void setViewportSize(int w, int h);
57  static void setWindowSize(int w, int h);
58 
59  static PGE_Texture loadTexture(QString path, QString maskPath="");
60  static void loadTextureP(PGE_Texture &target, QString path, QString maskPath="");
61  static void deleteTexture(PGE_Texture &tx);
62 private:
63  static void initDummyTexture();
64  static PGE_Texture _dummyTexture;
65 
66  //Virtual resolution of renderable zone
67  static int window_w;
68  static int window_h;
69 
70  //Scale of virtual and window resolutuins
71  static float scale_x;
72  static float scale_y;
73  //Side offsets to keep ratio
74  static float offset_x;
75  static float offset_y;
76  //current viewport
77  static float viewport_x;
78  static float viewport_y;
79  //Need to calculate relative viewport position when screen was scaled
80  static float viewport_scale_x;
81  static float viewport_scale_y;
82  //Resolution of viewport
83  static float viewport_w;
84  static float viewport_h;
85  //Half values of viewport Resolution
86  static float viewport_w_half;
87  static float viewport_h_half;
88 
89  //Texture render color levels
90  static float color_level_red;
91  static float color_level_green;
92  static float color_level_blue;
93  static float color_level_alpha;
94 
95  static SDL_Thread *thread;
96  static bool _isReady;
97 };
98 
99 #endif // GL_RENDERER_H
100 
Definition: gl_renderer.h:29
Definition: pge_texture.h:32
Definition: pointf.h:23
Definition: point.h:23
static void renderTexture(PGE_Texture *texture, float x, float y)
Render texture as-is.
Definition: gl_renderer.cpp:538
static void renderTextureCur(float x, float y, float w, float h, float ani_top=0, float ani_bottom=1, float ani_left=0, float ani_right=1)
Draw currently binded texture.
Definition: gl_renderer.cpp:671