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

#include <safeopenglimagehelper.h>

Inheritance diagram for SafeOpenGLImageHelper:
ImageHelper

Public Member Functions

 SafeOpenGLImageHelper ()
 
 ~SafeOpenGLImageHelper ()
 
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 safeopenglimagehelper.h.

Constructor & Destructor Documentation

◆ SafeOpenGLImageHelper()

SafeOpenGLImageHelper::SafeOpenGLImageHelper ( )
inline

Definition at line 77 of file safeopenglimagehelper.h.

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

◆ ~SafeOpenGLImageHelper()

SafeOpenGLImageHelper::~SafeOpenGLImageHelper ( )

Definition at line 58 of file safeopenglimagehelper.cpp.

59 {
60  glDeleteTextures(static_cast<GLsizei>(texturesSize - mFreeTextureIndex),
62 }
static const size_t texturesSize

References mFreeTextureIndex, mTextures, and texturesSize.

Member Function Documentation

◆ bindTexture()

void SafeOpenGLImageHelper::bindTexture ( const GLuint  texture)
static

Definition at line 255 of file safeopenglimagehelper.cpp.

256 {
257  switch (mUseOpenGL)
258  {
259 #ifdef __native_client__
262  case RENDER_GLES_OPENGL:
263  break;
264  case RENDER_SAFE_OPENGL:
266  break;
267  case RENDER_GLES2_OPENGL:
269  break;
270 #elif defined(ANDROID)
273  case RENDER_SAFE_OPENGL:
274  case RENDER_GLES2_OPENGL:
275  break;
276  case RENDER_GLES_OPENGL:
278  break;
279 #else // __native_client__
282  break;
285  break;
286  case RENDER_SAFE_OPENGL:
288  break;
289  case RENDER_GLES_OPENGL:
291  break;
292  case RENDER_GLES2_OPENGL:
294  break;
295 #endif // __native_client__
296  case RENDER_SOFTWARE:
297  case RENDER_SDL2_DEFAULT:
298  case RENDER_NULL:
299  case RENDER_LAST:
300  default:
301  logger->log("Unknown OpenGL backend: %d", mUseOpenGL);
302  break;
303  }
304 }
static RenderType mUseOpenGL
Definition: imagehelper.h:118
void log(const char *const log_text,...)
Definition: logger.cpp:269
Logger * logger
Definition: logger.cpp:89
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(), Logger::log(), logger, 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, and RENDER_SOFTWARE.

Referenced by glLoad().

◆ convertSurface()

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

< Surface is in system memory

Definition at line 202 of file safeopenglimagehelper.cpp.

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

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

Referenced by copySurfaceToImage().

◆ convertSurfaceNormalize()

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

< Surface is in system memory

Definition at line 138 of file safeopenglimagehelper.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  logger->log("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  logger->log("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 Logger::log(), logger, MSDL_CreateRGBSurface, and powerOfTwo().

Referenced by glLoad().

◆ copySurfaceToImage()

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

Reimplemented from ImageHelper.

Definition at line 466 of file safeopenglimagehelper.cpp.

470 {
471  if (surface == nullptr || image == nullptr)
472  return;
473 
474  SDL_Surface *const oldSurface = surface;
475  surface = convertSurface(surface, surface->w, surface->h);
476  if (surface == nullptr)
477  return;
478 
479  // +++ probably need combine
480  // mglTextureSubImage2D and mglTextureSubImage2DEXT
481  if (mglTextureSubImage2D != nullptr)
482  {
483  mglTextureSubImage2D(image->mGLImage,
484  0,
485  x, y,
486  surface->w, surface->h,
487  GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
488  }
489  else
490  {
491  mglTextureSubImage2DEXT(image->mGLImage,
492  mTextureType, 0,
493  x, y,
494  surface->w, surface->h,
495  GL_RGBA, GL_UNSIGNED_BYTE, surface->pixels);
496  }
497 
498  if (surface != oldSurface)
499  MSDL_FreeSurface(surface);
500 }
static SDL_Surface * convertSurface(SDL_Surface *tmpImage, int width, int height)
#define MSDL_FreeSurface(surface)
Definition: debug.h:54

References convertSurface(), MSDL_FreeSurface, mTextureType, x, and y.

◆ create32BitSurface()

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

< Surface is in system memory

Reimplemented from ImageHelper.

Definition at line 417 of file safeopenglimagehelper.cpp.

419 {
420 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
421  const uint32_t rmask = 0xff000000U;
422  const uint32_t gmask = 0x00ff0000U;
423  const uint32_t bmask = 0x0000ff00U;
424  const uint32_t amask = 0x000000ffU;
425 #else // SDL_BYTEORDER == SDL_BIG_ENDIAN
426 
427  const uint32_t rmask = 0x000000ffU;
428  const uint32_t gmask = 0x0000ff00U;
429  const uint32_t bmask = 0x00ff0000U;
430  const uint32_t amask = 0xff000000U;
431 #endif // SDL_BYTEORDER == SDL_BIG_ENDIAN
432 
433  width = powerOfTwo(width);
434  height = powerOfTwo(height);
435 
436  return MSDL_CreateRGBSurface(SDL_SWSURFACE,
437  width, height, 32, rmask, gmask, bmask, amask);
438 }

References MSDL_CreateRGBSurface, and powerOfTwo().

◆ createTextSurface()

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

Definition at line 116 of file safeopenglimagehelper.cpp.

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

References glLoad().

◆ getInternalTextureType()

static int SafeOpenGLImageHelper::getInternalTextureType ( )
inlinestatic

Definition at line 115 of file safeopenglimagehelper.h.

116  { return mInternalTextureType; }

References mInternalTextureType.

◆ getNewTexture()

GLuint SafeOpenGLImageHelper::getNewTexture ( )
protected

Definition at line 440 of file safeopenglimagehelper.cpp.

441 {
442  GLuint texture = mTextures[mFreeTextureIndex];
445  {
446  mFreeTextureIndex = 0;
447  postInit();
448  }
449  return texture;
450 }

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

Referenced by glLoad().

◆ getTextureSize()

static int SafeOpenGLImageHelper::getTextureSize ( )
inlinestatic

Definition at line 128 of file safeopenglimagehelper.h.

129  { return mTextureSize; }

References mTextureSize.

◆ getTextureType()

static int SafeOpenGLImageHelper::getTextureType ( )
inlinestatic

Definition at line 112 of file safeopenglimagehelper.h.

113  { return mTextureType; }

References mTextureType.

◆ glLoad()

Image * SafeOpenGLImageHelper::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 306 of file safeopenglimagehelper.cpp.

309 {
310  if (tmpImage == nullptr)
311  return nullptr;
312 
313  BLOCK_START("SafeOpenGLImageHelper::glLoad")
314  // Flush current error flag.
315  graphicsManager.getLastError();
316 
317  if (width == 0)
318  width = tmpImage->w;
319  if (height == 0)
320  height = tmpImage->h;
321 
322  SDL_Surface *oldImage = tmpImage;
323  tmpImage = convertSurfaceNormalize(tmpImage, width, height);
324  if (tmpImage == nullptr)
325  return nullptr;
326 
327  const int realWidth = tmpImage->w;
328  const int realHeight = tmpImage->h;
329 
330  const GLuint texture = getNewTexture();
331  bindTexture(texture);
332 
333  if (SDL_MUSTLOCK(tmpImage))
334  SDL_LockSurface(tmpImage);
335 
336  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
337 
339  {
340  if (mBlur)
341  {
342  glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
343  glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
344  }
345  else
346  {
347  glTexParameteri(mTextureType, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
348  glTexParameteri(mTextureType, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
349  }
350  }
351 #ifndef ANDROID
352  glTexParameteri(mTextureType, GL_TEXTURE_MAX_LEVEL, 0);
353 #endif // ANDROID
354 
355  glTexImage2D(mTextureType, 0, mInternalTextureType,
356  tmpImage->w, tmpImage->h,
357  0, GL_RGBA, GL_UNSIGNED_BYTE, tmpImage->pixels);
358 
359 #ifdef DEBUG_OPENGL
360 /*
361  disabled for now, because debugger can't show it
362  if (isGLNotNull(mglLabelObject))
363  {
364  const char *const text = "image text";
365  mglLabelObject(GL_TEXTURE, texture, strlen(text), text);
366  }
367 */
368 #endif // DEBUG_OPENGL
369 
370 /*
371  GLint compressed;
372  glGetTexLevelParameteriv(mTextureType, 0,
373  GL_TEXTURE_COMPRESSED_ARB, &compressed);
374  if (compressed)
375  logger->log("image compressed");
376  else
377  logger->log("image not compressed");
378 */
379 
380 #ifdef DEBUG_OPENGL_LEAKS
381  textures_count ++;
382 #endif // DEBUG_OPENGL_LEAKS
383 
384  if (SDL_MUSTLOCK(tmpImage))
385  SDL_UnlockSurface(tmpImage);
386 
387  if (oldImage != tmpImage)
388  MSDL_FreeSurface(tmpImage);
389 
391  if (error != 0U)
392  {
393  std::string errmsg = GraphicsManager::errorToString(error);
394  logger->log("Error: Image GL import failed: %s (%u)",
395  errmsg.c_str(), error);
396 // return nullptr;
397  }
398 
399  BLOCK_END("SafeOpenGLImageHelper::glLoad")
400  return new Image(texture, width, height, realWidth, realHeight);
401 }
static GLenum getLastError()
static std::string errorToString(const GLenum error)
static void bindTexture(const GLuint texture)
static SDL_Surface * convertSurfaceNormalize(SDL_Surface *tmpImage, int width, int height)
#define new
Definition: debug_new.h:147
int textures_count
Definition: client.cpp:138
if(!vert) return
GraphicsManager graphicsManager
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, Logger::log(), logger, mBlur, mInternalTextureType, MSDL_FreeSurface, mTextureType, mUseTextureSampler, and textures_count.

Referenced by createTextSurface(), and loadSurface().

◆ initTextureSampler()

void SafeOpenGLImageHelper::initTextureSampler ( const GLint  id)
static

Definition at line 403 of file safeopenglimagehelper.cpp.

404 {
405  if (mBlur)
406  {
407  mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
408  mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
409  }
410  else
411  {
412  mglSamplerParameteri(id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
413  mglSamplerParameteri(id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
414  }
415 }

References mBlur.

◆ invalidate()

void SafeOpenGLImageHelper::invalidate ( const GLuint  textureId)
static

Definition at line 457 of file safeopenglimagehelper.cpp.

458 {
459  if (isGLNotNull(mglInvalidateTexImage))
460  {
461  logger->log("invalidate: %u", textureId);
462  mglInvalidateTexImage(textureId, 0);
463  }
464 }
#define isGLNotNull(func)
Definition: mglcheck.h:28

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

◆ load()

Image * SafeOpenGLImageHelper::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 64 of file safeopenglimagehelper.cpp.

66 {
67  SDL_Surface *const tmpImage = loadPng(rw);
68  if (tmpImage == nullptr)
69  {
70  logger->log("Error, image load failed: %s", SDL_GetError());
71  return nullptr;
72  }
73 
74  SDL_Surface *const surf = convertTo32Bit(tmpImage);
75  MSDL_FreeSurface(tmpImage);
76  if (surf == nullptr)
77  return nullptr;
78 
79  uint32_t *pixels = static_cast<uint32_t *>(surf->pixels);
80  const int type = dye.getType();
81 
82  switch (type)
83  {
84  case 1:
85  {
86  const DyePalette *const pal = dye.getSPalete();
87  if (pal != nullptr)
88  DYEPALETTEP(pal, SOGLColor)(pixels, surf->w * surf->h);
89  break;
90  }
91  case 2:
92  {
93  const DyePalette *const pal = dye.getAPalete();
94  if (pal != nullptr)
95  DYEPALETTEP(pal, AOGLColor)(pixels, surf->w * surf->h);
96  break;
97  }
98  case 0:
99  default:
100  {
101  dye.normalOGLDye(pixels, surf->w * surf->h);
102  break;
103  }
104  }
105 
106  Image *const image = loadSurface(surf);
107  MSDL_FreeSurface(surf);
108  return image;
109 }
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(), Logger::log(), logger, MSDL_FreeSurface, and Dye::normalOGLDye().

◆ loadSurface()

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

Loads an image from an SDL surface.

Reimplemented from ImageHelper.

Definition at line 111 of file safeopenglimagehelper.cpp.

112 {
113  return glLoad(tmpImage);
114 }

References glLoad().

Referenced by load().

◆ postInit()

void SafeOpenGLImageHelper::postInit ( )
virtual

Reimplemented from ImageHelper.

Definition at line 452 of file safeopenglimagehelper.cpp.

453 {
454  glGenTextures(texturesSize, &mTextures[mFreeTextureIndex]);
455 }

References mFreeTextureIndex, mTextures, and texturesSize.

Referenced by getNewTexture().

◆ powerOfTwo()

int SafeOpenGLImageHelper::powerOfTwo ( const int  input)
staticprotected

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

Definition at line 130 of file safeopenglimagehelper.cpp.

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

References mTextureSize.

Referenced by convertSurfaceNormalize(), and create32BitSurface().

◆ setBlur()

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

Definition at line 121 of file safeopenglimagehelper.h.

122  { mBlur = n; }

References mBlur.

Referenced by GraphicsManager::initGraphics().

◆ setInternalTextureType()

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

Definition at line 118 of file safeopenglimagehelper.h.

119  { mInternalTextureType = n; }

References mInternalTextureType.

Referenced by GraphicsManager::updateTextureFormat().

◆ setUseTextureSampler()

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

Definition at line 133 of file safeopenglimagehelper.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 safeopenglimagehelper.h.

◆ Graphics

friend class Graphics
friend

Definition at line 73 of file safeopenglimagehelper.h.

◆ Image

friend class Image
friend

Definition at line 74 of file safeopenglimagehelper.h.

Referenced by glLoad().

Field Documentation

◆ mBlur

bool SafeOpenGLImageHelper::mBlur = true
staticprotected

Definition at line 171 of file safeopenglimagehelper.h.

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

◆ mFreeTextureIndex

size_t SafeOpenGLImageHelper::mFreeTextureIndex
protected

Definition at line 167 of file safeopenglimagehelper.h.

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

◆ mInternalTextureType

int SafeOpenGLImageHelper::mInternalTextureType = 0x8058
static

Definition at line 126 of file safeopenglimagehelper.h.

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

◆ mTextures

GLuint SafeOpenGLImageHelper::mTextures[texturesSize]
protected

Definition at line 168 of file safeopenglimagehelper.h.

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

◆ mTextureSize

int SafeOpenGLImageHelper::mTextureSize = 0
staticprotected

Definition at line 170 of file safeopenglimagehelper.h.

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

◆ mTextureType

int SafeOpenGLImageHelper::mTextureType = 0
static

◆ mUseTextureSampler

bool SafeOpenGLImageHelper::mUseTextureSampler = false
staticprotected

Definition at line 172 of file safeopenglimagehelper.h.

Referenced by glLoad(), and setUseTextureSampler().

◆ texturesSize

const size_t SafeOpenGLImageHelper::texturesSize = 10
staticprotected

Definition at line 166 of file safeopenglimagehelper.h.

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


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