ManaPlus
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes
MobileOpenGL2Graphics Class Reference

#include <mobileopengl2graphics.h>

Inheritance diagram for MobileOpenGL2Graphics:
Graphics

Public Member Functions

 MobileOpenGL2Graphics ()
 
 ~MobileOpenGL2Graphics ()
 
void postInit ()
 
void setColor (const Color &color)
 
void screenResized ()
 
void finalize (ImageCollection *const col)
 
void finalize (ImageVertexes *const vert)
 
void testDraw ()
 
void removeArray (const uint32_t id, uint32_t *const arr)
 
void createGLContext (const bool custom)
 
- Public Member Functions inherited from Graphics
virtual ~Graphics ()
 
void setWindow (SDL_Surface *const window, const int width, const int height)
 
SDL_Surface * getWindow () const
 
void setSync (const bool sync)
 
bool getSync () const
 
virtual bool setVideoMode (const int w, const int h, const int scale, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)=0
 
bool setFullscreen (const bool fs)
 
virtual bool resizeScreen (const int width, const int height)
 
virtual void restoreContext ()
 
virtual void drawRescaledImage (const Image *const image, int dstX, int dstY, const int desiredWidth, const int desiredHeight)=0
 
virtual void drawPattern (const Image *const image, const int x, const int y, const int w, const int h)=0
 
virtual void drawRescaledPattern (const Image *const image, const int x, const int y, const int w, const int h, const int scaledWidth, const int scaledHeight)=0
 
virtual void drawImageRect (const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
 
virtual void calcPattern (ImageVertexes *const vert, const Image *const image, const int x, const int y, const int w, const int h) const =0
 
virtual void calcPattern (ImageCollection *const vert, const Image *const image, const int x, const int y, const int w, const int h) const =0
 
virtual void calcTileVertexes (ImageVertexes *const vert, const Image *const image, int x, int y) const =0
 
virtual void calcTileSDL (ImageVertexes *const vert, int x, int y) const
 
virtual void drawTileVertexes (const ImageVertexes *const vert)=0
 
virtual void drawTileCollection (const ImageCollection *const vertCol)=0
 
virtual void calcTileCollection (ImageCollection *const vertCol, const Image *const image, int x, int y)=0
 
virtual void calcWindow (ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
 
virtual void fillRectangle (const Rect &rectangle)=0
 
virtual void updateScreen ()=0
 
void setWindowSize (const int width, const int height)
 
int getWidth () const
 
int getHeight () const
 
int getMemoryUsage () const
 
virtual void drawNet (const int x1, const int y1, const int x2, const int y2, const int width, const int height)
 
ClipRectgetTopClip () const
 
void setRedraw (const bool n)
 
bool getRedraw () const
 
void setSecure (const bool n)
 
bool getSecure () const
 
int getBpp () const
 
bool getFullScreen () const
 
bool getHWAccel () const
 
bool getDoubleBuffer () const
 
RenderType getOpenGL () const
 
void setNoFrame (const bool n)
 
const std::string & getName () const
 
virtual void initArrays (const int vertCount)
 
const ColorgetColor () const
 
virtual void drawImage (const Image *const image, int dstX, int dstY)=0
 
virtual void copyImage (const Image *const image, int dstX, int dstY)=0
 
virtual void drawImageCached (const Image *const image, int srcX, int srcY)=0
 
virtual void drawPatternCached (const Image *const image, const int x, const int y, const int w, const int h)=0
 
virtual void completeCache ()=0
 
int getScale () const
 
virtual bool isAllowScale () const
 
void setScale (int scale)
 
virtual void pushClipArea (const Rect &area)
 
virtual void popClipArea ()
 
virtual void drawLine (int x1, int y1, int x2, int y2)=0
 
virtual void drawRectangle (const Rect &rectangle)=0
 
virtual void drawPoint (int x, int y)=0
 
virtual void beginDraw ()
 
virtual void endDraw ()
 
virtual void clearScreen () const
 
virtual void deleteArrays ()
 

Private Member Functions

void deleteGLObjects ()
 
void drawQuad (const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height) 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 drawTriangleArray (const int size) A_INLINE
 
void drawTriangleArray (const GLfloat *const array, const int size) A_INLINE
 
void drawLineArrays (const int size) A_INLINE
 
void bindArrayBuffer (const GLuint vbo) A_INLINE
 
void bindArrayBufferAndAttributes (const GLuint vbo) A_INLINE
 
void bindAttributes () A_INLINE
 

Static Private Member Functions

static void bindTexture2 (const GLenum target, const Image *const image)
 

Private Attributes

GLfloat * mFloatArray
 
GLfloat * mFloatArrayCached
 
ShaderProgrammProgram
 
float mAlphaCached
 
int mVpCached
 
float mFloatColor
 
int mMaxVertices
 
GLuint mProgramId
 
GLuint mSimpleColorUniform
 
GLint mPosAttrib
 
GLint mTextureColorUniform
 
GLuint mScreenUniform
 
GLuint mDrawTypeUniform
 
GLuint mVao
 
GLuint mVbo
 
GLuint mVboBinded
 
GLuint mAttributesBinded
 
bool mColorAlpha
 
bool mTextureDraw
 
FBOInfo mFbo
 

Static Private Attributes

static GLuint mTextureSizeUniform = 0U
 
static int mTextureWidth = 1
 
static int mTextureHeight = 1
 

Additional Inherited Members

- Public Types inherited from Graphics
enum  Alignment { LEFT = 0 , CENTER , RIGHT }
 
- Static Public Member Functions inherited from Graphics
static void cleanUp ()
 
- Data Fields inherited from Graphics
int mWidth
 
int mHeight
 
int mActualWidth
 
int mActualHeight
 
- Protected Member Functions inherited from Graphics
 Graphics ()
 
void setMainFlags (const int w, const int h, const int scale, const int bpp, const bool fs, const bool hwaccel, const bool resize, const bool noFrame, const bool allowHighDPI)
 
int getOpenGLFlags () const
 
int getSoftwareFlags () const
 
bool setOpenGLMode ()
 
void updateMemoryInfo ()
 
bool videoInfo ()
 
void setOpenGLFlags ()
 
- Protected Attributes inherited from Graphics
MStack< ClipRectmClipStack
 
SDL_Surface * mWindow
 
int mBpp
 
bool mAlpha
 
bool mFullscreen
 
bool mHWAccel
 
bool mRedraw
 
bool mDoubleBuffer
 
SDL_Rect mRect
 
bool mSecure
 
RenderType mOpenGL
 
bool mEnableResize
 
bool mNoFrame
 
bool mAllowHighDPI
 
std::string mName
 
int mStartFreeMem
 
bool mSync
 
int mScale
 
Color mColor
 
- Static Protected Attributes inherited from Graphics
static void * mGLContext = 0
 

Detailed Description

Definition at line 64 of file mobileopengl2graphics.h.

Constructor & Destructor Documentation

◆ MobileOpenGL2Graphics()

MobileOpenGL2Graphics::MobileOpenGL2Graphics ( )

Definition at line 92 of file mobileopengl2graphics.cpp.

92  :
93  mFloatArray(nullptr),
94  mFloatArrayCached(nullptr),
95  mProgram(nullptr),
96  mAlphaCached(1.0F),
97  mVpCached(0),
98  mFloatColor(1.0F),
99  mMaxVertices(500),
100  mProgramId(0U),
102  mPosAttrib(0),
104  mScreenUniform(0U),
105  mDrawTypeUniform(0U),
106 #ifndef __native_client__
107  mVao(0U),
108 #endif // __native_client__
109  mVbo(0U),
110  mVboBinded(0U),
111  mAttributesBinded(0U),
112  mColorAlpha(false),
113  mTextureDraw(false),
114 #ifdef DEBUG_BIND_TEXTURE
115  mOldTexture(),
116  mOldTextureId(0),
117 #endif // DEBUG_BIND_TEXTURE
118  mFbo()
119 {
121  mName = "mobile OpenGL ES 2";
122 }
RenderType mOpenGL
Definition: graphics.h:545
std::string mName
Definition: graphics.h:549
@ RENDER_GLES2_OPENGL
Definition: rendertype.h:33

References Graphics::mName, Graphics::mOpenGL, and RENDER_GLES2_OPENGL.

◆ ~MobileOpenGL2Graphics()

MobileOpenGL2Graphics::~MobileOpenGL2Graphics ( )

Definition at line 124 of file mobileopengl2graphics.cpp.

125 {
127  deleteGLObjects();
128 }
void deleteArraysInternal() restrict2

References deleteArraysInternal(), and deleteGLObjects().

Member Function Documentation

◆ bindArrayBuffer()

void MobileOpenGL2Graphics::bindArrayBuffer ( const GLuint  vbo)
inlineprivate

Definition at line 1186 of file mobileopengl2graphics.cpp.

1187 {
1188  if (mVboBinded != vbo)
1189  {
1190  mVboBinded = vbo;
1191  mglBindBuffer(GL_ARRAY_BUFFER, vbo);
1192  mAttributesBinded = 0U;
1193  }
1194 }
#define GL_ARRAY_BUFFER
Definition: mgldefines.h:84

References GL_ARRAY_BUFFER.

Referenced by postInit().

◆ bindArrayBufferAndAttributes()

void MobileOpenGL2Graphics::bindArrayBufferAndAttributes ( const GLuint  vbo)
inlineprivate

Definition at line 1196 of file mobileopengl2graphics.cpp.

1198 {
1199  if (mVboBinded != vbo)
1200  {
1201  mVboBinded = vbo;
1202  mglBindBuffer(GL_ARRAY_BUFFER, vbo);
1203 
1205  mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
1206  }
1207  else if (mAttributesBinded != mVboBinded)
1208  {
1210  mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
1211  }
1212 }

References GL_ARRAY_BUFFER.

◆ bindAttributes()

void MobileOpenGL2Graphics::bindAttributes ( )
inlineprivate

Definition at line 1214 of file mobileopengl2graphics.cpp.

1215 {
1217  {
1219  mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
1220  }
1221 }

References mAttributesBinded, and mVboBinded.

◆ bindTexture2()

void MobileOpenGL2Graphics::bindTexture2 ( const GLenum  target,
const Image *const  image 
)
staticprivate

Definition at line 1144 of file mobileopengl2graphics.cpp.

1146 {
1147  const GLuint texture = image->mGLImage;
1148  if (mTextureBinded != texture)
1149  {
1150  mTextureBinded = texture;
1151  mglBindTexture(target, texture);
1152  if (mTextureWidth != image->mTexWidth ||
1153  mTextureHeight != image->mTexHeight)
1154  {
1155  mTextureWidth = image->mTexWidth;
1156  mTextureHeight = image->mTexHeight;
1157  mglUniform2f(mTextureSizeUniform,
1158  static_cast<GLfloat>(image->mTexWidth),
1159  static_cast<GLfloat>(image->mTexHeight));
1160  }
1161  }
1162 }
#define mglBindTexture(...)
Definition: mgl.hpp:93
static GLuint mTextureBinded

References mglBindTexture, mTextureBinded, mTextureHeight, mTextureSizeUniform, and mTextureWidth.

◆ createGLContext()

void MobileOpenGL2Graphics::createGLContext ( const bool  custom)
virtual

Reimplemented from Graphics.

Definition at line 1267 of file mobileopengl2graphics.cpp.

1268 {
1269  Graphics::createGLContext(custom);
1270 /*
1271  if (mGLContext)
1272  SDL::makeCurrentContext(mGLContext);
1273  else
1274  mGLContext = SDL::createGLContext(mWindow, 2, 0, 0x04);
1275 */
1276 }
virtual void createGLContext(const bool custom)
Definition: graphics.cpp:418

References Graphics::createGLContext().

◆ deleteGLObjects()

void MobileOpenGL2Graphics::deleteGLObjects ( )
private

Definition at line 130 of file mobileopengl2graphics.cpp.

131 {
133  if (mVbo != 0U)
134  mglDeleteBuffers(1, &mVbo);
135 #ifndef __native_client__
136  if (mVao != 0U)
137  mglDeleteVertexArrays(1, &mVao);
138 #endif // __native_client__
139 }
#define delete2(var)
Definition: delete2.h:25

References delete2, mProgram, mVao, and mVbo.

Referenced by screenResized(), and ~MobileOpenGL2Graphics().

◆ drawLineArrays()

void MobileOpenGL2Graphics::drawLineArrays ( const int  size)
inlineprivate

Definition at line 1355 of file mobileopengl2graphics.cpp.

1356 {
1357  mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat),
1359 #ifdef DEBUG_DRAW_CALLS
1360  mDrawCalls ++;
1361 #endif // DEBUG_DRAW_CALLS
1362  mglDrawArrays(GL_LINES, 0, size / 4);
1363 #ifdef OPENGLERRORS
1365 #endif // OPENGLERRORS
1366 }
static void logError()
GraphicsManager graphicsManager
#define mglDrawArrays(...)
Definition: mgl.hpp:83
#define GL_STREAM_DRAW
Definition: mgldefines.h:89
int size()
Definition: emotedb.cpp:306

References GL_ARRAY_BUFFER, GL_STREAM_DRAW, graphicsManager, GraphicsManager::logError(), mglDrawArrays, and EmoteDB::size().

◆ drawQuad()

void MobileOpenGL2Graphics::drawQuad ( const int  srcX,
const int  srcY,
const int  dstX,
const int  dstY,
const int  width,
const int  height 
)
inlineprivate

Definition at line 278 of file mobileopengl2graphics.cpp.

284 {
285  const GLfloat texX2 = static_cast<GLfloat>(srcX + width);
286  const GLfloat texY2 = static_cast<GLfloat>(srcY + height);
287  const GLfloat x2 = static_cast<GLfloat>(dstX + width);
288  const GLfloat y2 = static_cast<GLfloat>(dstY + height);
289  const GLfloat srcX2 = toGL(srcX);
290  const GLfloat srcY2 = toGL(srcY);
291  const GLfloat dstX2 = toGL(dstX);
292  const GLfloat dstY2 = toGL(dstY);
293 
294  GLfloat vertices[] =
295  {
296  dstX2, dstY2, srcX2, srcY2,
297  x2, dstY2, texX2, srcY2,
298  dstX2, y2, srcX2, texY2,
299  x2, y2, texX2, texY2
300  };
301 
302  mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
303  vertices, GL_STREAM_DRAW);
304 #ifdef DEBUG_DRAW_CALLS
305  mDrawCalls ++;
306 #endif // DEBUG_DRAW_CALLS
307  mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
308 #ifdef OPENGLERRORS
310 #endif // OPENGLERRORS
311 }
#define toGL

References GL_ARRAY_BUFFER, GL_STREAM_DRAW, graphicsManager, GraphicsManager::logError(), mglDrawArrays, and toGL.

◆ drawRescaledQuad()

void MobileOpenGL2Graphics::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 
)
inlineprivate

Definition at line 313 of file mobileopengl2graphics.cpp.

318 {
319  const GLfloat texX2 = static_cast<GLfloat>(srcX + width);
320  const GLfloat texY2 = static_cast<GLfloat>(srcY + height);
321  const GLfloat x2 = static_cast<GLfloat>(dstX + desiredWidth);
322  const GLfloat y2 = static_cast<GLfloat>(dstY + desiredHeight);
323  const GLfloat srcX2 = toGL(srcX);
324  const GLfloat srcY2 = toGL(srcY);
325  const GLfloat dstX2 = toGL(dstX);
326  const GLfloat dstY2 = toGL(dstY);
327 
328  GLfloat vertices[] =
329  {
330  dstX2, dstY2, srcX2, srcY2,
331  x2, dstY2, texX2, srcY2,
332  dstX2, y2, srcX2, texY2,
333  x2, y2, texX2, texY2
334  };
335 
336  mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
337  vertices, GL_STREAM_DRAW);
338 #ifdef DEBUG_DRAW_CALLS
339  mDrawCalls ++;
340 #endif // DEBUG_DRAW_CALLS
341  mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
342 #ifdef OPENGLERRORS
344 #endif // OPENGLERRORS
345 }

References GL_ARRAY_BUFFER, GL_STREAM_DRAW, graphicsManager, GraphicsManager::logError(), mglDrawArrays, and toGL.

◆ drawTriangleArray() [1/2]

void MobileOpenGL2Graphics::drawTriangleArray ( const GLfloat *const  array,
const int  size 
)
inlineprivate

Definition at line 1340 of file mobileopengl2graphics.cpp.

1343 {
1344  mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat),
1345  array, GL_STREAM_DRAW);
1346 #ifdef DEBUG_DRAW_CALLS
1347  mDrawCalls ++;
1348 #endif // DEBUG_DRAW_CALLS
1349  mglDrawArrays(GL_TRIANGLES, 0, size / 4);
1350 #ifdef OPENGLERRORS
1352 #endif // OPENGLERRORS
1353 }

References GL_ARRAY_BUFFER, GL_STREAM_DRAW, graphicsManager, GraphicsManager::logError(), mglDrawArrays, and EmoteDB::size().

◆ drawTriangleArray() [2/2]

void MobileOpenGL2Graphics::drawTriangleArray ( const int  size)
inlineprivate

Definition at line 1327 of file mobileopengl2graphics.cpp.

1328 {
1329  mglBufferData(GL_ARRAY_BUFFER, size * sizeof(GLfloat),
1331 #ifdef DEBUG_DRAW_CALLS
1332  mDrawCalls ++;
1333 #endif // DEBUG_DRAW_CALLS
1334  mglDrawArrays(GL_TRIANGLES, 0, size / 4);
1335 #ifdef OPENGLERRORS
1337 #endif // OPENGLERRORS
1338 }

References GL_ARRAY_BUFFER, GL_STREAM_DRAW, graphicsManager, GraphicsManager::logError(), mglDrawArrays, and EmoteDB::size().

◆ finalize() [1/2]

void MobileOpenGL2Graphics::finalize ( ImageCollection *const  col)
virtual

Reimplemented from Graphics.

Definition at line 1278 of file mobileopengl2graphics.cpp.

1280 {
1281  if (col == nullptr)
1282  return;
1283  FOR_EACH (ImageCollectionIter, it, col->draws)
1284  finalize(*it);
1285 }
ImageVertexesVector draws
void finalize(ImageCollection *const col)
#define FOR_EACH(type, iter, array)
Definition: foreach.h:25
ImageVertexesVector::iterator ImageCollectionIter
Definition: imagevertexes.h:57

References FOR_EACH.

◆ finalize() [2/2]

void MobileOpenGL2Graphics::finalize ( ImageVertexes *const  vert)
virtual

Reimplemented from Graphics.

Definition at line 1287 of file mobileopengl2graphics.cpp.

1289 {
1290  // in future need convert in each switchVp/continueVp
1291 
1292  if (vert == nullptr)
1293  return;
1294  OpenGLGraphicsVertexes &ogl = vert->ogl;
1295  const STD_VECTOR<int> &vp = ogl.mVp;
1296  STD_VECTOR<int>::const_iterator ivp;
1297  const STD_VECTOR<int>::const_iterator ivp_end = vp.end();
1298  STD_VECTOR<GLfloat*> &floatTexPool = ogl.mFloatTexPool;
1299  STD_VECTOR<GLfloat*>::const_iterator ft;
1300  const STD_VECTOR<GLfloat*>::const_iterator ft_end = floatTexPool.end();
1301  STD_VECTOR<GLuint> &vbos = ogl.mVbo;
1302  STD_VECTOR<GLuint>::const_iterator ivbo;
1303 
1304  const int sz = CAST_S32(floatTexPool.size());
1305  if (sz == 0)
1306  return;
1307  vbos.resize(sz);
1308  mglGenBuffers(sz, &vbos[0]);
1309 
1310  for (ft = floatTexPool.begin(), ivp = vp.begin(), ivbo = vbos.begin();
1311  ft != ft_end && ivp != ivp_end;
1312  ++ ft, ++ ivp, ++ ivbo)
1313  {
1314  bindArrayBuffer(*ivbo);
1315  mglBufferData(GL_ARRAY_BUFFER, (*ivp) * sizeof(GLfloat),
1316  *ft, GL_STATIC_DRAW);
1317  }
1318 
1319  for (STD_VECTOR<GLfloat*>::iterator it = floatTexPool.begin();
1320  it != floatTexPool.end(); ++ it)
1321  {
1322  delete [] (*it);
1323  }
1324  floatTexPool.clear();
1325 }
#define CAST_S32
Definition: cast.h:30
OpenGLGraphicsVertexes ogl
Definition: imagevertexes.h:50
void bindArrayBuffer(const GLuint vbo) A_INLINE
#define GL_STATIC_DRAW
Definition: mgldefines.h:90

References CAST_S32, GL_ARRAY_BUFFER, GL_STATIC_DRAW, and ImageVertexes::ogl.

◆ postInit()

void MobileOpenGL2Graphics::postInit ( )
virtual

Reimplemented from Graphics.

Definition at line 158 of file mobileopengl2graphics.cpp.

159 {
160 #ifndef __native_client__
161  mglGenVertexArrays(1, &mVao);
162  mglBindVertexArray(mVao);
163 #endif // __native_client__
164  mglGenBuffers(1, &mVbo);
165 // logger->log("gen vbo buffer: %u", mVbo);
167 
168  logger->log("Compiling shaders");
170  if (mProgram == nullptr)
171  {
173  logger->safeError("Shader creation error. See manaplus.log.");
174  }
176  if (mProgramId == 0U)
177  logger->safeError("Shaders compilation error.");
178 
179  logger->log("Shaders compilation done.");
180  mglUseProgram(mProgramId);
181 
182  mPosAttrib = 0;
183 
184  mSimpleColorUniform = mglGetUniformLocation(mProgramId, "color");
185  mScreenUniform = mglGetUniformLocation(mProgramId, "screen");
186  mDrawTypeUniform = mglGetUniformLocation(mProgramId, "drawType");
187  mTextureColorUniform = mglGetUniformLocation(mProgramId, "alpha");
188  mTextureSizeUniform = mglGetUniformLocation(mProgramId, "textureSize");
189 
190  mglUniform1f(mTextureColorUniform, 1.0F);
191 
192  mglVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, nullptr);
193  mglEnableVertexAttribArray(0);
195 
196  mglUniform2f(mScreenUniform,
197  static_cast<float>(mWidth) / 2.0F,
198  static_cast<float>(mHeight) / 2.0F);
199  // for safty init texture size to 1x1
200  mglUniform2f(mTextureSizeUniform,
201  1.0F,
202  1.0F);
203  mglUniform4f(mSimpleColorUniform,
204  0.0F,
205  0.0F,
206  0.0F,
207  0.0F);
208 
209  mglActiveTexture(GL_TEXTURE0);
210 }
int mWidth
Definition: graphics.h:484
int mHeight
Definition: graphics.h:485
void log(const char *const log_text,...)
Definition: logger.cpp:269
void safeError(const std::string &error_text) __attribute__((noreturn))
Definition: logger.cpp:435
unsigned int getProgramId() const
Definition: shaderprogram.h:42
ShaderProgram * getGles2Program()
Logger * logger
Definition: logger.cpp:89
ShadersManager shaders

References bindArrayBuffer(), ShadersManager::getGles2Program(), ShaderProgram::getProgramId(), graphicsManager, Logger::log(), GraphicsManager::logError(), logger, mAttributesBinded, mDrawTypeUniform, Graphics::mHeight, mPosAttrib, mProgram, mProgramId, mScreenUniform, mSimpleColorUniform, mTextureColorUniform, mTextureSizeUniform, mVao, mVbo, Graphics::mWidth, Logger::safeError(), and shaders.

Referenced by screenResized().

◆ removeArray()

void MobileOpenGL2Graphics::removeArray ( const uint32_t  id,
uint32_t *const  arr 
)
virtual

Reimplemented from Graphics.

Definition at line 1175 of file mobileopengl2graphics.cpp.

1177 {
1178  mglDeleteBuffers(sz, arr);
1179  for (size_t f = 0; f < sz; f ++)
1180  {
1181  if (arr[f] == mVboBinded)
1182  mVboBinded = 0;
1183  }
1184 }

◆ screenResized()

void MobileOpenGL2Graphics::screenResized ( )
virtual

Reimplemented from Graphics.

Definition at line 212 of file mobileopengl2graphics.cpp.

213 {
214  deleteGLObjects();
215  mVboBinded = 0U;
216  mAttributesBinded = 0U;
217  mColor = Color(0, 0, 0, 0);
218  postInit();
219 }
Definition: color.h:76
Color mColor
Definition: graphics.h:553

References deleteGLObjects(), mAttributesBinded, Graphics::mColor, mVboBinded, and postInit().

◆ setColor()

void MobileOpenGL2Graphics::setColor ( const Color color)
virtual

Reimplemented from Graphics.

Definition at line 255 of file mobileopengl2graphics.cpp.

256 {
257  mColorAlpha = (color.a != 255);
258  if (mColor != color)
259  {
260  mColor = color;
261  mglUniform4f(mSimpleColorUniform,
262  static_cast<float>(color.r) / 255.0F,
263  static_cast<float>(color.g) / 255.0F,
264  static_cast<float>(color.b) / 255.0F,
265  static_cast<float>(color.a) / 255.0F);
266  }
267 }
unsigned int a
Definition: color.h:251
unsigned int b
Definition: color.h:245
unsigned int r
Definition: color.h:235
unsigned int g
Definition: color.h:240

◆ testDraw()

void MobileOpenGL2Graphics::testDraw ( )
virtual

Reimplemented from Graphics.

Definition at line 384 of file mobileopengl2graphics.cpp.

385 {
386 /*
387  GLfloat vertices[] =
388  {
389  0, 0, 0, 0,
390  800, 0, 800, 0,
391  0, 600, 0, 600,
392  800, 600, 800, 600
393  };
394 */
395 // logger->log("allocate: %d, %ld", mVboBinded, sizeof(vertices));
396 // mglBufferData(GL_ARRAY_BUFFER, sizeof(vertices),
397 // vertices, GL_STREAM_DRAW);
398 #ifdef DEBUG_DRAW_CALLS
399  mDrawCalls ++;
400 #endif // DEBUG_DRAW_CALLS
401  mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
402 // glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, 0);
403 #ifdef OPENGLERRORS
405 #endif // OPENGLERRORS
406 }

References graphicsManager, GraphicsManager::logError(), and mglDrawArrays.

Field Documentation

◆ mAlphaCached

float MobileOpenGL2Graphics::mAlphaCached
private

Definition at line 143 of file mobileopengl2graphics.h.

◆ mAttributesBinded

GLuint MobileOpenGL2Graphics::mAttributesBinded
private

Definition at line 160 of file mobileopengl2graphics.h.

Referenced by bindAttributes(), postInit(), and screenResized().

◆ mColorAlpha

bool MobileOpenGL2Graphics::mColorAlpha
private

Definition at line 161 of file mobileopengl2graphics.h.

Referenced by disableTexturingAndBlending().

◆ mDrawTypeUniform

GLuint MobileOpenGL2Graphics::mDrawTypeUniform
private

◆ mFbo

FBOInfo MobileOpenGL2Graphics::mFbo
private

Definition at line 168 of file mobileopengl2graphics.h.

◆ mFloatArray

GLfloat* MobileOpenGL2Graphics::mFloatArray
private

Definition at line 140 of file mobileopengl2graphics.h.

Referenced by deleteArraysInternal().

◆ mFloatArrayCached

GLfloat* MobileOpenGL2Graphics::mFloatArrayCached
private

Definition at line 141 of file mobileopengl2graphics.h.

Referenced by deleteArraysInternal().

◆ mFloatColor

float MobileOpenGL2Graphics::mFloatColor
private

Definition at line 146 of file mobileopengl2graphics.h.

◆ mMaxVertices

int MobileOpenGL2Graphics::mMaxVertices
private

Definition at line 147 of file mobileopengl2graphics.h.

◆ mPosAttrib

GLint MobileOpenGL2Graphics::mPosAttrib
private

Definition at line 150 of file mobileopengl2graphics.h.

Referenced by postInit().

◆ mProgram

ShaderProgram* MobileOpenGL2Graphics::mProgram
private

Definition at line 142 of file mobileopengl2graphics.h.

Referenced by deleteGLObjects(), and postInit().

◆ mProgramId

GLuint MobileOpenGL2Graphics::mProgramId
private

Definition at line 148 of file mobileopengl2graphics.h.

Referenced by postInit().

◆ mScreenUniform

GLuint MobileOpenGL2Graphics::mScreenUniform
private

Definition at line 152 of file mobileopengl2graphics.h.

Referenced by postInit().

◆ mSimpleColorUniform

GLuint MobileOpenGL2Graphics::mSimpleColorUniform
private

Definition at line 149 of file mobileopengl2graphics.h.

Referenced by postInit().

◆ mTextureColorUniform

GLint MobileOpenGL2Graphics::mTextureColorUniform
private

Definition at line 151 of file mobileopengl2graphics.h.

Referenced by postInit().

◆ mTextureDraw

bool MobileOpenGL2Graphics::mTextureDraw
private

◆ mTextureHeight

int MobileOpenGL2Graphics::mTextureHeight = 1
staticprivate

Definition at line 138 of file mobileopengl2graphics.h.

Referenced by bindTexture2().

◆ mTextureSizeUniform

GLuint MobileOpenGL2Graphics::mTextureSizeUniform = 0U
staticprivate

Definition at line 136 of file mobileopengl2graphics.h.

Referenced by bindTexture2(), and postInit().

◆ mTextureWidth

int MobileOpenGL2Graphics::mTextureWidth = 1
staticprivate

Definition at line 137 of file mobileopengl2graphics.h.

Referenced by bindTexture2().

◆ mVao

GLuint MobileOpenGL2Graphics::mVao
private

Definition at line 155 of file mobileopengl2graphics.h.

Referenced by deleteGLObjects(), and postInit().

◆ mVbo

GLuint MobileOpenGL2Graphics::mVbo
private

Definition at line 158 of file mobileopengl2graphics.h.

Referenced by deleteGLObjects(), and postInit().

◆ mVboBinded

GLuint MobileOpenGL2Graphics::mVboBinded
private

Definition at line 159 of file mobileopengl2graphics.h.

Referenced by bindAttributes(), and screenResized().

◆ mVpCached

int MobileOpenGL2Graphics::mVpCached
private

Definition at line 144 of file mobileopengl2graphics.h.


The documentation for this class was generated from the following files: