Only check for openGL errors in debug builds or when initializing. Calling glGet*() or any other synchronizing function is very slow (at least for Mac OS X).

This commit is contained in:
Steve Checkoway
2008-01-02 12:17:49 +00:00
parent 09a24016b5
commit 7c5853292b
+81 -79
View File
@@ -237,21 +237,24 @@ static void FixLittleEndian()
} }
static void FlushGLErrors() /* Making an OpenGL call doesn't also flush the error state; if we happen
{ * to have an error from a previous call, then the assert below will fail.
/* Making an OpenGL call doesn't also flush the error state; if we happen * Flush it. */
* to have an error from a previous call, then the assert below will fail. #define FlushGLErrors() do { } while( glGetError() != GL_NO_ERROR )
* Flush it. */
while( glGetError() != GL_NO_ERROR )
;
}
#define AssertNoGLError() \ #define AssertNoGLError() \
{ \ { \
GLenum error = glGetError(); \ GLenum error = glGetError(); \
ASSERT_M( error == GL_NO_ERROR, GLToString(error) ); \ ASSERT_M( error == GL_NO_ERROR, GLToString(error) ); \
} }
#ifdef DEBUG
#define DebugFlushGLErrors() FlushGLErrors()
#define DebugAssertNoGLError() AssertNoGLError()
#else
#define DebugFlushGLErrors()
#define DebugAssertNoGLError()
#endif
static void TurnOffHardwareVBO() static void TurnOffHardwareVBO()
{ {
if( GLExt.glBindBufferARB ) if( GLExt.glBindBufferARB )
@@ -791,14 +794,14 @@ RageSurface* RageDisplay_OGL::CreateScreenshot()
RageSurface *image = CreateSurface( width, height, desc.bpp, RageSurface *image = CreateSurface( width, height, desc.bpp,
desc.masks[0], desc.masks[1], desc.masks[2], 0 ); desc.masks[0], desc.masks[1], desc.masks[2], 0 );
FlushGLErrors(); DebugFlushGLErrors();
glReadBuffer( GL_FRONT ); glReadBuffer( GL_FRONT );
AssertNoGLError(); DebugAssertNoGLError();
glReadPixels( 0, 0, g_pWind->GetActualVideoModeParams().width, g_pWind->GetActualVideoModeParams().height, GL_RGBA, glReadPixels( 0, 0, g_pWind->GetActualVideoModeParams().width, g_pWind->GetActualVideoModeParams().height, GL_RGBA,
GL_UNSIGNED_BYTE, image->pixels ); GL_UNSIGNED_BYTE, image->pixels );
AssertNoGLError(); DebugAssertNoGLError();
RageSurfaceUtils::FlipVertically( image ); RageSurfaceUtils::FlipVertically( image );
@@ -1061,106 +1064,106 @@ RageCompiledGeometryHWOGL::RageCompiledGeometryHWOGL()
RageCompiledGeometryHWOGL::~RageCompiledGeometryHWOGL() RageCompiledGeometryHWOGL::~RageCompiledGeometryHWOGL()
{ {
FlushGLErrors(); DebugFlushGLErrors();
GLExt.glDeleteBuffersARB( 1, &m_nPositions ); GLExt.glDeleteBuffersARB( 1, &m_nPositions );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glDeleteBuffersARB( 1, &m_nTextureCoords ); GLExt.glDeleteBuffersARB( 1, &m_nTextureCoords );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glDeleteBuffersARB( 1, &m_nNormals ); GLExt.glDeleteBuffersARB( 1, &m_nNormals );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glDeleteBuffersARB( 1, &m_nTriangles ); GLExt.glDeleteBuffersARB( 1, &m_nTriangles );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glDeleteBuffersARB( 1, &m_nTextureMatrixScale ); GLExt.glDeleteBuffersARB( 1, &m_nTextureMatrixScale );
AssertNoGLError(); DebugAssertNoGLError();
} }
void RageCompiledGeometryHWOGL::AllocateBuffers() void RageCompiledGeometryHWOGL::AllocateBuffers()
{ {
FlushGLErrors(); DebugFlushGLErrors();
if( !m_nPositions ) if( !m_nPositions )
{ {
GLExt.glGenBuffersARB( 1, &m_nPositions ); GLExt.glGenBuffersARB( 1, &m_nPositions );
AssertNoGLError(); DebugAssertNoGLError();
} }
if( !m_nTextureCoords ) if( !m_nTextureCoords )
{ {
GLExt.glGenBuffersARB( 1, &m_nTextureCoords ); GLExt.glGenBuffersARB( 1, &m_nTextureCoords );
AssertNoGLError(); DebugAssertNoGLError();
} }
if( !m_nNormals ) if( !m_nNormals )
{ {
GLExt.glGenBuffersARB( 1, &m_nNormals ); GLExt.glGenBuffersARB( 1, &m_nNormals );
AssertNoGLError(); DebugAssertNoGLError();
} }
if( !m_nTriangles ) if( !m_nTriangles )
{ {
GLExt.glGenBuffersARB( 1, &m_nTriangles ); GLExt.glGenBuffersARB( 1, &m_nTriangles );
AssertNoGLError(); DebugAssertNoGLError();
} }
if( !m_nTextureMatrixScale ) if( !m_nTextureMatrixScale )
{ {
GLExt.glGenBuffersARB( 1, &m_nTextureMatrixScale ); GLExt.glGenBuffersARB( 1, &m_nTextureMatrixScale );
AssertNoGLError(); DebugAssertNoGLError();
} }
} }
void RageCompiledGeometryHWOGL::UploadData() void RageCompiledGeometryHWOGL::UploadData()
{ {
FlushGLErrors(); DebugFlushGLErrors();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
&m_vPosition[0], &m_vPosition[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
&m_vTexture[0], &m_vTexture[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
&m_vNormal[0], &m_vNormal[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ELEMENT_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB,
GetTotalTriangles()*sizeof(msTriangle), GetTotalTriangles()*sizeof(msTriangle),
&m_vTriangles[0], &m_vTriangles[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
if( m_bAnyNeedsTextureMatrixScale ) if( m_bAnyNeedsTextureMatrixScale )
{ {
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
&m_vTexMatrixScale[0], &m_vTexMatrixScale[0],
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
} }
} }
@@ -1178,47 +1181,47 @@ void RageCompiledGeometryHWOGL::Invalidate()
void RageCompiledGeometryHWOGL::Allocate( const vector<msMesh> &vMeshes ) void RageCompiledGeometryHWOGL::Allocate( const vector<msMesh> &vMeshes )
{ {
FlushGLErrors(); DebugFlushGLErrors();
RageCompiledGeometrySWOGL::Allocate( vMeshes ); RageCompiledGeometrySWOGL::Allocate( vMeshes );
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
NULL, NULL,
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
NULL, NULL,
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector3), GetTotalVertices()*sizeof(RageVector3),
NULL, NULL,
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ELEMENT_ARRAY_BUFFER_ARB, GL_ELEMENT_ARRAY_BUFFER_ARB,
GetTotalTriangles()*sizeof(msTriangle), GetTotalTriangles()*sizeof(msTriangle),
NULL, NULL,
GL_STATIC_DRAW_ARB ); GL_STATIC_DRAW_ARB );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBufferDataARB( GLExt.glBufferDataARB(
GL_ARRAY_BUFFER_ARB, GL_ARRAY_BUFFER_ARB,
GetTotalVertices()*sizeof(RageVector2), GetTotalVertices()*sizeof(RageVector2),
@@ -1235,31 +1238,32 @@ void RageCompiledGeometryHWOGL::Change( const vector<msMesh> &vMeshes )
void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
{ {
FlushGLErrors(); DebugFlushGLErrors();
const MeshInfo& meshInfo = m_vMeshInfo[iMeshIndex]; const MeshInfo& meshInfo = m_vMeshInfo[iMeshIndex];
if( !meshInfo.iVertexCount || !meshInfo.iTriangleCount ) if( !meshInfo.iVertexCount || !meshInfo.iTriangleCount )
return; return;
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nPositions );
AssertNoGLError(); DebugAssertNoGLError();
glVertexPointer(3, GL_FLOAT, 0, NULL ); glVertexPointer(3, GL_FLOAT, 0, NULL );
AssertNoGLError(); DebugAssertNoGLError();
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
AssertNoGLError(); DebugAssertNoGLError();
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureCoords );
AssertNoGLError(); DebugAssertNoGLError();
glTexCoordPointer(2, GL_FLOAT, 0, NULL); glTexCoordPointer(2, GL_FLOAT, 0, NULL);
AssertNoGLError(); DebugAssertNoGLError();
// TRICKY: Don't bind and send normals if lighting is disabled. This // TRICKY: Don't bind and send normals if lighting is disabled. This
// will save some effort transforming these values. // will save some effort transforming these values.
// XXX: We should keep track of these ourself and avoid glGet*()
GLboolean bLighting; GLboolean bLighting;
glGetBooleanv( GL_LIGHTING, &bLighting ); glGetBooleanv( GL_LIGHTING, &bLighting );
GLboolean bTextureGenS; GLboolean bTextureGenS;
@@ -1269,16 +1273,16 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
if( bLighting || bTextureGenS || bTextureGenT ) if( bLighting || bTextureGenS || bTextureGenT )
{ {
glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_NORMAL_ARRAY);
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nNormals );
AssertNoGLError(); DebugAssertNoGLError();
glNormalPointer(GL_FLOAT, 0, NULL); glNormalPointer(GL_FLOAT, 0, NULL);
AssertNoGLError(); DebugAssertNoGLError();
} }
else else
{ {
glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_NORMAL_ARRAY);
AssertNoGLError(); DebugAssertNoGLError();
} }
if( meshInfo.m_bNeedsTextureMatrixScale ) if( meshInfo.m_bNeedsTextureMatrixScale )
@@ -1289,14 +1293,14 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
* vertex shader. This shader doesn't support all OpenGL state, so only enable it * vertex shader. This shader doesn't support all OpenGL state, so only enable it
* if we're using it. */ * if we're using it. */
GLExt.glEnableVertexAttribArrayARB( g_iAttribTextureMatrixScale ); GLExt.glEnableVertexAttribArrayARB( g_iAttribTextureMatrixScale );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale ); GLExt.glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nTextureMatrixScale );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glVertexAttribPointerARB( g_iAttribTextureMatrixScale, 2, GL_FLOAT, false, 0, NULL ); GLExt.glVertexAttribPointerARB( g_iAttribTextureMatrixScale, 2, GL_FLOAT, false, 0, NULL );
AssertNoGLError(); DebugAssertNoGLError();
GLExt.glUseProgramObjectARB( g_bTextureMatrixShader ); GLExt.glUseProgramObjectARB( g_bTextureMatrixShader );
AssertNoGLError(); DebugAssertNoGLError();
} }
else else
{ {
@@ -1321,12 +1325,12 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
glMatrixMode( GL_TEXTURE ); glMatrixMode( GL_TEXTURE );
glLoadMatrixf( (const float*)mat ); glLoadMatrixf( (const float*)mat );
AssertNoGLError(); DebugAssertNoGLError();
} }
} }
GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles ); GLExt.glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nTriangles );
AssertNoGLError(); DebugAssertNoGLError();
#define BUFFER_OFFSET(o) ((char*)(o)) #define BUFFER_OFFSET(o) ((char*)(o))
@@ -1339,7 +1343,7 @@ void RageCompiledGeometryHWOGL::Draw( int iMeshIndex ) const
meshInfo.iTriangleCount*3, // number of elements to be rendered meshInfo.iTriangleCount*3, // number of elements to be rendered
GL_UNSIGNED_SHORT, GL_UNSIGNED_SHORT,
BUFFER_OFFSET(meshInfo.iTriangleStart*sizeof(msTriangle)) ); BUFFER_OFFSET(meshInfo.iTriangleStart*sizeof(msTriangle)) );
AssertNoGLError(); DebugAssertNoGLError();
if( meshInfo.m_bNeedsTextureMatrixScale && g_bTextureMatrixShader != 0 ) if( meshInfo.m_bNeedsTextureMatrixScale && g_bTextureMatrixShader != 0 )
{ {
@@ -1660,7 +1664,7 @@ void RageDisplay_OGL::SetEffectMode( EffectMode effect )
case EffectMode_YUYV422: hShader = g_hYUYV422Shader; break; case EffectMode_YUYV422: hShader = g_hYUYV422Shader; break;
} }
FlushGLErrors(); DebugFlushGLErrors();
GLExt.glUseProgramObjectARB( hShader ); GLExt.glUseProgramObjectARB( hShader );
if( hShader == 0 ) if( hShader == 0 )
return; return;
@@ -1677,7 +1681,7 @@ void RageDisplay_OGL::SetEffectMode( EffectMode effect )
GLExt.glUniform1iARB( iTextureWidthUniform, iWidth ); GLExt.glUniform1iARB( iTextureWidthUniform, iWidth );
} }
AssertNoGLError(); DebugAssertNoGLError();
} }
bool RageDisplay_OGL::IsEffectModeSupported( EffectMode effect ) bool RageDisplay_OGL::IsEffectModeSupported( EffectMode effect )
@@ -1942,9 +1946,9 @@ void RageDisplay_OGL::DeleteTexture( unsigned iTexture )
return; return;
} }
FlushGLErrors(); DebugFlushGLErrors();
glDeleteTextures( 1, reinterpret_cast<GLuint*>(&iTexture) ); glDeleteTextures( 1, reinterpret_cast<GLuint*>(&iTexture) );
AssertNoGLError(); DebugAssertNoGLError();
} }
@@ -2006,14 +2010,13 @@ void SetPixelMapForSurface( int glImageFormat, int glTexFormat, const RageSurfac
buf[3][i] = SCALE( palette->colors[i].a, 0, 255, 0, 65535 ); buf[3][i] = SCALE( palette->colors[i].a, 0, 255, 0, 65535 );
} }
FlushGLErrors(); DebugFlushGLErrors();
glPixelMapusv( GL_PIXEL_MAP_I_TO_R, 256, buf[0] ); glPixelMapusv( GL_PIXEL_MAP_I_TO_R, 256, buf[0] );
glPixelMapusv( GL_PIXEL_MAP_I_TO_G, 256, buf[1] ); glPixelMapusv( GL_PIXEL_MAP_I_TO_G, 256, buf[1] );
glPixelMapusv( GL_PIXEL_MAP_I_TO_B, 256, buf[2] ); glPixelMapusv( GL_PIXEL_MAP_I_TO_B, 256, buf[2] );
glPixelMapusv( GL_PIXEL_MAP_I_TO_A, 256, buf[3] ); glPixelMapusv( GL_PIXEL_MAP_I_TO_A, 256, buf[3] );
glPixelTransferi( GL_MAP_COLOR, true ); glPixelTransferi( GL_MAP_COLOR, true );
GLenum error = glGetError(); DebugAssertNoGLError();
ASSERT_M( error == GL_NO_ERROR, GLToString(error) );
} }
unsigned RageDisplay_OGL::CreateTexture( unsigned RageDisplay_OGL::CreateTexture(
@@ -2111,7 +2114,7 @@ unsigned RageDisplay_OGL::CreateTexture(
GLToString(glImageFormat).c_str(), GLToString(glImageFormat).c_str(),
GLToString(glImageType).c_str(), pixfmt, SurfacePixFmt ); GLToString(glImageType).c_str(), pixfmt, SurfacePixFmt );
FlushGLErrors(); DebugFlushGLErrors();
if( bGenerateMipMaps ) if( bGenerateMipMaps )
{ {
@@ -2133,8 +2136,7 @@ unsigned RageDisplay_OGL::CreateTexture(
pImg->w, pImg->h, pImg->w, pImg->h,
glImageFormat, glImageType, pImg->pixels ); glImageFormat, glImageType, pImg->pixels );
GLenum error = glGetError(); DebugAssertNoGLError();
ASSERT_M( error == GL_NO_ERROR, GLToString(error) );
} }
@@ -2217,9 +2219,9 @@ private:
if( m_iBuffer != 0 ) if( m_iBuffer != 0 )
return; return;
FlushGLErrors(); DebugFlushGLErrors();
GLExt.glGenBuffersARB( 1, &m_iBuffer ); GLExt.glGenBuffersARB( 1, &m_iBuffer );
AssertNoGLError(); DebugAssertNoGLError();
} }
GLuint m_iBuffer; GLuint m_iBuffer;
@@ -2311,7 +2313,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam &param, int
{ {
m_Param = param; m_Param = param;
FlushGLErrors(); DebugFlushGLErrors();
// Allocate OpenGL texture resource // Allocate OpenGL texture resource
glGenTextures( 1, reinterpret_cast<GLuint*>(&m_iTexHandle) ); glGenTextures( 1, reinterpret_cast<GLuint*>(&m_iTexHandle) );
@@ -2333,7 +2335,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam &param, int
glTexImage2D( GL_TEXTURE_2D, 0, internalformat, glTexImage2D( GL_TEXTURE_2D, 0, internalformat,
iTextureWidth, iTextureHeight, 0, type, GL_UNSIGNED_BYTE, NULL ); iTextureWidth, iTextureHeight, 0, type, GL_UNSIGNED_BYTE, NULL );
AssertNoGLError(); DebugAssertNoGLError();
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
@@ -2347,7 +2349,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam &param, int
/* Attach the texture to it. */ /* Attach the texture to it. */
GLExt.glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_iFrameBufferHandle ); GLExt.glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_iFrameBufferHandle );
GLExt.glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_iTexHandle, 0 ); GLExt.glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_iTexHandle, 0 );
AssertNoGLError(); DebugAssertNoGLError();
/* Attach a depth buffer, if requested. */ /* Attach a depth buffer, if requested. */
if( param.bWithDepthBuffer ) if( param.bWithDepthBuffer )