ManaPlus
mobileopengl2graphics.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2018 The ManaPlus Developers
6  *
7  * This file is part of The ManaPlus Client.
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef RENDER_MOBILEOPENGL2GRAPHICS_H
24 #define RENDER_MOBILEOPENGL2GRAPHICS_H
25 
26 #if defined(USE_OPENGL) && !defined(ANDROID)
27 
28 #include "localconsts.h"
29 
30 #include "render/graphics.h"
31 
32 #include "resources/fboinfo.h"
33 
34 #ifdef ANDROID
35 #include <GLES/gl.h>
36 #include <GLES/glext.h>
37 #include <GLES2/gl2.h>
38 #else // ANDROID
39 #ifndef USE_SDL2
40 #define GL_GLEXT_PROTOTYPES 1
41 #endif // USE_SDL2
42 PRAGMA48(GCC diagnostic push)
43 PRAGMA48(GCC diagnostic ignored "-Wshadow")
44 #include <SDL_opengl.h>
45 PRAGMA48(GCC diagnostic pop)
46 #if defined(__APPLE__)
47 #include <OpenGL/glext.h>
48 #elif !defined(__native_client__)
49 #include <GL/glext.h>
50 #endif // defined(__APPLE__)
51 #endif // ANDROID
52 
54 class ShaderProgram;
55 
57 {
58  public:
60 
62 
63  ~MobileOpenGL2Graphics() override final;
64 
65  void postInit() restrict2 override final;
66 
67  void setColor(const Color &restrict color) restrict2 override final;
68 
69  void screenResized() restrict2 override final;
70 
71  void finalize(ImageCollection *restrict const col)
72  restrict2 override final;
73 
74  void finalize(ImageVertexes *restrict const vert)
75  restrict2 override final;
76 
77  void testDraw() restrict2 override final;
78 
79  void removeArray(const uint32_t id,
80  uint32_t *restrict const arr)
81  restrict2 override final A_NONNULL(3);
82 
83  void createGLContext(const bool custom) restrict2 override final;
84 
85  #include "render/graphicsdef.hpp"
87 
90 
93 
94  private:
96 
97  inline void drawQuad(const int srcX,
98  const int srcY,
99  const int dstX,
100  const int dstY,
101  const int width,
102  const int height) restrict2 A_INLINE;
103 
104  inline void drawRescaledQuad(const int srcX, const int srcY,
105  const int dstX, const int dstY,
106  const int width, const int height,
107  const int desiredWidth,
108  const int desiredHeight)
109  restrict2 A_INLINE;
110 
111  inline void drawTriangleArray(const int size) restrict2 A_INLINE;
112 
113  inline void drawTriangleArray(const GLfloat *restrict const array,
114  const int size) restrict2 A_INLINE;
115 
116  inline void drawLineArrays(const int size) restrict2 A_INLINE;
117 
118  inline void bindArrayBuffer(const GLuint vbo) restrict2 A_INLINE;
119 
120  inline void bindArrayBufferAndAttributes(const GLuint vbo)
121  restrict2 A_INLINE;
122 
123  inline void bindAttributes() restrict2 A_INLINE;
124 
125  static void bindTexture2(const GLenum target,
126  const Image *restrict const image);
127 
128  static GLuint mTextureSizeUniform;
129  static int mTextureWidth;
130  static int mTextureHeight;
131 
137 
138  float mFloatColor;
140  GLuint mProgramId;
142  GLint mPosAttrib;
146 #ifndef __native_client__
147  GLuint mVao;
148 #endif // __native_client__
149 
150  GLuint mVbo;
151  GLuint mVboBinded;
155 #ifdef DEBUG_BIND_TEXTURE
156  std::string mOldTexture;
157  unsigned mOldTextureId;
158 #endif // DEBUG_BIND_TEXTURE
159 
161 };
162 #endif // defined(USE_OPENGL) && !defined(ANDROID)
163 
164 #endif // RENDER_MOBILEOPENGL2GRAPHICS_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
static void bindTexture2(const GLenum target, const Image *const image)
void drawTriangleArray(const int size) A_INLINE
#define A_NONNULLPOINTER
Definition: localconsts.h:294
void drawRescaledQuad(const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height, const int desiredWidth, const int desiredHeight) A_INLINE
void finalize(ImageCollection *const col)
void removeArray(const uint32_t id, uint32_t *const arr)
void bindArrayBufferAndAttributes(const GLuint vbo) A_INLINE
#define final
Definition: localconsts.h:45
#define RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
#define A_NONNULL(...)
Definition: localconsts.h:179
void setColor(const Color &color)
#define PRAGMA48(str)
Definition: localconsts.h:214
void drawLineArrays(const int size) A_INLINE
#define RENDER_OPENGLGRAPHICSDEF_HPP
void createGLContext(const bool custom)
Definition: image.h:61
Definition: color.h:74
#define restrict
Definition: localconsts.h:176
void bindArrayBuffer(const GLuint vbo) A_INLINE
#define RENDER_GRAPHICSDEF_HPP
void drawQuad(const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height) A_INLINE
#define restrict2
Definition: localconsts.h:177