Sign in to follow this  
glaeken

Multiple texture coordintes

Recommended Posts

glaeken    294
I'm trying to do hardware vertex morphing, and I'm stuck on how to pass texcoords to the vertex shader. I'm not using VBOs, I'm simply drawing a list of vertices with their connectivity with glDrawElements(). I've tried both:
glVertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, 0, dstMeshVerts);
glEnableVertexAttribArrayARB(0);

glVertexAttribPointerARB(1, 3, GL_FLOAT, GL_FALSE, 0, dstMeshNormals);
glEnableVertexAttribArrayARB(1);

//   and    //

glClientActiveTexture(GL_TEXTURE1);
glTexCoordPointer(3, GL_FLOAT, 0, (float*) dstMeshVerts);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glClientActiveTexture(GL_TEXTURE2);
glTexCoordPointer(3, GL_FLOAT, 0, (float*) dstMeshNormals);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);


Is there a way to do this without VBOs? I'm used to using DirectX so there's probably an obvious mistake I'm making.

Share this post


Link to post
Share on other sites
MARS_999    1627
I think you are a bit confused here, you don't need VBOs to send texture coordinates or any vertex attributes to a shader. You can even use immediate mode if you wanted to.


Make sure you bind your attribute locations for GLSL or whatever Cg needs if you are going to use generic attribute locations vs. built in ones. Look at glGetAttribLocation()



glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, Vertices);
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, 0, Normals);
glClientActiveTexture(GL_TEXTURE1);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TexCoords1);
glClientActiveTexture(GL_TEXTURE2);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, TexCoords2);

glDrawElements();

glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClientActiveTexture(GL_TEXTURE1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);



Share this post


Link to post
Share on other sites
glaeken    294
Ah, thanks. I didn't think they were related, but every example I saw was using VBOs so I was unsure.

I tried that example, but I got runtime errors for:

glClientActiveTexture(GL_TEXTURE1);

I'll give it another go in the morning.

Edit: tried it again this morning and now I'm not getting a run time error, and it works just fine.

[Edited by - glaeken on March 25, 2008 10:47:14 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this