PDA

View Full Version : How to use multiple texcoords with VBOs?



991060
07-23-2004, 08:12 PM
Hi all:
I have a vertex format with 2 texcoords in it, my question is that how to use glTexCoordPointer() to assign parameter for them? All tutorials/demos I have seen only use 1 texcoord.

CrazyButcher
07-24-2004, 01:24 AM
if you mean 2 pairs of texcoords for use in multitexturing, you would use

glClientActiveTextureARB( GL_TEXTUREx_ARB );
glTexCoordPointer(...);

and do this for each texture unit you want to use. then depending on your needs texcoordpointer will be different for the units.

and before drawing activate
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
for each used texture units.

991060
07-24-2004, 10:58 PM
Thanks,and what if I want to use, say 4 textures, 2 of them will use the vertex's texcoord and the other 2 will use texcoord generated in the vertex program, how do I set up the proper parameters?
This is what came into my mind:

glClientActiveTextureARB( GL_TEXTURE0_ARB );
glBindTexture( GL_TEXTURE_2D, texture1);
glEnable( GL_TEXTURE_2D );
glTexCoordPointer(2, GL_FLOAT, sizeof(WaterVertex), (void*)24);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTextureARB( GL_TEXTURE1_ARB );
glBindTexture( GL_TEXTURE_2D, texture2);
glEnable( GL_TEXTURE_2D );
glTexCoordPointer(2, GL_FLOAT, sizeof(WaterVertex), (void*)32);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTextureARB( GL_TEXTURE2_ARB );
glBindTexture( GL_TEXTURE_2D, texture3);
glEnable( GL_TEXTURE_2D );

glClientActiveTextureARB( GL_TEXTURE3_ARB );
glBindTexture( GL_TEXTURE_2D, texture4);
glEnable( GL_TEXTURE_2D );since texture 2/3 doesn't use incoming texcoord, I didn't set glTexCoordPointer and enable the accoding client state, is that right?
And when I get done with those texture, do I need to disable GL_TEXTURE_COORD_ARRAY client state?

CrazyButcher
07-25-2004, 12:23 AM
to make the binds for the textures you need to use
glActiveTextureARB(..)
ClientActive... is just for the arrays I think.
and yes that stuff (cept the Active...) looks okay

the COORD_STATE you should disable after drawing, I guess