Jump to content
  • Advertisement
Sign in to follow this  
DarkMessiaH

Strange glVertexAttribPointerARB error,help is needed.

This topic is 4848 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

Hello. I've implemented VBO support in my game,and,though it haven't provided me with an expected speed boost(Mesh of 444 tris,noVbo = 550 FPS,withVbo=650 FPS),it works fine and I found it quite usefull. Now I'm trying to pass vertex attributes into vertex shader.Values are tangent,normal,binormal.But when I use glVertexAttribPointerARB funstion all my geometry gets broken into non-correct triangle set.Where can I find a really precisive description of this function(I found no samples or articles on it) and where is my error? Shader is enabled Code: glEnableVertexAttribArrayARB(0); glEnableVertexAttribArrayARB(1); glEnableVertexAttribArrayARB(2); vertex = sizeof ( SBSPVertex ); tex = ((int)&Level.Models.Surf[j].Ver[0].texcoord) - ((int)&Level.Models.Surf[j].Ver[0]); par0 = ((int)&Level.Models.Surf[j].Ver[0].tangent) - ((int)&Level.Models.Surf[j].Ver[0]); par1 = ((int)&Level.Models.Surf[j].Ver[0].binormal) - ((int)&Level.Models.Surf[j].Ver[0]); par2 = ((int)&Level.Models.Surf[j].Ver[0].normal) - ((int)&Level.Models.Surf[j].Ver[0]); //norm = ((int)&Level.Models.Surf[j].Ver[0].normal) - ((int)&Level.Models.Surf[j].Ver[0]); glPushClientAttrib ( GL_CLIENT_VERTEX_ARRAY_BIT ); glEnableClientState ( GL_VERTEX_ARRAY ); glEnableClientState ( GL_TEXTURE_COORD_ARRAY ); glEnableClientState ( GL_INDEX_ARRAY ); glBindBufferARB ( GL_ARRAY_BUFFER_ARB, Level.Models.Surf[j].vertexID ); glVertexPointer ( 3, GL_FLOAT, vertex, (void *)0 ); glVertexAttribPointerARB(2,3,GL_FLOAT,0,vertex,(void*) par2); glVertexAttribPointerARB(1,3,GL_FLOAT,0,vertex,(void*) par1); glVertexAttribPointerARB(0,3,GL_FLOAT,0,vertex,(void*) par0); glTexCoordPointer ( 2, GL_FLOAT, vertex, (void *)tex ); glBindBufferARB ( GL_ARRAY_BUFFER_ARB, 0 ); glBindBufferARB ( GL_ELEMENT_ARRAY_BUFFER_ARB, Level.Models.Surf[j].indexID ); glIndexPointer ( GL_UNSIGNED_INT, 0, 0 ); glDrawElements ( GL_TRIANGLES, 3*Level.Models.Surf[j].numPol, GL_UNSIGNED_INT, 0 ); glBindBufferARB ( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 ); glDisableVertexAttribArrayARB(2); glDisableVertexAttribArrayARB(1); glDisableVertexAttribArrayARB(0);

Share this post


Link to post
Share on other sites
Advertisement
By the way,when I use traditional glUniform and glAttrib functions,shader works fine.So the probleb is that the glVertexAttribPointerARB function does something unexpectable with vertex pointer.Has ANYONE encountered this sort of problem?

Share this post


Link to post
Share on other sites
Vertex attribute array zero aliases with the vertex array (similarly other vertex attribute arrays may alias other specific arrays, i.e. attribute array 2 may alias the normal array). Whenever you set an attribute array the contents of the corresponding possibly-aliased conventional array becomes undefined. So in your case your vertex positions are being sourced from vertex attribute array zero and your vertex array is being ignored. Simply switch your attribute arrays to 1, 2 and 3 to avoid the aliasing problem. Check the vertex program spec for which attribute arrays may alias which conventional arrays.

Enigma

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!