ManaPlus
modernopenglgraphics.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_MODERNOPENGLGRAPHICS_H
25 #define RENDER_MODERNOPENGLGRAPHICS_H
26 
27 #ifdef USE_OPENGL
28 #if !defined(ANDROID) && !defined(__native_client__) && !defined(__SWITCH__)
29 
30 #include "localconsts.h"
31 
32 #include "render/graphics.h"
33 
34 #include "resources/fboinfo.h"
35 
36 #ifdef ANDROID
37 #include <GLES/gl.h>
38 #include <GLES/glext.h>
39 #include <GLES2/gl2.h>
40 #else // ANDROID
41 #ifndef USE_SDL2
42 #define GL_GLEXT_PROTOTYPES 1
43 #endif // USE_SDL2
44 PRAGMA48(GCC diagnostic push)
45 PRAGMA48(GCC diagnostic ignored "-Wshadow")
46 // ignore -Wredundant-decls for SDL 1.2
47 PRAGMA45(GCC diagnostic push)
48 PRAGMA45(GCC diagnostic ignored "-Wredundant-decls")
49 #include <SDL_opengl.h>
50 PRAGMA45(GCC diagnostic pop)
51 PRAGMA48(GCC diagnostic pop)
52 #if defined(__APPLE__)
53 #include <OpenGL/glext.h>
54 #elif !defined(__native_client__)
55 PRAGMA45(GCC diagnostic push)
56 PRAGMA45(GCC diagnostic ignored "-Wredundant-decls")
57 #include <GL/glext.h>
58 PRAGMA45(GCC diagnostic pop)
59 #endif // defined(__APPLE__)
60 #endif // ANDROID
61 
62 class OpenGLGraphicsVertexes;
63 class ShaderProgram;
64 
66 {
67  public:
69 
71 
72  ~ModernOpenGLGraphics() override final;
73 
74  void postInit() restrict2 override final;
75 
76  void setColor(const Color &restrict color) restrict2 override final;
77 
78  void screenResized() restrict2 override final;
79 
80  void finalize(ImageCollection *restrict const col)
81  restrict2 override final;
82 
83  void finalize(ImageVertexes *restrict const vert)
84  restrict2 override final;
85 
86  void testDraw() restrict2 override final;
87 
88  void removeArray(const uint32_t id,
89  uint32_t *restrict const arr)
90  restrict2 override final A_NONNULL(3);
91 
92  void createGLContext(const bool custom) restrict2 override final;
93 
94  #include "render/graphicsdef.hpp"
96 
99 
102 
103  private:
104  void deleteGLObjects() restrict2;
105 
106  inline void drawQuad(const int srcX,
107  const int srcY,
108  const int dstX,
109  const int dstY,
110  const int width,
111  const int height) restrict2 A_INLINE;
112 
113  inline void drawRescaledQuad(const int srcX, const int srcY,
114  const int dstX, const int dstY,
115  const int width, const int height,
116  const int desiredWidth,
117  const int desiredHeight)
118  restrict2 A_INLINE;
119 
120  inline void drawTriangleArray(const int size) restrict2 A_INLINE;
121 
122  inline void drawTriangleArray(const GLint *restrict const array,
123  const int size) restrict2 A_INLINE;
124 
125  inline void drawLineArrays(const int size) restrict2 A_INLINE;
126 
127  inline void bindArrayBuffer(const GLuint vbo) restrict2 A_INLINE;
128 
129  inline void bindArrayBufferAndAttributes(const GLuint vbo)
130  restrict2 A_INLINE;
131 
132  inline void bindAttributes() restrict2 A_INLINE;
133 
134  inline void bindElementBuffer(const GLuint ebo) restrict2 A_INLINE;
135 
141 
142  float mFloatColor;
144  GLuint mProgramId;
146  GLint mPosAttrib;
150  GLuint mVao;
151  GLuint mVbo;
152  GLuint mEbo;
153  GLuint mVboBinded;
154  GLuint mEboBinded;
158 #ifdef DEBUG_BIND_TEXTURE
159  std::string mOldTexture;
160  unsigned mOldTextureId;
161 #endif // DEBUG_BIND_TEXTURE
162 
163  FBOInfo mFbo;
164 };
165 #endif // defined(USE_OPENGL) && !defined(ANDROID) &&
166  // !defined(__native_client__)
167 #endif // USE_OPENGL
168 
169 #endif // RENDER_MODERNOPENGLGRAPHICS_H
Definition: color.h:76
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 createGLContext(const bool custom)
void drawLineArrays(const int size) A_INLINE
void drawTriangleArray(const int size) A_INLINE
void removeArray(const uint32_t id, uint32_t *const arr)
void bindElementBuffer(const GLuint ebo) A_INLINE
void bindArrayBuffer(const GLuint vbo) A_INLINE
void setColor(const Color &color)
void bindArrayBufferAndAttributes(const GLuint vbo) 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 finalize(ImageCollection *const col)
#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