RageDisplay::GetTexture, mostly for debugging for now

This commit is contained in:
Glenn Maynard
2007-02-24 23:17:34 +00:00
parent dbd40a9da4
commit 4af53a0de9
3 changed files with 27 additions and 0 deletions
+1
View File
@@ -292,6 +292,7 @@ public:
virtual RString GetTextureDiagnostics( unsigned id ) const { return RString(); }
virtual RageSurface* CreateScreenshot() = 0; // allocates a surface. Caller must delete it.
virtual RageSurface *GetTexture( unsigned iTexture ) { return NULL; } // allocates a surface. Caller must delete it.
protected:
virtual void DrawQuadsInternal( const RageSpriteVertex v[], int iNumVerts ) = 0;
+24
View File
@@ -763,6 +763,30 @@ RageSurface* RageDisplay_OGL::CreateScreenshot()
return image;
}
RageSurface *RageDisplay_OGL::GetTexture( unsigned iTexture )
{
if( iTexture == 0 )
return NULL; // XXX
FlushGLErrors();
glBindTexture( GL_TEXTURE_2D, iTexture );
GLint iHeight, iWidth, iAlphaBits;
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &iHeight );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &iWidth );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &iAlphaBits );
int iFormat = iAlphaBits? PixelFormat_RGBA8:PixelFormat_RGB8;
const PixelFormatDesc &desc = PIXEL_FORMAT_DESC[iFormat];
RageSurface *pImage = CreateSurface( iWidth, iHeight, desc.bpp,
desc.masks[0], desc.masks[1], desc.masks[2], desc.masks[3] );
glGetTexImage( GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pImage->pixels );
AssertNoGLError();
return pImage;
}
VideoModeParams RageDisplay_OGL::GetActualVideoModeParams() const
{
return g_pWind->GetActualVideoModeParams();
+2
View File
@@ -40,6 +40,8 @@ public:
int xoffset, int yoffset, int width, int height
);
void DeleteTexture( unsigned iTexHandle );
RageSurface *GetTexture( unsigned iTexture );
void ClearAllTextures();
int GetNumTextureUnits();
void SetTexture( TextureUnit tu, unsigned iTexture );