本文整理汇总了C++中OpenGLTexture::Dispose方法的典型用法代码示例。如果您正苦于以下问题:C++ OpenGLTexture::Dispose方法的具体用法?C++ OpenGLTexture::Dispose怎么用?C++ OpenGLTexture::Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenGLTexture
的用法示例。
在下文中一共展示了OpenGLTexture::Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadImage
Uint32 OpenGLGraphics::LoadImage ( const char *_filename, bool _isColorKeyed )
{
ARCReleaseAssert ( _filename != NULL );
// Load the image from RAM.
SDL_Surface* src = g_app->m_resource->GetImage ( _filename ); // use SDL_Image to load the image
ARCReleaseAssert ( src != NULL );
Uint32 oldWidth = 0, oldHeight = 0;
Uint32 rmask, gmask, bmask, amask;
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xff000000;
gmask = 0x00ff0000;
bmask = 0x0000ff00;
amask = 0x000000ff;
#else
rmask = 0x000000ff;
gmask = 0x0000ff00;
bmask = 0x00ff0000;
amask = 0xff000000;
#endif
Uint32 targetW = src->w, targetH = src->h;
if ( !g_openGL->GetSetting ( OPENGL_TEX_ALLOW_NPOT, false ) )
{
oldWidth = targetW, oldHeight = targetH;
if ( !isPowerOfTwo ( targetW ) )
targetW = nearestPowerOfTwo ( targetW );
if ( !isPowerOfTwo ( targetH ) )
targetH = nearestPowerOfTwo ( targetH );
ARCReleaseAssert ( isPowerOfTwo ( targetW * targetH ) );
}
if ( g_openGL->GetSetting ( OPENGL_TEX_FORCE_SQUARE, false ) )
{
targetH = targetW = std::max ( targetW, targetH );
}
OpenGLTexture *tex = new OpenGLTexture();
Uint32 ret = m_textures.insert ( tex );
tex->Dispose();
tex->Create ( targetW, targetH, _isColorKeyed );
ARCReleaseAssert ( tex->m_sdlSurface != NULL );
if ( _isColorKeyed && m_colorKeySet )
{
SDL_FillRect ( tex->m_sdlSurface, NULL, ZERO_ALPHA & m_colorKey );
SDL_SetColorKey ( tex->m_sdlSurface, SDL_SRCCOLORKEY | SDL_RLEACCEL, m_colorKey );
}
SDL_SetAlpha ( tex->m_sdlSurface, 0, SDL_ALPHA_OPAQUE );
SDL_BlitSurface ( src, NULL, tex->m_sdlSurface, NULL );
SDL_FreeSurface ( src );
tex->Damage();
return ret;
}