simplify
handle texture invalidation
This commit is contained in:
@@ -100,6 +100,9 @@ void RageMovieTexture::Update(float fDeltaTime)
|
|||||||
|
|
||||||
buffer_changed = false;
|
buffer_changed = false;
|
||||||
|
|
||||||
|
/* Just in case we were invalidated: */
|
||||||
|
CreateTexture();
|
||||||
|
|
||||||
DISPLAY->SetTexture(this);
|
DISPLAY->SetTexture(this);
|
||||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
|
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
@@ -195,6 +198,17 @@ void RageMovieTexture::Create()
|
|||||||
m_iSourceWidth = pCTR->GetVidWidth();
|
m_iSourceWidth = pCTR->GetVidWidth();
|
||||||
m_iSourceHeight = pCTR->GetVidHeight();
|
m_iSourceHeight = pCTR->GetVidHeight();
|
||||||
|
|
||||||
|
/* image size cannot exceed max size */
|
||||||
|
m_iImageWidth = min( m_iSourceWidth, m_ActualID.iMaxSize );
|
||||||
|
m_iImageHeight = min( m_iSourceHeight, m_ActualID.iMaxSize );
|
||||||
|
|
||||||
|
/* Texture dimensions need to be a power of two; jump to the next. */
|
||||||
|
m_iTextureWidth = power_of_two(m_iImageWidth);
|
||||||
|
m_iTextureHeight = power_of_two(m_iImageHeight);
|
||||||
|
|
||||||
|
if(buffer == NULL)
|
||||||
|
buffer = new char[m_iSourceWidth * m_iSourceHeight * 3];
|
||||||
|
|
||||||
/* We've set up the movie, so we know the dimensions we need. Set
|
/* We've set up the movie, so we know the dimensions we need. Set
|
||||||
* up the texture. */
|
* up the texture. */
|
||||||
CreateTexture();
|
CreateTexture();
|
||||||
@@ -211,19 +225,12 @@ void RageMovieTexture::NewData(char *data)
|
|||||||
memcpy(buffer, data, m_iSourceWidth * m_iSourceHeight * 3);
|
memcpy(buffer, data, m_iSourceWidth * m_iSourceHeight * 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageMovieTexture::CreateTexture()
|
void RageMovieTexture::CreateTexture()
|
||||||
{
|
{
|
||||||
/* image size cannot exceed max size */
|
if(m_uGLTextureID)
|
||||||
m_iImageWidth = min( m_iSourceWidth, m_ActualID.iMaxSize );
|
return;
|
||||||
m_iImageHeight = min( m_iSourceHeight, m_ActualID.iMaxSize );
|
|
||||||
|
|
||||||
/* Texture dimensions need to be a power of two; jump to the next. */
|
glGenTextures(1, &m_uGLTextureID);
|
||||||
m_iTextureWidth = power_of_two(m_iImageWidth);
|
|
||||||
m_iTextureHeight = power_of_two(m_iImageHeight);
|
|
||||||
|
|
||||||
buffer = new char[m_iSourceWidth * m_iSourceHeight * 3];
|
|
||||||
if(!m_uGLTextureID)
|
|
||||||
glGenTextures(1, &m_uGLTextureID);
|
|
||||||
|
|
||||||
DISPLAY->SetTexture(this);
|
DISPLAY->SetTexture(this);
|
||||||
|
|
||||||
@@ -231,8 +238,6 @@ bool RageMovieTexture::CreateTexture()
|
|||||||
string buf(m_iTextureWidth*m_iTextureHeight*3, 0);
|
string buf(m_iTextureWidth*m_iTextureHeight*3, 0);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,
|
||||||
m_iTextureWidth, m_iTextureHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, buf.data());
|
m_iTextureWidth, m_iTextureHeight, 0, GL_BGR, GL_UNSIGNED_BYTE, buf.data());
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RageMovieTexture::PlayMovie()
|
bool RageMovieTexture::PlayMovie()
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ class RageMovieTexture : public RageTexture
|
|||||||
public:
|
public:
|
||||||
RageMovieTexture( RageTextureID ID );
|
RageMovieTexture( RageTextureID ID );
|
||||||
virtual ~RageMovieTexture();
|
virtual ~RageMovieTexture();
|
||||||
|
/* only called by RageTextureManager::InvalidateTextures */
|
||||||
|
void Invalidate() { m_uGLTextureID = 0; }
|
||||||
void Update(float fDeltaTime);
|
void Update(float fDeltaTime);
|
||||||
|
|
||||||
virtual void Reload();
|
virtual void Reload();
|
||||||
@@ -60,15 +62,13 @@ public:
|
|||||||
void NewData(char *buffer);
|
void NewData(char *buffer);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_iIndexFrontBuffer; // index of the buffer that should be rendered from - either 0 or 1
|
|
||||||
|
|
||||||
char *buffer;
|
char *buffer;
|
||||||
bool buffer_changed;
|
bool buffer_changed;
|
||||||
RageMutex buffer_mutex;
|
RageMutex buffer_mutex;
|
||||||
|
|
||||||
void Create();
|
void Create();
|
||||||
|
|
||||||
bool CreateTexture();
|
void CreateTexture();
|
||||||
bool PlayMovie();
|
bool PlayMovie();
|
||||||
void CheckMovieStatus();
|
void CheckMovieStatus();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user