ManaPlus
Macros | Functions
mobileopenglgraphics.cpp File Reference

(986a3bf)

#include "render/mobileopenglgraphics.h"
#include "render/opengl/mgl.h"
#include "render/vertexes/imagecollection.h"
#include "resources/imagerect.h"
#include "resources/openglimagehelper.h"
#include "resources/image/image.h"
#include "utils/sdlcheckutils.h"
#include "debug.h"
#include "render/graphics_drawImageRect.hpp"
#include "render/graphics_calcImageRect.hpp"

Go to the source code of this file.

Macros

#define vertFill2D(tVar, vVar, x1, y1, x2, y2, dstX, dstY, w, h)
 

Functions

static void drawQuad (const Image *const image, const int srcX, const int srcY, const int dstX, const int dstY, const int width, const int height) A_INLINE
 
static void drawRescaledQuad (const Image *const image, 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
 

Macro Definition Documentation

◆ vertFill2D

#define vertFill2D (   tVar,
  vVar,
  x1,
  y1,
  x2,
  y2,
  dstX,
  dstY,
  w,
 
)
Value:
tVar[vp + 0] = x1; \
tVar[vp + 1] = y1; \
tVar[vp + 2] = x2; \
tVar[vp + 3] = y1; \
tVar[vp + 4] = x2; \
tVar[vp + 5] = y2; \
tVar[vp + 6] = x1; \
tVar[vp + 7] = y1; \
tVar[vp + 8] = x1; \
tVar[vp + 9] = y2; \
tVar[vp + 10] = x2; \
tVar[vp + 11] = y2; \
vVar[vp + 0] = static_cast<GLshort>(dstX); \
vVar[vp + 1] = static_cast<GLshort>(dstY); \
vVar[vp + 2] = static_cast<GLshort>(dstX + w); \
vVar[vp + 3] = static_cast<GLshort>(dstY); \
vVar[vp + 4] = static_cast<GLshort>(dstX + w); \
vVar[vp + 5] = static_cast<GLshort>(dstY + h); \
vVar[vp + 6] = static_cast<GLshort>(dstX); \
vVar[vp + 7] = static_cast<GLshort>(dstY); \
vVar[vp + 8] = static_cast<GLshort>(dstX); \
vVar[vp + 9] = static_cast<GLshort>(dstY + h); \
vVar[vp + 10] = static_cast<GLshort>(dstX + w); \
vVar[vp + 11] = static_cast<GLshort>(dstY + h)

Definition at line 48 of file mobileopenglgraphics.cpp.

Function Documentation

◆ drawQuad()

static void drawQuad ( const Image *const  image,
const int  srcX,
const int  srcY,
const int  dstX,
const int  dstY,
const int  width,
const int  height 
)
inlinestatic

Definition at line 181 of file mobileopenglgraphics.cpp.

188 {
189 // if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
190  {
191  const float tw = static_cast<float>(image->mTexWidth);
192  const float th = static_cast<float>(image->mTexHeight);
193  // Find OpenGL normalized texture coordinates.
194  const float texX1 = static_cast<float>(srcX) / tw;
195  const float texY1 = static_cast<float>(srcY) / th;
196  const float texX2 = static_cast<float>(srcX + width) / tw;
197  const float texY2 = static_cast<float>(srcY + height) / th;
198 
199  GLfloat tex[] =
200  {
201  texX1, texY1,
202  texX2, texY1,
203  texX1, texY2,
204  texX2, texY2
205  };
206 
207  GLshort vert[] =
208  {
209  static_cast<GLshort>(dstX), static_cast<GLshort>(dstY),
210  static_cast<GLshort>(dstX + width), static_cast<GLshort>(dstY),
211  static_cast<GLshort>(dstX), static_cast<GLshort>(dstY + height),
212  static_cast<GLshort>(dstX + width),
213  static_cast<GLshort>(dstY + height)
214  };
215 
216  glVertexPointer(2, GL_SHORT, 0, &vert);
217  glTexCoordPointer(2, GL_FLOAT, 0, &tex);
218 
219 #ifdef DEBUG_DRAW_CALLS
220  MobileOpenGLGraphics::mDrawCalls ++;
221 #endif // DEBUG_DRAW_CALLS
222  mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
223 #ifdef OPENGLERRORS
225 #endif // OPENGLERRORS
226  }
227 }
static void logError()
GraphicsManager graphicsManager
#define mglDrawArrays(...)
Definition: mgl.hpp:83

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

◆ drawRescaledQuad()

static void drawRescaledQuad ( const Image *const  image,
const int  srcX,
const int  srcY,
const int  dstX,
const int  dstY,
const int  width,
const int  height,
const int  desiredWidth,
const int  desiredHeight 
)
inlinestatic

Definition at line 237 of file mobileopenglgraphics.cpp.

243 {
244 // if (OpenGLImageHelper::mTextureType == GL_TEXTURE_2D)
245  {
246  const float tw = static_cast<float>(image->mTexWidth);
247  const float th = static_cast<float>(image->mTexHeight);
248  // Find OpenGL normalized texture coordinates.
249  const float texX1 = static_cast<float>(srcX) / tw;
250  const float texY1 = static_cast<float>(srcY) / th;
251  const float texX2 = static_cast<float>(srcX + width) / tw;
252  const float texY2 = static_cast<float>(srcY + height) / th;
253 
254  GLfloat tex[] =
255  {
256  texX1, texY1,
257  texX2, texY1,
258  texX1, texY2,
259  texX2, texY2
260  };
261 
262  GLshort vert[] =
263  {
264  static_cast<GLshort>(dstX), static_cast<GLshort>(dstY),
265  static_cast<GLshort>(dstX + desiredWidth),
266  static_cast<GLshort>(dstY),
267  static_cast<GLshort>(dstX), static_cast<GLshort>(
268  dstY + desiredHeight),
269  static_cast<GLshort>(dstX + desiredWidth),
270  static_cast<GLshort>(dstY + desiredHeight)
271  };
272  glVertexPointer(2, GL_SHORT, 0, &vert);
273  glTexCoordPointer(2, GL_FLOAT, 0, &tex);
274 
275 #ifdef DEBUG_DRAW_CALLS
276  MobileOpenGLGraphics::mDrawCalls ++;
277 #endif // DEBUG_DRAW_CALLS
278  mglDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
279 #ifdef OPENGLERRORS
281 #endif // OPENGLERRORS
282  }
283 }

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