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-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_MODERNOPENGLGRAPHICS_H
24 #define RENDER_MODERNOPENGLGRAPHICS_H
25 
26 #if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__native_client__)
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  ~ModernOpenGLGraphics() 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 GLint *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  inline void bindElementBuffer(const GLuint ebo) restrict2 A_INLINE;
126 
132 
133  float mFloatColor;
135  GLuint mProgramId;
137  GLint mPosAttrib;
141  GLuint mVao;
142  GLuint mVbo;
143  GLuint mEbo;
144  GLuint mVboBinded;
145  GLuint mEboBinded;
149 #ifdef DEBUG_BIND_TEXTURE
150  std::string mOldTexture;
151  unsigned mOldTextureId;
152 #endif // DEBUG_BIND_TEXTURE
153 
155 };
156 #endif // defined(USE_OPENGL) && !defined(ANDROID) &&
157  // !defined(__native_client__)
158 
159 #endif // RENDER_MODERNOPENGLGRAPHICS_H
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
void bindElementBuffer(const GLuint ebo) A_INLINE
void drawQuad(const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height) A_INLINE
#define A_NONNULLPOINTER
Definition: localconsts.h:257
void drawLineArrays(const int size) A_INLINE
void bindArrayBuffer(const GLuint vbo) A_INLINE
#define final
Definition: localconsts.h:45
#define A_NONNULL(...)
Definition: localconsts.h:159
#define RENDER_OPENGLGRAPHICSDEFADVANCED_HPP
#define RENDER_OPENGLGRAPHICSDEF_HPP
void removeArray(const uint32_t id, uint32_t *const arr)
void drawTriangleArray(const int size) A_INLINE
void bindArrayBufferAndAttributes(const GLuint vbo) A_INLINE
#define RENDER_GRAPHICSDEF_HPP
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
#define PRAGMA48(str)
Definition: localconsts.h:190
void createGLContext(const bool custom)
void setColor(const Color &color)
void finalize(ImageCollection *const col)
Definition: color.h:74
#define restrict
Definition: localconsts.h:156
#define restrict2
Definition: localconsts.h:157