impement Invalidate()
This commit is contained in:
@@ -33,12 +33,14 @@ RageBitmapTexture::RageBitmapTexture( const CString &sFilePath ) : RageTexture(
|
|||||||
{
|
{
|
||||||
// LOG->Trace( "RageBitmapTexture::RageBitmapTexture()" );
|
// LOG->Trace( "RageBitmapTexture::RageBitmapTexture()" );
|
||||||
|
|
||||||
|
m_uGLTextureID = 0;
|
||||||
Load( sFilePath );
|
Load( sFilePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
RageBitmapTexture::~RageBitmapTexture()
|
RageBitmapTexture::~RageBitmapTexture()
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, &m_uGLTextureID);
|
if(m_uGLTextureID)
|
||||||
|
glDeleteTextures(1, &m_uGLTextureID);
|
||||||
}
|
}
|
||||||
|
|
||||||
int power_of_two(int input)
|
int power_of_two(int input)
|
||||||
@@ -82,10 +84,10 @@ void RageBitmapTexture::Load( const CString &sFilePath )
|
|||||||
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight, 32,
|
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight, 32,
|
||||||
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 );
|
0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 );
|
||||||
|
|
||||||
|
if(!m_uGLTextureID)
|
||||||
|
glGenTextures(1, &m_uGLTextureID);
|
||||||
|
|
||||||
glGenTextures(1, &m_uGLTextureID);
|
DISPLAY->SetTexture(this);
|
||||||
DISPLAY->FlushQueue();
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_uGLTextureID);
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, img->pitch / img->format->BytesPerPixel);
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, img->pitch / img->format->BytesPerPixel);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
@@ -93,21 +95,19 @@ void RageBitmapTexture::Load( const CString &sFilePath )
|
|||||||
GL_UNSIGNED_BYTE, img->pixels);
|
GL_UNSIGNED_BYTE, img->pixels);
|
||||||
glFlush();
|
glFlush();
|
||||||
|
|
||||||
|
|
||||||
SDL_FreeSurface(img);
|
SDL_FreeSurface(img);
|
||||||
|
|
||||||
|
|
||||||
CreateFrameRects();
|
CreateFrameRects();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RageBitmapTexture::Reload()
|
void RageBitmapTexture::Reload()
|
||||||
{
|
{
|
||||||
glDeleteTextures(1, &m_uGLTextureID);
|
DISPLAY->SetTexture(0);
|
||||||
|
|
||||||
|
if(m_uGLTextureID) {
|
||||||
|
glDeleteTextures(1, &m_uGLTextureID);
|
||||||
|
m_uGLTextureID = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Load( m_sFilePath );
|
Load( m_sFilePath );
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int RageBitmapTexture::GetGLTextureID()
|
|
||||||
{
|
|
||||||
return m_uGLTextureID;
|
|
||||||
}
|
|
||||||
@@ -24,12 +24,14 @@ class RageBitmapTexture : public RageTexture
|
|||||||
public:
|
public:
|
||||||
RageBitmapTexture( const CString &sFilePath );
|
RageBitmapTexture( const CString &sFilePath );
|
||||||
virtual ~RageBitmapTexture();
|
virtual ~RageBitmapTexture();
|
||||||
|
/* only called by RageTextureManager::InvalidateTextures */
|
||||||
|
virtual void Invalidate() { m_uGLTextureID = 0; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Load( const CString &sFilePath );
|
virtual void Load( const CString &sFilePath );
|
||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
|
|
||||||
virtual unsigned int GetGLTextureID();
|
virtual unsigned int GetGLTextureID() { return m_uGLTextureID; }
|
||||||
|
|
||||||
unsigned int m_uGLTextureID;
|
unsigned int m_uGLTextureID;
|
||||||
CString m_sFilePath;
|
CString m_sFilePath;
|
||||||
|
|||||||
Reference in New Issue
Block a user