general minor cosmetics
This commit is contained in:
+105
-100
@@ -85,7 +85,7 @@ const GLenum RageSpriteVertexFormat = GL_T2F_C4F_N3F_V3F;
|
||||
/* If we support texture matrix scaling, a handle to the vertex program: */
|
||||
static GLhandleARB g_bTextureMatrixShader = 0;
|
||||
|
||||
LowLevelWindow *wind;
|
||||
static LowLevelWindow *g_pWind;
|
||||
|
||||
static void InvalidateAllGeometry();
|
||||
|
||||
@@ -232,10 +232,10 @@ struct GLPixFmtInfo_t {
|
||||
static void FixLittleEndian()
|
||||
{
|
||||
#if defined(ENDIAN_LITTLE)
|
||||
static bool Initialized = false;
|
||||
if( Initialized )
|
||||
static bool bInitialized = false;
|
||||
if( bInitialized )
|
||||
return;
|
||||
Initialized = true;
|
||||
bInitialized = true;
|
||||
|
||||
for( int i = 0; i < NUM_PixelFormat; ++i )
|
||||
{
|
||||
@@ -326,7 +326,7 @@ RageDisplay_OGL::RageDisplay_OGL()
|
||||
FixLittleEndian();
|
||||
InitStringMap();
|
||||
|
||||
wind = NULL;
|
||||
g_pWind = NULL;
|
||||
g_bTextureMatrixShader = 0;
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ void InitScalingScript()
|
||||
|
||||
CString RageDisplay_OGL::Init( VideoModeParams p, bool bAllowUnacceleratedRenderer )
|
||||
{
|
||||
wind = MakeLowLevelWindow();
|
||||
g_pWind = MakeLowLevelWindow();
|
||||
|
||||
bool bIgnore = false;
|
||||
CString sError = SetVideoMode( p, bIgnore );
|
||||
@@ -498,29 +498,29 @@ bool RageDisplay_OGL::IsSoftwareRenderer()
|
||||
|
||||
RageDisplay_OGL::~RageDisplay_OGL()
|
||||
{
|
||||
delete wind;
|
||||
delete g_pWind;
|
||||
}
|
||||
|
||||
static void CheckPalettedTextures()
|
||||
{
|
||||
CString error;
|
||||
CString sError;
|
||||
do
|
||||
{
|
||||
if( !GLExt.HasExtension("GL_EXT_paletted_texture") )
|
||||
{
|
||||
error = "GL_EXT_paletted_texture missing";
|
||||
sError = "GL_EXT_paletted_texture missing";
|
||||
break;
|
||||
}
|
||||
|
||||
if( GLExt.glColorTableEXT == NULL )
|
||||
{
|
||||
error = "glColorTableEXT missing";
|
||||
sError = "glColorTableEXT missing";
|
||||
break;
|
||||
}
|
||||
|
||||
if( GLExt.glGetColorTableParameterivEXT == NULL )
|
||||
{
|
||||
error = "glGetColorTableParameterivEXT missing";
|
||||
sError = "glGetColorTableParameterivEXT missing";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -529,14 +529,14 @@ static void CheckPalettedTextures()
|
||||
GLenum glImageFormat = g_GLPixFmtInfo[PixelFormat_PAL].format;
|
||||
GLenum glImageType = g_GLPixFmtInfo[PixelFormat_PAL].type;
|
||||
|
||||
int bits = 8;
|
||||
int iBits = 8;
|
||||
|
||||
FlushGLErrors();
|
||||
#define GL_CHECK_ERROR(f) \
|
||||
{ \
|
||||
GLenum glError = glGetError(); \
|
||||
if( glError != GL_NO_ERROR ) { \
|
||||
error = ssprintf(f " failed (%s)", GLToString(glError).c_str() ); \
|
||||
sError = ssprintf(f " failed (%s)", GLToString(glError).c_str() ); \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
@@ -547,14 +547,13 @@ static void CheckPalettedTextures()
|
||||
glImageFormat, glImageType, NULL );
|
||||
GL_CHECK_ERROR( "glTexImage2D" );
|
||||
|
||||
GLuint ifmt = 0;
|
||||
glGetTexLevelParameteriv( GL_PROXY_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INTERNAL_FORMAT), (GLint *)&ifmt );
|
||||
GLuint iFormat = 0;
|
||||
glGetTexLevelParameteriv( GL_PROXY_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INTERNAL_FORMAT), (GLint *) &iFormat );
|
||||
GL_CHECK_ERROR( "glGetTexLevelParameteriv(GL_TEXTURE_INTERNAL_FORMAT)" );
|
||||
if( ifmt != glTexFormat )
|
||||
if( iFormat != glTexFormat )
|
||||
{
|
||||
error = ssprintf( "Expected format %s, got %s instead",
|
||||
GLToString(glTexFormat).c_str(),
|
||||
GLToString(ifmt).c_str() );
|
||||
sError = ssprintf( "Expected format %s, got %s instead",
|
||||
GLToString(glTexFormat).c_str(), GLToString(iFormat).c_str() );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -563,43 +562,43 @@ static void CheckPalettedTextures()
|
||||
GLExt.glColorTableEXT(GL_PROXY_TEXTURE_2D, GL_RGBA8, 256, GL_RGBA, GL_UNSIGNED_BYTE, palette);
|
||||
GL_CHECK_ERROR( "glColorTableEXT" );
|
||||
|
||||
GLint size = 0;
|
||||
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INDEX_SIZE_EXT), &size);
|
||||
GLint iSize = 0;
|
||||
glGetTexLevelParameteriv( GL_PROXY_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INDEX_SIZE_EXT), &iSize );
|
||||
GL_CHECK_ERROR( "glGetTexLevelParameteriv(GL_TEXTURE_INDEX_SIZE_EXT)" );
|
||||
if( bits > size || size > 8 )
|
||||
if( iBits > iSize || iSize > 8 )
|
||||
{
|
||||
error = ssprintf("Expected %i-bit palette, got a %i-bit one instead", bits, int(size));
|
||||
sError = ssprintf( "Expected %i-bit palette, got a %i-bit one instead", iBits, int(iSize) );
|
||||
break;
|
||||
}
|
||||
|
||||
GLint RealWidth = 0;
|
||||
GLExt.glGetColorTableParameterivEXT(GL_PROXY_TEXTURE_2D, GL_COLOR_TABLE_WIDTH, &RealWidth);
|
||||
GLint iRealWidth = 0;
|
||||
GLExt.glGetColorTableParameterivEXT( GL_PROXY_TEXTURE_2D, GL_COLOR_TABLE_WIDTH, &iRealWidth );
|
||||
GL_CHECK_ERROR( "glGetColorTableParameterivEXT(GL_COLOR_TABLE_WIDTH)" );
|
||||
if( RealWidth != 1 << bits )
|
||||
if( iRealWidth != 1 << iBits )
|
||||
{
|
||||
error = ssprintf("GL_COLOR_TABLE_WIDTH returned %i instead of %i", int(RealWidth), 1 << bits );
|
||||
sError = ssprintf( "GL_COLOR_TABLE_WIDTH returned %i instead of %i", int(iRealWidth), 1 << iBits );
|
||||
break;
|
||||
}
|
||||
|
||||
GLint RealFormat = 0;
|
||||
GLExt.glGetColorTableParameterivEXT(GL_PROXY_TEXTURE_2D, GL_COLOR_TABLE_FORMAT, &RealFormat);
|
||||
GLint iRealFormat = 0;
|
||||
GLExt.glGetColorTableParameterivEXT( GL_PROXY_TEXTURE_2D, GL_COLOR_TABLE_FORMAT, &iRealFormat );
|
||||
GL_CHECK_ERROR( "glGetColorTableParameterivEXT(GL_COLOR_TABLE_FORMAT)" );
|
||||
if( RealFormat != GL_RGBA8 )
|
||||
if( iRealFormat != GL_RGBA8 )
|
||||
{
|
||||
error = ssprintf("GL_COLOR_TABLE_FORMAT returned %s instead of GL_RGBA8", GLToString(RealFormat).c_str() );
|
||||
sError = ssprintf( "GL_COLOR_TABLE_FORMAT returned %s instead of GL_RGBA8", GLToString(iRealFormat).c_str() );
|
||||
break;
|
||||
}
|
||||
} while(0);
|
||||
#undef GL_CHECK_ERROR
|
||||
|
||||
if( error == "" )
|
||||
if( sError == "" )
|
||||
return;
|
||||
|
||||
/* If 8-bit palettes don't work, disable them entirely--don't trust 4-bit
|
||||
* palettes if it can't even get 8-bit ones right. */
|
||||
GLExt.glColorTableEXT = NULL;
|
||||
GLExt.glGetColorTableParameterivEXT = NULL;
|
||||
LOG->Info("Paletted textures disabled: %s.", error.c_str());
|
||||
LOG->Info( "Paletted textures disabled: %s.", sError.c_str() );
|
||||
}
|
||||
|
||||
static void CheckReversePackedPixels()
|
||||
@@ -613,7 +612,9 @@ static void CheckReversePackedPixels()
|
||||
|
||||
const GLenum glError = glGetError();
|
||||
if( glError == GL_NO_ERROR )
|
||||
{
|
||||
g_bReversePackedPixelsWorks = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_bReversePackedPixelsWorks = false;
|
||||
@@ -630,7 +631,7 @@ void SetupExtensions()
|
||||
const float fGLUVersion = strtof( (const char *) gluGetString(GLU_VERSION), NULL );
|
||||
g_gluVersion = int(roundf(fGLUVersion * 10));
|
||||
|
||||
GLExt.Load( wind );
|
||||
GLExt.Load( g_pWind );
|
||||
|
||||
g_iMaxTextureUnits = 1;
|
||||
if( GLExt.glActiveTextureARB != NULL )
|
||||
@@ -651,9 +652,11 @@ void SetupExtensions()
|
||||
g_bColorIndexTableWorks = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_bColorIndexTableWorks = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RageDisplay_OGL::ResolutionChanged()
|
||||
{
|
||||
@@ -671,7 +674,7 @@ CString RageDisplay_OGL::TryVideoMode( VideoModeParams p, bool &bNewDeviceOut )
|
||||
{
|
||||
// LOG->Trace( "RageDisplay_OGL::SetVideoMode( %d, %d, %d, %d, %d, %d )", windowed, width, height, bpp, rate, vsync );
|
||||
CString err;
|
||||
err = wind->TryVideoMode( p, bNewDeviceOut );
|
||||
err = g_pWind->TryVideoMode( p, bNewDeviceOut );
|
||||
if( err != "" )
|
||||
return err; // failed to set video mode
|
||||
|
||||
@@ -706,10 +709,10 @@ void RageDisplay_OGL::SetViewport(int shift_left, int shift_down)
|
||||
{
|
||||
/* left and down are on a 0..SCREEN_WIDTH, 0..SCREEN_HEIGHT scale.
|
||||
* Scale them to the actual viewport range. */
|
||||
shift_left = int( shift_left * float(wind->GetActualVideoModeParams().width) / SCREEN_WIDTH );
|
||||
shift_down = int( shift_down * float(wind->GetActualVideoModeParams().height) / SCREEN_HEIGHT );
|
||||
shift_left = int( shift_left * float(g_pWind->GetActualVideoModeParams().width) / SCREEN_WIDTH );
|
||||
shift_down = int( shift_down * float(g_pWind->GetActualVideoModeParams().height) / SCREEN_HEIGHT );
|
||||
|
||||
glViewport(shift_left, -shift_down, wind->GetActualVideoModeParams().width, wind->GetActualVideoModeParams().height);
|
||||
glViewport( shift_left, -shift_down, g_pWind->GetActualVideoModeParams().width, g_pWind->GetActualVideoModeParams().height );
|
||||
}
|
||||
|
||||
int RageDisplay_OGL::GetMaxTextureSize() const
|
||||
@@ -734,9 +737,9 @@ void RageDisplay_OGL::EndFrame()
|
||||
// Gog-knows-what.
|
||||
glFlush();
|
||||
|
||||
wind->SwapBuffers();
|
||||
g_pWind->SwapBuffers();
|
||||
|
||||
wind->Update();
|
||||
g_pWind->Update();
|
||||
|
||||
if( PREFSMAN->m_bDisableScreenSaver )
|
||||
{
|
||||
@@ -777,8 +780,8 @@ void RageDisplay_OGL::EndFrame()
|
||||
|
||||
RageSurface* RageDisplay_OGL::CreateScreenshot()
|
||||
{
|
||||
int width = wind->GetActualVideoModeParams().width;
|
||||
int height = wind->GetActualVideoModeParams().height;
|
||||
int width = g_pWind->GetActualVideoModeParams().width;
|
||||
int height = g_pWind->GetActualVideoModeParams().height;
|
||||
|
||||
const PixelFormatDesc &desc = PIXEL_FORMAT_DESC[PixelFormat_RGBA8];
|
||||
RageSurface *image = CreateSurface( width, height, desc.bpp,
|
||||
@@ -789,7 +792,7 @@ RageSurface* RageDisplay_OGL::CreateScreenshot()
|
||||
glReadBuffer( GL_FRONT );
|
||||
AssertNoGLError();
|
||||
|
||||
glReadPixels(0, 0, wind->GetActualVideoModeParams().width, wind->GetActualVideoModeParams().height, GL_RGBA,
|
||||
glReadPixels( 0, 0, g_pWind->GetActualVideoModeParams().width, g_pWind->GetActualVideoModeParams().height, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, image->pixels );
|
||||
AssertNoGLError();
|
||||
|
||||
@@ -800,7 +803,7 @@ RageSurface* RageDisplay_OGL::CreateScreenshot()
|
||||
|
||||
VideoModeParams RageDisplay_OGL::GetActualVideoModeParams() const
|
||||
{
|
||||
return wind->GetActualVideoModeParams();
|
||||
return g_pWind->GetActualVideoModeParams();
|
||||
}
|
||||
|
||||
static void SetupVertices( const RageSpriteVertex v[], int iNumVerts )
|
||||
@@ -1333,14 +1336,14 @@ void RageDisplay_OGL::DrawCompiledGeometryInternal( const RageCompiledGeometry *
|
||||
p->Draw( iMeshIndex );
|
||||
}
|
||||
|
||||
void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float LineWidth )
|
||||
void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNumVerts, float fLineWidth )
|
||||
{
|
||||
TurnOffHardwareVBO();
|
||||
|
||||
if( !GetActualVideoModeParams().bSmoothLines )
|
||||
{
|
||||
/* Fall back on the generic polygon-based line strip. */
|
||||
RageDisplay::DrawLineStripInternal(v, iNumVerts, LineWidth );
|
||||
RageDisplay::DrawLineStripInternal(v, iNumVerts, fLineWidth );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1354,20 +1357,20 @@ void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNu
|
||||
/* Our line width is wrt the regular internal SCREEN_WIDTHxSCREEN_HEIGHT screen,
|
||||
* but these width functions actually want raster sizes (that is, actual pixels).
|
||||
* Scale the line width and point size by the average ratio of the scale. */
|
||||
float WidthVal = float(wind->GetActualVideoModeParams().width) / SCREEN_WIDTH;
|
||||
float HeightVal = float(wind->GetActualVideoModeParams().height) / SCREEN_HEIGHT;
|
||||
LineWidth *= (WidthVal + HeightVal) / 2;
|
||||
float fWidthVal = float(g_pWind->GetActualVideoModeParams().width) / SCREEN_WIDTH;
|
||||
float fHeightVal = float(g_pWind->GetActualVideoModeParams().height) / SCREEN_HEIGHT;
|
||||
fLineWidth *= (fWidthVal + fHeightVal) / 2;
|
||||
|
||||
/* Clamp the width to the hardware max for both lines and points (whichever
|
||||
* is more restrictive). */
|
||||
LineWidth = clamp(LineWidth, g_line_range[0], g_line_range[1]);
|
||||
LineWidth = clamp(LineWidth, g_point_range[0], g_point_range[1]);
|
||||
fLineWidth = clamp( fLineWidth, g_line_range[0], g_line_range[1] );
|
||||
fLineWidth = clamp( fLineWidth, g_point_range[0], g_point_range[1] );
|
||||
|
||||
/* Hmm. The granularity of lines and points might be different; for example,
|
||||
* if lines are .5 and points are .25, we might want to snap the width to the
|
||||
* nearest .5, so the hardware doesn't snap them to different sizes. Does it
|
||||
* matter? */
|
||||
glLineWidth(LineWidth);
|
||||
glLineWidth( fLineWidth );
|
||||
|
||||
/* Draw the line loop: */
|
||||
SetupVertices( v, iNumVerts );
|
||||
@@ -1378,7 +1381,7 @@ void RageDisplay_OGL::DrawLineStripInternal( const RageSpriteVertex v[], int iNu
|
||||
/* Round off the corners. This isn't perfect; the point is sometimes a little
|
||||
* larger than the line, causing a small bump on the edge. Not sure how to fix
|
||||
* that. */
|
||||
glPointSize(LineWidth);
|
||||
glPointSize( fLineWidth );
|
||||
|
||||
/* Hack: if the points will all be the same, we don't want to draw
|
||||
* any points at all, since there's nothing to connect. That'll happen
|
||||
@@ -1453,6 +1456,7 @@ void RageDisplay_OGL::SetTexture( TextureUnit tu, RageTexture* pTexture )
|
||||
glDisable( GL_TEXTURE_2D );
|
||||
}
|
||||
}
|
||||
|
||||
void RageDisplay_OGL::SetTextureModeModulate()
|
||||
{
|
||||
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
|
||||
@@ -1610,6 +1614,7 @@ void RageDisplay_OGL::SetLightOff( int index )
|
||||
{
|
||||
glDisable( GL_LIGHT0+index );
|
||||
}
|
||||
|
||||
void RageDisplay_OGL::SetLightDirectional(
|
||||
int index,
|
||||
const RageColor &ambient,
|
||||
@@ -1669,7 +1674,7 @@ void RageDisplay_OGL::DeleteTexture( unsigned uTexHandle )
|
||||
}
|
||||
|
||||
|
||||
PixelFormat RageDisplay_OGL::GetImgPixelFormat( RageSurface* &img, bool &FreeImg, int width, int height, bool bPalettedTexture )
|
||||
PixelFormat RageDisplay_OGL::GetImgPixelFormat( RageSurface* &img, bool &bFreeImg, int width, int height, bool bPalettedTexture )
|
||||
{
|
||||
PixelFormat pixfmt = FindPixelFormat( img->format->BitsPerPixel, img->format->Rmask, img->format->Gmask, img->format->Bmask, img->format->Amask );
|
||||
|
||||
@@ -1697,11 +1702,11 @@ PixelFormat RageDisplay_OGL::GetImgPixelFormat( RageSurface* &img, bool &FreeImg
|
||||
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3] );
|
||||
RageSurfaceUtils::Blit( img, imgconv, width, height );
|
||||
img = imgconv;
|
||||
FreeImg = true;
|
||||
bFreeImg = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeImg = false;
|
||||
bFreeImg = false;
|
||||
}
|
||||
|
||||
return pixfmt;
|
||||
@@ -1739,16 +1744,16 @@ void SetPixelMapForSurface( int glImageFormat, int glTexFormat, const RageSurfac
|
||||
|
||||
unsigned RageDisplay_OGL::CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
RageSurface* img,
|
||||
RageSurface* pImg,
|
||||
bool bGenerateMipMaps )
|
||||
{
|
||||
ASSERT( pixfmt < NUM_PixelFormat );
|
||||
ASSERT( img->w == power_of_two(img->w) && img->h == power_of_two(img->h) );
|
||||
ASSERT( pImg->w == power_of_two(pImg->w) && pImg->h == power_of_two(pImg->h) );
|
||||
|
||||
|
||||
/* Find the pixel format of the image we've been given. */
|
||||
bool FreeImg;
|
||||
PixelFormat imgpixfmt = GetImgPixelFormat( img, FreeImg, img->w, img->h, pixfmt == PixelFormat_PAL );
|
||||
bool bFreeImg;
|
||||
PixelFormat imgpixfmt = GetImgPixelFormat( pImg, bFreeImg, pImg->w, pImg->h, pixfmt == PixelFormat_PAL );
|
||||
ASSERT( imgpixfmt != PixelFormat_INVALID );
|
||||
|
||||
GLenum glTexFormat = g_GLPixFmtInfo[pixfmt].internalfmt;
|
||||
@@ -1757,7 +1762,7 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
|
||||
/* If the image is paletted, but we're not sending it to a paletted image,
|
||||
* set up glPixelMap. */
|
||||
SetPixelMapForSurface( glImageFormat, glTexFormat, img->format->palette );
|
||||
SetPixelMapForSurface( glImageFormat, glTexFormat, pImg->format->palette );
|
||||
|
||||
// HACK: OpenGL 1.2 types aren't available in GLU 1.3. Don't call GLU for mip
|
||||
// mapping if we're using an OGL 1.2 type and don't have >= GLU 1.3.
|
||||
@@ -1787,31 +1792,31 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, uTexHandle );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
GLint minFilter;
|
||||
GLint iMinFilter;
|
||||
if( bGenerateMipMaps )
|
||||
{
|
||||
if( wind->GetActualVideoModeParams().bTrilinearFiltering )
|
||||
minFilter = GL_LINEAR_MIPMAP_LINEAR;
|
||||
if( g_pWind->GetActualVideoModeParams().bTrilinearFiltering )
|
||||
iMinFilter = GL_LINEAR_MIPMAP_LINEAR;
|
||||
else
|
||||
minFilter = GL_LINEAR_MIPMAP_NEAREST;
|
||||
iMinFilter = GL_LINEAR_MIPMAP_NEAREST;
|
||||
}
|
||||
else
|
||||
{
|
||||
minFilter = GL_LINEAR;
|
||||
iMinFilter = GL_LINEAR;
|
||||
}
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, minFilter);
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, iMinFilter );
|
||||
|
||||
if( wind->GetActualVideoModeParams().bAnisotropicFiltering &&
|
||||
if( g_pWind->GetActualVideoModeParams().bAnisotropicFiltering &&
|
||||
GLExt.HasExtension("GL_EXT_texture_filter_anisotropic") )
|
||||
{
|
||||
GLfloat largest_supported_anisotropy;
|
||||
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);
|
||||
GLfloat fLargestSupportedAnisotropy;
|
||||
glGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &fLargestSupportedAnisotropy );
|
||||
glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, fLargestSupportedAnisotropy );
|
||||
}
|
||||
|
||||
SetTextureWrapping( false );
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, img->pitch / img->format->BytesPerPixel);
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, pImg->pitch / pImg->format->BytesPerPixel );
|
||||
|
||||
|
||||
if( pixfmt == PixelFormat_PAL )
|
||||
@@ -1821,20 +1826,20 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
memset( palette, 0, sizeof(palette) );
|
||||
int p = 0;
|
||||
/* Copy the palette to the format OpenGL expects. */
|
||||
for(int i = 0; i < img->format->palette->ncolors; ++i)
|
||||
for( int i = 0; i < pImg->format->palette->ncolors; ++i )
|
||||
{
|
||||
palette[p++] = img->format->palette->colors[i].r;
|
||||
palette[p++] = img->format->palette->colors[i].g;
|
||||
palette[p++] = img->format->palette->colors[i].b;
|
||||
palette[p++] = img->format->palette->colors[i].a;
|
||||
palette[p++] = pImg->format->palette->colors[i].r;
|
||||
palette[p++] = pImg->format->palette->colors[i].g;
|
||||
palette[p++] = pImg->format->palette->colors[i].b;
|
||||
palette[p++] = pImg->format->palette->colors[i].a;
|
||||
}
|
||||
|
||||
/* Set the palette. */
|
||||
GLExt.glColorTableEXT( GL_TEXTURE_2D, GL_RGBA8, 256, GL_RGBA, GL_UNSIGNED_BYTE, palette );
|
||||
|
||||
GLint RealFormat = 0;
|
||||
GLExt.glGetColorTableParameterivEXT(GL_TEXTURE_2D, GL_COLOR_TABLE_FORMAT, &RealFormat);
|
||||
ASSERT( RealFormat == GL_RGBA8); /* This is a case I don't expect to happen. */
|
||||
GLint iRealFormat = 0;
|
||||
GLExt.glGetColorTableParameterivEXT( GL_TEXTURE_2D, GL_COLOR_TABLE_FORMAT, &iRealFormat );
|
||||
ASSERT( iRealFormat == GL_RGBA8 );
|
||||
}
|
||||
|
||||
|
||||
@@ -1844,7 +1849,7 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
|
||||
s << (bGenerateMipMaps? "gluBuild2DMipmaps":"glTexImage2D");
|
||||
s << "(format " << GLToString(glTexFormat) <<
|
||||
", " << img->w << "x" << img->h <<
|
||||
", " << pImg->w << "x" << pImg->h <<
|
||||
", format " << GLToString(glImageFormat) <<
|
||||
", type " << GLToString(glImageType) <<
|
||||
", pixfmt " << pixfmt <<
|
||||
@@ -1859,16 +1864,16 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
{
|
||||
GLenum error = gluBuild2DMipmaps(
|
||||
GL_TEXTURE_2D, glTexFormat,
|
||||
img->w, img->h,
|
||||
glImageFormat, glImageType, img->pixels );
|
||||
pImg->w, pImg->h,
|
||||
glImageFormat, glImageType, pImg->pixels );
|
||||
ASSERT_M( error == 0, (char *) gluErrorString(error) );
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0, glTexFormat,
|
||||
img->w, img->h, 0,
|
||||
glImageFormat, glImageType, img->pixels);
|
||||
pImg->w, pImg->h, 0,
|
||||
glImageFormat, glImageType, pImg->pixels);
|
||||
|
||||
GLenum error = glGetError();
|
||||
ASSERT_M( error == GL_NO_ERROR, GLToString(error) );
|
||||
@@ -1878,17 +1883,17 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
/* Sanity check: */
|
||||
if( pixfmt == PixelFormat_PAL )
|
||||
{
|
||||
GLint size = 0;
|
||||
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INDEX_SIZE_EXT), &size);
|
||||
if(size != 8)
|
||||
GLint iSize = 0;
|
||||
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GLenum(GL_TEXTURE_INDEX_SIZE_EXT), &iSize );
|
||||
if( iSize != 8 )
|
||||
RageException::Throw( "Thought paletted textures worked, but they don't." );
|
||||
}
|
||||
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
|
||||
glFlush();
|
||||
|
||||
if( FreeImg )
|
||||
delete img;
|
||||
if( bFreeImg )
|
||||
delete pImg;
|
||||
return uTexHandle;
|
||||
}
|
||||
|
||||
@@ -1896,31 +1901,31 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
* This is only used for movies anyway, which are never paletted. */
|
||||
void RageDisplay_OGL::UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
RageSurface* img,
|
||||
int xoffset, int yoffset, int width, int height )
|
||||
RageSurface* pImg,
|
||||
int iXOffset, int iYOffset, int iWidth, int iHeight )
|
||||
{
|
||||
glBindTexture( GL_TEXTURE_2D, uTexHandle );
|
||||
|
||||
bool FreeImg;
|
||||
PixelFormat pixfmt = GetImgPixelFormat( img, FreeImg, width, height, false );
|
||||
bool bFreeImg;
|
||||
PixelFormat pixfmt = GetImgPixelFormat( pImg, bFreeImg, iWidth, iHeight, false );
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, img->pitch / img->format->BytesPerPixel);
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, pImg->pitch / pImg->format->BytesPerPixel );
|
||||
|
||||
// GLenum glTexFormat = g_GLPixFmtInfo[pixfmt].internalfmt;
|
||||
GLenum glImageFormat = g_GLPixFmtInfo[pixfmt].format;
|
||||
GLenum glImageType = g_GLPixFmtInfo[pixfmt].type;
|
||||
|
||||
glTexSubImage2D( GL_TEXTURE_2D, 0,
|
||||
xoffset, yoffset,
|
||||
width, height,
|
||||
glImageFormat, glImageType, img->pixels);
|
||||
iXOffset, iYOffset,
|
||||
iWidth, iHeight,
|
||||
glImageFormat, glImageType, pImg->pixels );
|
||||
|
||||
/* Must unset PixelStore when we're done! */
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
|
||||
glFlush();
|
||||
|
||||
if( FreeImg )
|
||||
delete img;
|
||||
if( bFreeImg )
|
||||
delete pImg;
|
||||
}
|
||||
|
||||
void RageDisplay_OGL::SetPolygonMode( PolygonMode pm )
|
||||
|
||||
Reference in New Issue
Block a user