Jump to content
  • Advertisement
Sign in to follow this  
Vexator

[SOLVED] attributes and vbo's...

This topic is 4419 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

this works fine with vertex arrays: glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glTexCoordPointer( 2, GL_FLOAT, 0, Maps ); glNormalPointer( GL_FLOAT, 0, Normals ); glVertexPointer( 3, GL_FLOAT, 0, Vertices ); int index = glGetAttribLocationARB( Shader->Handle, "tangent" ); glEnableVertexAttribArrayARB( index ); glVertexAttribPointerARB( index, 3, GL_FLOAT, false, 0, Tangents ); glDrawArrays( GL_TRIANGLES, 0, VertexCount ); however, if i enable vbo's, the geometry is totally screwed up: glGenBuffers( 1, &MapsID ); glBindBuffer( GL_ARRAY_BUFFER, MapsID ); glBufferData( GL_ARRAY_BUFFER, VertexCount*2*sizeof(float), Maps, GL_STATIC_DRAW ); delete[] Maps, Maps = 0; glGenBuffers( 1, &NormalsID ); glBindBuffer( GL_ARRAY_BUFFER, NormalsID ); glBufferData( GL_ARRAY_BUFFER, VertexCount*3*sizeof(float), Normals, GL_STATIC_DRAW ); delete[] Normals, Normals = 0; glGenBuffers( 1, &VerticesID ); glBindBuffer( GL_ARRAY_BUFFER, VerticesID ); glBufferData( GL_ARRAY_BUFFER, VertexCount*3*sizeof(float), Vertices, GL_STATIC_DRAW ); delete[] Vertices, Vertices = 0; ... glEnableClientState( GL_VERTEX_ARRAY ); glEnableClientState( GL_NORMAL_ARRAY ); glEnableClientState( GL_TEXTURE_COORD_ARRAY ); glBindBuffer( GL_ARRAY_BUFFER, MapsID ); glTexCoordPointer( 2, GL_FLOAT, 0, 0 ); glBindBuffer( GL_ARRAY_BUFFER, NormalsID ); glNormalPointer( GL_FLOAT, 0, 0 ); glBindBuffer( GL_ARRAY_BUFFER, VerticesID ); glVertexPointer( 3, GL_FLOAT, 0, 0 ); int index = glGetAttribLocationARB( Shader->Handle, "tangent" ); glEnableVertexAttribArrayARB( index ); glVertexAttribPointerARB( index, 3, GL_FLOAT, false, 0, Tangents ); glDrawArrays( GL_TRIANGLES, 0, VertexCount ); why does it work with va's, but not with vbo's? thanks in advance! [Edited by - Vexator on July 9, 2006 4:32:24 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:

int index = glGetAttribLocationARB( Shader->Handle, "tangent" );
glEnableVertexAttribArrayARB( index );
glVertexAttribPointerARB( index, 3, GL_FLOAT, false, 0, Tangents );


did you want to use VBOs on the tangent parameter? also, there might be an issue of that the space for the attribute for "Tangents" might colide with the space for the attribute of one of the built in openGL attributes (this is whay some stick with using gl_TexCoord for their attributes)

Share this post


Link to post
Share on other sites
Quote:
Original post by kRogue
also, there might be an issue of that the space for the attribute for "Tangents" might colide with the space for the attribute of one of the built in openGL attributes (this is whay some stick with using gl_TexCoord for their attributes)


No, this won't happen.
The issue is only with NV's drivers and only if you tell GLSL that you want a perticular attribute to use a perticular slot and you are using the fixed function attribute name which also maps to that slot.

On ATI hardware this isn't an issue, it'll remap things and if you are just asking GLSL where it put something you will also avoid this problem, which is what the OP is doing.

@OP
You have to unbind the VBO before issuing the command to setup the attribute pointer as right now it is using the value of 'Tangents' as an offset into the VerticesID VBO.

Share this post


Link to post
Share on other sites
Quote:
You have to unbind the VBO before issuing the command to setup the attribute pointer..


ah that did it, thank you!

Quote:
..as right now it is using the value of 'Tangents' as an offset into the VerticesID VBO.


so could i save my tangent array in a vbo as well?

Share this post


Link to post
Share on other sites
yes you can, VBOs are jut VAs which maybe be in video ram, there isn't anything special about them as such, anything which works with a VA will work with a VBO

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!