Original Post
🔒 Locked
A glTexCoordPointer question
Advertisement
Since you can''t change a texutre inside a vertex array, you have to draw a quad, bind a new texture, and draw another quad, and bind another texture... and so on.
Not if you pack the lightmap for several triangles into a single lightmap. Otherwise, yes, sort of.
So I''ve reorganized my render function to do this:
for( int a = 0; a < Map->GetNumVerts(); a += 4 )
glDrawArrays( GL_QUADS, a, 4 );
instead of this:
glDrawArrays( GL_QUADS, 0, Map->GetNumVerts() );
It works, and I see no immediate performance hit, so is this how most people do it when they''re going for best performance?
As a side note here is the whole render function so far:
Is there anything that you see horribly wrong with it?
bool CEngine::RenderScene()
{
TRACE_ENTER_FN( CEngine::Render )
OpenGL->BeginScene();
Camera->Render();
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, Map->GetVerts() );
glColorPointer( 3, GL_FLOAT, 0, Map->GetColors() );
glTexCoordPointer( 2, GL_FLOAT, 0, Map->GetTexCoords() );
for( int a = 0; a < Map->GetNumVerts(); a += 4 )
glDrawArrays( GL_QUADS, a, 4 );
OpenGL->EndScene();
TRACE_LEAVE_FN()
return true;
}
for( int a = 0; a < Map->GetNumVerts(); a += 4 )
glDrawArrays( GL_QUADS, a, 4 );
instead of this:
glDrawArrays( GL_QUADS, 0, Map->GetNumVerts() );
It works, and I see no immediate performance hit, so is this how most people do it when they''re going for best performance?
As a side note here is the whole render function so far:
Is there anything that you see horribly wrong with it?
bool CEngine::RenderScene()
{
TRACE_ENTER_FN( CEngine::Render )
OpenGL->BeginScene();
Camera->Render();
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glVertexPointer( 3, GL_FLOAT, 0, Map->GetVerts() );
glColorPointer( 3, GL_FLOAT, 0, Map->GetColors() );
glTexCoordPointer( 2, GL_FLOAT, 0, Map->GetTexCoords() );
for( int a = 0; a < Map->GetNumVerts(); a += 4 )
glDrawArrays( GL_QUADS, a, 4 );
OpenGL->EndScene();
TRACE_LEAVE_FN()
return true;
}
That doesn''t make any sense. Calling glDrawArrays(GL_QUADS, a, 4); n times is exactly the same as calling glDrawArrays(GL_QUADS, a, 4*n); since you don''t perform any GL state changes between the calls to glDrawArrays.
Obviously, using a single call will be faster.
Apparently, you aren''t using different textures on the quads after all, you''re just using different parts of the same texture.
cu,
Prefect
Obviously, using a single call will be faster.
Apparently, you aren''t using different textures on the quads after all, you''re just using different parts of the same texture.
cu,
Prefect
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement