OpenGL: Use support for non-power-of-two-textures if available

stable-5.2
Günther Brammer 2009-05-30 21:24:14 +02:00
parent c6154b6881
commit 8c21cfbb41
1 changed files with 17 additions and 2 deletions

View File

@ -222,7 +222,15 @@ bool CSurface::CreateTextures(int MaxTextureSize)
// free previous
FreeTextures();
// get needed tex size - begin with smaller value of wdt/hgt, so there won't be too much space wasted
int iNeedSize=Min(Wdt, Hgt); int n=0; while ((1<<++n) < iNeedSize) {} iNeedSize=1<<n;
int iNeedSize=Min(Wdt, Hgt);
#ifdef USE_GL
if (!pGL || !GLEW_ARB_texture_non_power_of_two)
#endif
{
int n=0;
while ((1<<++n) < iNeedSize) {}
iNeedSize = 1<<n;
}
// adjust to available texture size
iTexSize=Min(iNeedSize, lpDDraw->MaxTexSize);
if (MaxTextureSize)
@ -246,7 +254,14 @@ bool CSurface::CreateTextures(int MaxTextureSize)
{
// last texture might be smaller
iNeedSize=Max(Wdt%iTexSize, Hgt%iTexSize);
int n=0; while ((1<<++n) < iNeedSize) {} iNeedSize=1<<n;
#ifdef USE_GL
if (!pGL || !GLEW_ARB_texture_non_power_of_two)
#endif
{
int n=0;
while ((1<<++n) < iNeedSize) {}
iNeedSize=1<<n;
}
*ppCTex = new CTexRef(iNeedSize, fIsRenderTarget);
}
if (fIsBackground && ppCTex) (*ppCTex)->FillBlack();