Skip to main content
gamedev.net
🔒 Locked

A glTexCoordPointer question

Started by Mulligan Jan 14, 2003 at 9:50 PM 4 replies 300+ views
Original Post
Mulligan
Mulligan
If I have a bunch of quads in a list which are all supposed to have different textures and i''m usnig glTexCoordPointer to supplu the texture coordinates. Problem is, how do I get the correct textures to bind to the different quads?
Brother Bob
Brother Bob
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.
Mulligan
Mulligan
So wait a minute, I have to render lightmaps on all of the quads. Wouldn''t that completely defeat the purpose of using glDrawArrays?
Brother Bob
Brother Bob
Not if you pack the lightmap for several triangles into a single lightmap. Otherwise, yes, sort of.
Mulligan
Mulligan
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;
}
Prefect
Prefect
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
Widelands - laid back, free software strategy

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.