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