ManaPlus
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
OpenGLImageHelper Class Reference

#include <openglimagehelper.h>

Inheritance diagram for OpenGLImageHelper:
ImageHelper

Public Member Functions

 OpenGLImageHelper ()
 
 ~OpenGLImageHelper ()
 
Imageload (SDL_RWops *const rw, Dye const &dye)
 
ImageloadSurface (SDL_Surface *const tmpImage)
 
ImagecreateTextSurface (SDL_Surface *const tmpImage, const int width, const int height, const float alpha)
 
SDL_Surface * create32BitSurface (int width, int height) const
 
void postInit ()
 
void copySurfaceToImage (const Image *const image, const int x, const int y, SDL_Surface *surface) const
 
- Public Member Functions inherited from ImageHelper
virtual ~ImageHelper ()
 
Imageload (SDL_RWops *const rw)
 
virtual ImagecreateTextSurface (SDL_Surface *const tmpImage, const int width, const int height, const float alpha) const
 
virtual RenderType useOpenGL () const
 

Static Public Member Functions

static int getTextureType ()
 
static int getInternalTextureType ()
 
static void setInternalTextureType (const int n)
 
static void setBlur (const bool n)
 
static int getTextureSize ()
 
static void initTextureSampler (const GLint id)
 
static void setUseTextureSampler (const bool b)
 
static void invalidate (const GLuint textureId)
 
static void bindTexture (const GLuint texture)
 
- Static Public Member Functions inherited from ImageHelper
static SDL_Surface * convertTo32Bit (SDL_Surface *const tmpImage)
 
static void dumpSurfaceFormat (const SDL_Surface *const image)
 
static void setEnableAlpha (const bool n)
 
static SDL_Surface * loadPng (SDL_RWops *const rw)
 
static void setOpenGlMode (const RenderType useOpenGL)
 

Static Public Attributes

static int mTextureType = 0
 
static int mInternalTextureType = 0x8058
 

Protected Member Functions

ImageglLoad (SDL_Surface *tmpImage, int width=0, int height=0)
 
GLuint getNewTexture ()
 
- Protected Member Functions inherited from ImageHelper
 ImageHelper ()
 

Static Protected Member Functions

static int powerOfTwo (const int input)
 
static SDL_Surface * convertSurfaceNormalize (SDL_Surface *tmpImage, int width, int height)
 
static SDL_Surface * convertSurface (SDL_Surface *tmpImage, int width, int height)
 

Protected Attributes

size_t mFreeTextureIndex
 
GLuint mTextures [texturesSize]
 

Static Protected Attributes

static const size_t texturesSize = 10
 
static int mTextureSize = 0
 
static bool mBlur = true
 
static bool mUseTextureSampler = false
 
- Static Protected Attributes inherited from ImageHelper
static bool mEnableAlpha = true
 
static RenderType mUseOpenGL = RENDER_SOFTWARE
 

Friends

class CompoundSprite
 
class Graphics
 
class Image
 

Detailed Description

Defines a class for loading and storing images.

Definition at line 70 of file openglimagehelper.h.

Constructor & Destructor Documentation

◆ OpenGLImageHelper()

OpenGLImageHelper::OpenGLImageHelper ( )
inline

Definition at line 77 of file openglimagehelper.h.

77  :
79  mTextures()
80  {
81  }
GLuint mTextures[texturesSize]

◆ ~OpenGLImageHelper()

OpenGLImageHelper::~OpenGLImageHelper ( )

Definition at line 62 of file openglimagehelper.cpp.

63 {
64  glDeleteTextures(static_cast<GLsizei>(texturesSize - mFreeTextureIndex),
66 }
static const size_t texturesSize

References mFreeTextureIndex, mTextures, and texturesSize.

Member Function Documentation

◆ bindTexture()

void OpenGLImageHelper::bindTexture ( const GLuint  texture)
static

Definition at line 254 of file openglimagehelper.cpp.

255 {
256  switch (mUseOpenGL)
257  {
258 #ifdef ANDROID
260  case RENDER_SAFE_OPENGL:
262  case RENDER_GLES2_OPENGL:
263  break;
264  case RENDER_GLES_OPENGL:
266  break;
267 #elif defined(__native_client__) || defined(__SWITCH__)
270  case RENDER_GLES_OPENGL:
271  break;
272  case RENDER_SAFE_OPENGL:
273 #ifndef __SWITCH__
275 #endif
276  break;
277  case RENDER_GLES2_OPENGL:
279  break;
280 #else // ANDROID
281 
284  break;
287  break;
288  case RENDER_SAFE_OPENGL:
290  break;
291  case RENDER_GLES_OPENGL:
293  break;
294  case RENDER_GLES2_OPENGL:
296  break;
297 #endif // ANDROID
298 
299  case RENDER_SOFTWARE:
300  case RENDER_SDL2_DEFAULT:
301  case RENDER_NULL:
302  case RENDER_LAST:
303  default:
304  reportAlways("Unknown OpenGL backend: %d", mUseOpenGL)
305  break;
306  }
307 }
#define reportAlways(...)
Definition: checkutils.h:253
static RenderType mUseOpenGL
Definition: imagehelper.h:118
static void bindTexture(const GLenum target, const GLuint texture)
@ RENDER_SAFE_OPENGL
Definition: rendertype.h:29
@ RENDER_GLES2_OPENGL
Definition: rendertype.h:33
@ RENDER_GLES_OPENGL
Definition: rendertype.h:30
@ RENDER_MODERN_OPENGL
Definition: rendertype.h:32
@ RENDER_LAST
Definition: rendertype.h:35
@ RENDER_NORMAL_OPENGL
Definition: rendertype.h:28
@ RENDER_SDL2_DEFAULT
Definition: rendertype.h:31
@ RENDER_NULL
Definition: rendertype.h:34
@ RENDER_SOFTWARE
Definition: rendertype.h:27

References bindTexture(), mTextureType, ImageHelper::mUseOpenGL, RENDER_GLES2_OPENGL, RENDER_GLES_OPENGL, RENDER_LAST, RENDER_MODERN_OPENGL, RENDER_NORMAL_OPENGL, RENDER_NULL, RENDER_SAFE_OPENGL, RENDER_SDL2_DEFAULT, RENDER_SOFTWARE, and reportAlways.

Referenced by emuglTextureSubImage2DEXT(), and glLoad().

◆ convertSurface()

SDL_Surface * OpenGLImageHelper::convertSurface ( SDL_Surface *  tmpImage,
int  width,
int  height 
)
staticprotected

< Surface is in system memory

Definition at line 202 of file openglimagehelper.cpp.

204 {
205  if (tmpImage == nullptr)
206  return nullptr;
207 
208 #ifdef USE_SDL2
209  SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
210 #else // USE_SDL2
211 
212  // Make sure the alpha channel is not used, but copied to destination
213  SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
214 #endif // USE_SDL2
215 
216  // Determine 32-bit masks based on byte order
217  uint32_t rmask, gmask, bmask, amask;
218 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
219  rmask = 0xff000000U;
220  gmask = 0x00ff0000U;
221  bmask = 0x0000ff00U;
222  amask = 0x000000ffU;
223 #else // SDL_BYTEORDER == SDL_BIG_ENDIAN
224 
225  rmask = 0x000000ffU;
226  gmask = 0x0000ff00U;
227  bmask = 0x00ff0000U;
228  amask = 0xff000000U;
229 #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
230 
231  if (tmpImage->format->BitsPerPixel != 32
232  || rmask != tmpImage->format->Rmask
233  || gmask != tmpImage->format->Gmask
234  || amask != tmpImage->format->Amask)
235  {
236  SDL_Surface *oldImage = tmpImage;
237 #ifdef USE_SDL2
238  SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
239 #endif // USE_SDL2
240 
241  tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
242  32, rmask, gmask, bmask, amask);
243 
244  if (tmpImage == nullptr)
245  {
246  reportAlways("Error, image convert failed: out of memory")
247  return nullptr;
248  }
249  SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
250  }
251  return tmpImage;
252 }
#define MSDL_CreateRGBSurface(flags, w, h, d, r, g, b, a)
Definition: debug.h:55

References MSDL_CreateRGBSurface, and reportAlways.

Referenced by copySurfaceToImage().

◆ convertSurfaceNormalize()

SDL_Surface * OpenGLImageHelper::convertSurfaceNormalize ( SDL_Surface *  tmpImage,
int  width,
int  height 
)
staticprotected

< Surface is in system memory

Definition at line 140 of file openglimagehelper.cpp.

142 {
143  if (tmpImage == nullptr)
144  return nullptr;
145 
146  int realWidth = powerOfTwo(width);
147  int realHeight = powerOfTwo(height);
148 
149  if (realWidth < width || realHeight < height)
150  {
151  reportAlways("Warning: image too large, cropping to %dx%d texture!",
152  tmpImage->w, tmpImage->h)
153  }
154 
155 #ifdef USE_SDL2
156  SDL_SetSurfaceAlphaMod(tmpImage, SDL_ALPHA_OPAQUE);
157 #else // USE_SDL2
158 
159  // Make sure the alpha channel is not used, but copied to destination
160  SDL_SetAlpha(tmpImage, 0, SDL_ALPHA_OPAQUE);
161 #endif // USE_SDL2
162 
163  // Determine 32-bit masks based on byte order
164  uint32_t rmask, gmask, bmask, amask;
165 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
166  rmask = 0xff000000U;
167  gmask = 0x00ff0000U;
168  bmask = 0x0000ff00U;
169  amask = 0x000000ffU;
170 #else // SDL_BYTEORDER == SDL_BIG_ENDIAN
171 
172  rmask = 0x000000ffU;
173  gmask = 0x0000ff00U;
174  bmask = 0x00ff0000U;
175  amask = 0xff000000U;
176 #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
177 
178  if (tmpImage->format->BitsPerPixel != 32
179  || realWidth != width || realHeight != height
180  || rmask != tmpImage->format->Rmask
181  || gmask != tmpImage->format->Gmask
182  || amask != tmpImage->format->Amask)
183  {
184  SDL_Surface *oldImage = tmpImage;
185 #ifdef USE_SDL2
186  SDL_SetSurfaceBlendMode(oldImage, SDL_BLENDMODE_NONE);
187 #endif // USE_SDL2
188 
189  tmpImage = MSDL_CreateRGBSurface(SDL_SWSURFACE, realWidth, realHeight,
190  32, rmask, gmask, bmask, amask);
191 
192  if (tmpImage == nullptr)
193  {
194  reportAlways("Error, image convert failed: out of memory")
195  return nullptr;
196  }
197  SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
198  }
199  return tmpImage;
200 }
static int powerOfTwo(const int input)

References MSDL_CreateRGBSurface, powerOfTwo(), and reportAlways.

Referenced by glLoad().

◆ copySurfaceToImage()

void OpenGLImageHelper::copySurfaceToImage ( const Image *const  image,
const int  x,
const int  y,
SDL_Surface *  surface 
) const
virtual

Reimplemented from ImageHelper.

Definition at line 495 of file openglimagehelper.cpp.

498 {
499  if (surface == nullptr || image == nullptr)
500  return;
501 
502  SDL_Surface *const oldSurface = surface;
503  surface = convertSurface(surface, surface->w, surface->h);
504  if (surface == nullptr)
505  return;
506 
507  // +++ probably need combine
508  // mglTextureSubImage2D and mglTextureSubImage2DEXT
509  if (mglTextureSubImage2D != nullptr)
510  {
511  mglTextureSubImage2D(image->mGLImage,
512  0,
513  x, y,
514  surface->w, surface->h,
515  GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
516  }
517  else
518  {
519  mglTextureSubImage2DEXT(image->mGLImage,
520  mTextureType, 0,
521  x, y,
522  surface->w, surface->h,
523  GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
524  }
525 #ifdef OPENGLERRORS
527 #endif // OPENGLERRORS
528 
529  if (surface != oldSurface)
530  MSDL_FreeSurface(surface);
531 }
static void logError()
static SDL_Surface * convertSurface(SDL_Surface *tmpImage, int width, int height)
#define MSDL_FreeSurface(surface)
Definition: debug.h:54
GraphicsManager graphicsManager

References convertSurface(), graphicsManager, GraphicsManager::logError(), MSDL_FreeSurface, mTextureType, x, and y.

◆ create32BitSurface()

SDL_Surface * OpenGLImageHelper::create32BitSurface ( int  width,
int  height 
) const
virtual

< Surface is in system memory

Reimplemented from ImageHelper.

Definition at line 446 of file openglimagehelper.cpp.

448 {
449 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
450  const uint32_t rmask = 0xff000000U;
451  const uint32_t gmask = 0x00ff0000U;
452  const uint32_t bmask = 0x0000ff00U;
453  const uint32_t amask = 0x000000ffU;
454 #else // SDL_BYTEORDER == SDL_BIG_ENDIAN
455 
456  const uint32_t rmask = 0x000000ffU;
457  const uint32_t gmask = 0x0000ff00U;
458  const uint32_t bmask = 0x00ff0000U;
459  const uint32_t amask = 0xff000000U;
460 #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
461 
462  width = powerOfTwo(width);
463  height = powerOfTwo(height);
464 
465  return MSDL_CreateRGBSurface(SDL_SWSURFACE,
466  width, height, 32, rmask, gmask, bmask, amask);
467 }

References MSDL_CreateRGBSurface, and powerOfTwo().

◆ createTextSurface()

Image * OpenGLImageHelper::createTextSurface ( SDL_Surface *const  tmpImage,
const int  width,
const int  height,
const float  alpha 
)

Definition at line 119 of file openglimagehelper.cpp.

122 {
123  if (tmpImage == nullptr)
124  return nullptr;
125 
126  Image *const img = glLoad(tmpImage, width, height);
127  if (img != nullptr)
128  img->setAlpha(alpha);
129  return img;
130 }
Image * glLoad(SDL_Surface *tmpImage, int width=0, int height=0)

References glLoad().

◆ getInternalTextureType()

static int OpenGLImageHelper::getInternalTextureType ( )
inlinestatic

Definition at line 115 of file openglimagehelper.h.

116  { return mInternalTextureType; }
static int mInternalTextureType

References mInternalTextureType.

Referenced by Graphics::setOpenGLMode().

◆ getNewTexture()

GLuint OpenGLImageHelper::getNewTexture ( )
protected

Definition at line 469 of file openglimagehelper.cpp.

470 {
471  GLuint texture = mTextures[mFreeTextureIndex];
474  {
475  mFreeTextureIndex = 0;
476  postInit();
477  }
478  return texture;
479 }

References mFreeTextureIndex, mTextures, postInit(), and texturesSize.

Referenced by glLoad().

◆ getTextureSize()

static int OpenGLImageHelper::getTextureSize ( )
inlinestatic

Definition at line 128 of file openglimagehelper.h.

129  { return mTextureSize; }

References mTextureSize.

Referenced by AtlasManager::loadTextureAtlas(), and TestLauncher::testTextures().

◆ getTextureType()

static int OpenGLImageHelper::getTextureType ( )
inlinestatic

Definition at line 112 of file openglimagehelper.h.

113  { return mTextureType; }

References mTextureType.

◆ glLoad()

Image * OpenGLImageHelper::glLoad ( SDL_Surface *  tmpImage,
int  width = 0,
int  height = 0 
)
protected

< Surface is in video memory

< Use asynchronous blits if possible

< Surface is RLE encoded

< Surface is in video memory

< Use asynchronous blits if possible

< Surface is RLE encoded

Definition at line 309 of file openglimagehelper.cpp.

311 {
312  if (tmpImage == nullptr)
313  return nullptr;
314 
315  BLOCK_START("OpenGLImageHelper::glLoad")
316  // Flush current error flag.
317  graphicsManager.getLastError();
318 
319  if (width == 0)
320  width = tmpImage->w;
321  if (height == 0)
322  height = tmpImage->h;
323 
324  SDL_Surface *oldImage = tmpImage;
325  tmpImage = convertSurfaceNormalize(tmpImage, width, height);
326  if (tmpImage == nullptr)
327  return nullptr;
328 
329  const int realWidth = tmpImage->w;
330  const int realHeight = tmpImage->h;
331 
332  const GLuint texture = getNewTexture();
333  bindTexture(texture);
334 
335  if (SDL_MUSTLOCK(tmpImage))
336  SDL_LockSurface(tmpImage);
337 
341  {
342 #ifndef __SWITCH__
343  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
344 #endif
345 #ifdef OPENGLERRORS
347 #endif // OPENGLERRORS
348  }
349 
350  if (!mUseTextureSampler)
351  {
352  if (mBlur)
353  {
354  mglTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
355 #ifdef OPENGLERRORS
357 #endif // OPENGLERRORS
358 
359  mglTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
360 #ifdef OPENGLERRORS
362 #endif // OPENGLERRORS
363  }
364  else
365  {
366  mglTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
367 #ifdef OPENGLERRORS
369 #endif // OPENGLERRORS
370 
371  mglTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
372 #ifdef OPENGLERRORS
374 #endif // OPENGLERRORS
375  }
376  }
377 #if !defined(ANDROID) && !defined(__native_client__)
378  mglTexParameteri(mTextureType, GL_TEXTURE_MAX_LEVEL, 0);
379 #endif // !defined(ANDROID) && !defined(__native_client__)
380 
382  tmpImage->w, tmpImage->h,
383  0, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->pixels);
384 #ifdef OPENGLERRORS
386 #endif // OPENGLERRORS
387 
388 #ifdef DEBUG_OPENGL
389 /*
390  disabled for now, because debugger can't show it
391  if (isGLNotNull(mglLabelObject))
392  {
393  const char *const text = "image text";
394  mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
395  }
396 */
397 #endif // DEBUG_OPENGL
398 
399 /*
400  GLint compressed;
401  glGetTexLevelParameteriv(mTextureType, 0,
402  GL_TEXTURE_COMPRESSED_ARB, &compressed);
403  if (compressed)
404  logger->log("image compressed");
405  else
406  logger->log("image not compressed");
407 */
408 
409 #ifdef DEBUG_OPENGL_LEAKS
410  textures_count ++;
411 #endif // DEBUG_OPENGL_LEAKS
412 
413  if (SDL_MUSTLOCK(tmpImage))
414  SDL_UnlockSurface(tmpImage);
415 
416  if (oldImage != tmpImage)
417  MSDL_FreeSurface(tmpImage);
418 
420  if (error != 0U)
421  {
422  std::string errmsg = GraphicsManager::errorToString(error);
423  reportAlways("Error: Image GL import failed: %s (%u)",
424  errmsg.c_str(), error)
425 // return nullptr;
426  }
427 
428  BLOCK_END("OpenGLImageHelper::glLoad")
429  return new Image(texture, width, height, realWidth, realHeight);
430 }
static GLenum getLastError()
static std::string errorToString(const GLenum error)
static SDL_Surface * convertSurfaceNormalize(SDL_Surface *tmpImage, int width, int height)
static void bindTexture(const GLuint texture)
static bool mUseTextureSampler
#define new
Definition: debug_new.h:147
int textures_count
Definition: client.cpp:138
if(!vert) return
#define mglTexParameteri(...)
Definition: mgl.hpp:101
#define mglTexImage2D(...)
Definition: mgl.hpp:103
bool error(InputEvent &event) __attribute__((noreturn))
Definition: actions.cpp:82
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79

References bindTexture(), BLOCK_END, BLOCK_START, convertSurfaceNormalize(), Actions::error(), GraphicsManager::errorToString(), GraphicsManager::getLastError(), getNewTexture(), graphicsManager, Image, GraphicsManager::logError(), mBlur, mglTexImage2D, mglTexParameteri, mInternalTextureType, MSDL_FreeSurface, mTextureType, ImageHelper::mUseOpenGL, mUseTextureSampler, RENDER_GLES2_OPENGL, RENDER_GLES_OPENGL, RENDER_MODERN_OPENGL, reportAlways, and textures_count.

Referenced by createTextSurface(), and loadSurface().

◆ initTextureSampler()

void OpenGLImageHelper::initTextureSampler ( const GLint  id)
static

Definition at line 432 of file openglimagehelper.cpp.

433 {
434  if (mBlur)
435  {
436  mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
437  mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
438  }
439  else
440  {
441  mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
442  mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
443  }
444 }

References mBlur.

Referenced by GraphicsManager::createTextureSampler().

◆ invalidate()

void OpenGLImageHelper::invalidate ( const GLuint  textureId)
static

Definition at line 486 of file openglimagehelper.cpp.

487 {
488  if (isGLNotNull(mglInvalidateTexImage))
489  {
490  logger->log("invalidate: %u", textureId);
491  mglInvalidateTexImage(textureId, 0);
492  }
493 }
void log(const char *const log_text,...)
Definition: logger.cpp:269
Logger * logger
Definition: logger.cpp:89
#define isGLNotNull(func)
Definition: mglcheck.h:28

References isGLNotNull, Logger::log(), and logger.

◆ load()

Image * OpenGLImageHelper::load ( SDL_RWops *const  rw,
Dye const &  dye 
)
virtual

Loads an image from an SDL_RWops structure and recolors it.

Parameters
rwThe SDL_RWops to load the image from.
dyeThe dye used to recolor the image.
Returns
NULL if an error occurred, a valid pointer otherwise.

Reimplemented from ImageHelper.

Definition at line 68 of file openglimagehelper.cpp.

69 {
70  SDL_Surface *const tmpImage = loadPng(rw);
71  if (tmpImage == nullptr)
72  {
73  reportAlways("Error, image load failed: %s", SDL_GetError())
74  return nullptr;
75  }
76 
77  SDL_Surface *const surf = convertTo32Bit(tmpImage);
78  MSDL_FreeSurface(tmpImage);
79  if (surf == nullptr)
80  return nullptr;
81 
82  uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
83  const int type = dye.getType();
84 
85  switch (type)
86  {
87  case 1:
88  {
89  const DyePalette *const pal = dye.getSPalete();
90  if (pal != nullptr)
91  DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h);
92  break;
93  }
94  case 2:
95  {
96  const DyePalette *const pal = dye.getAPalete();
97  if (pal != nullptr)
98  DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h);
99  break;
100  }
101  case 0:
102  default:
103  {
104  dye.normalOGLDye(pixels, surf->w * surf->h);
105  break;
106  }
107  }
108 
109  Image *const image = loadSurface(surf);
110  MSDL_FreeSurface(surf);
111  return image;
112 }
static SDL_Surface * convertTo32Bit(SDL_Surface *const tmpImage)
static SDL_Surface * loadPng(SDL_RWops *const rw)
Image * loadSurface(SDL_Surface *const tmpImage)
#define DYEPALETTEP(palette, color)
Definition: dyepalette.h:40

References ImageHelper::convertTo32Bit(), DYEPALETTEP, Dye::getAPalete(), Dye::getSPalete(), Dye::getType(), ImageHelper::loadPng(), loadSurface(), MSDL_FreeSurface, Dye::normalOGLDye(), and reportAlways.

◆ loadSurface()

Image * OpenGLImageHelper::loadSurface ( SDL_Surface *const  tmpImage)
virtual

Loads an image from an SDL surface.

Reimplemented from ImageHelper.

Definition at line 114 of file openglimagehelper.cpp.

115 {
116  return glLoad(tmpImage);
117 }

References glLoad().

Referenced by load().

◆ postInit()

void OpenGLImageHelper::postInit ( )
virtual

Reimplemented from ImageHelper.

Definition at line 481 of file openglimagehelper.cpp.

482 {
484 }
#define mglGenTextures(...)
Definition: mgl.hpp:105

References mFreeTextureIndex, mglGenTextures, mTextures, and texturesSize.

Referenced by getNewTexture().

◆ powerOfTwo()

int OpenGLImageHelper::powerOfTwo ( const int  input)
staticprotected

Returns the first power of two equal or bigger than the input.

Definition at line 132 of file openglimagehelper.cpp.

133 {
134  int value = 1;
135  while (value < input && value < mTextureSize)
136  value <<= 1;
137  return value >= mTextureSize ? mTextureSize : value;
138 }

References mTextureSize.

Referenced by convertSurfaceNormalize(), and create32BitSurface().

◆ setBlur()

static void OpenGLImageHelper::setBlur ( const bool  n)
inlinestatic

Definition at line 121 of file openglimagehelper.h.

122  { mBlur = n; }

References mBlur.

Referenced by GraphicsManager::initGraphics().

◆ setInternalTextureType()

static void OpenGLImageHelper::setInternalTextureType ( const int  n)
inlinestatic

Definition at line 118 of file openglimagehelper.h.

119  { mInternalTextureType = n; }

References mInternalTextureType.

Referenced by GraphicsManager::updateTextureFormat().

◆ setUseTextureSampler()

static void OpenGLImageHelper::setUseTextureSampler ( const bool  b)
inlinestatic

Definition at line 133 of file openglimagehelper.h.

134  { mUseTextureSampler = b; }

References mUseTextureSampler.

Referenced by GraphicsManager::createTextureSampler().

Friends And Related Function Documentation

◆ CompoundSprite

friend class CompoundSprite
friend

Definition at line 72 of file openglimagehelper.h.

◆ Graphics

friend class Graphics
friend

Definition at line 73 of file openglimagehelper.h.

◆ Image

friend class Image
friend

Definition at line 74 of file openglimagehelper.h.

Referenced by glLoad().

Field Documentation

◆ mBlur

bool OpenGLImageHelper::mBlur = true
staticprotected

Definition at line 171 of file openglimagehelper.h.

Referenced by glLoad(), initTextureSampler(), and setBlur().

◆ mFreeTextureIndex

size_t OpenGLImageHelper::mFreeTextureIndex
protected

Definition at line 167 of file openglimagehelper.h.

Referenced by getNewTexture(), postInit(), and ~OpenGLImageHelper().

◆ mInternalTextureType

int OpenGLImageHelper::mInternalTextureType = 0x8058
static

Definition at line 126 of file openglimagehelper.h.

Referenced by getInternalTextureType(), glLoad(), and setInternalTextureType().

◆ mTextures

GLuint OpenGLImageHelper::mTextures[texturesSize]
protected

Definition at line 168 of file openglimagehelper.h.

Referenced by getNewTexture(), postInit(), and ~OpenGLImageHelper().

◆ mTextureSize

int OpenGLImageHelper::mTextureSize = 0
staticprotected

Definition at line 170 of file openglimagehelper.h.

Referenced by getTextureSize(), powerOfTwo(), and Graphics::setOpenGLMode().

◆ mTextureType

int OpenGLImageHelper::mTextureType = 0
static

◆ mUseTextureSampler

bool OpenGLImageHelper::mUseTextureSampler = false
staticprotected

Definition at line 172 of file openglimagehelper.h.

Referenced by glLoad(), and setUseTextureSampler().

◆ texturesSize

const size_t OpenGLImageHelper::texturesSize = 10
staticprotected

Definition at line 166 of file openglimagehelper.h.

Referenced by getNewTexture(), postInit(), and ~OpenGLImageHelper().


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