diff --git a/stepmania/src/RageDisplay.h b/stepmania/src/RageDisplay.h index 746c8a2410..62c75764d5 100644 --- a/stepmania/src/RageDisplay.h +++ b/stepmania/src/RageDisplay.h @@ -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; diff --git a/stepmania/src/RageDisplay_OGL.cpp b/stepmania/src/RageDisplay_OGL.cpp index c75b8705b5..88ba5e57e0 100644 --- a/stepmania/src/RageDisplay_OGL.cpp +++ b/stepmania/src/RageDisplay_OGL.cpp @@ -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(); diff --git a/stepmania/src/RageDisplay_OGL.h b/stepmania/src/RageDisplay_OGL.h index 77837c9b18..1decbe37d4 100644 --- a/stepmania/src/RageDisplay_OGL.h +++ b/stepmania/src/RageDisplay_OGL.h @@ -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 );