Sign in to follow this  

glDrawElements not using my Normals array!?!?

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

Its bizar, i thought it would use the normal array if i call glEnableClientState(GL_NORMAL_ARRAY), but no... no normals to speak of. whats the dillio? or maybe, it IS using normals and when i was drawing polys manually i was just doing them wrong. well, some1 should be able to clear this up for me, thanks in advance.

Share this post


Link to post
Share on other sites
well maybe if you show your rendering code we may be able to help you.

as long as you are specifying it correctly e.g (using an array with float values)

glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT,0,yournormalarray);

If you suspect something is wrong than check with glGetError.


Share this post


Link to post
Share on other sites
sorry, here:



glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);

glNormalPointer(GL_FLOAT,0, normalBuffer[offset]);
glVertexPointer(3, GL_FLOAT, 0, vertexBuffer[offset]);

glDrawElements(GL_TRIANGLES, numFaces * 3, GL_UNSIGNED_SHORT, &indexBuffer[0] );





EDIT:

nvm, im just crazy... when i comment out enable client state i see the true meaning of normals not being there.. so i guess hwen i was doing it manually i was calling the normals wrong :P

but actually, it looks pretty cool with normals disabled. like some kinda funky cartoon rendering technique :D

Share this post


Link to post
Share on other sites
When you set the pointer to both your normals and verts you've define them as GL_FLOAT,
glNormalPointer(GL_FLOAT,0, normalBuffer[offset]);
glVertexPointer(3, GL_FLOAT, 0, vertexBuffer[offset]);

but when you draw you are saying use GL_UNSIGNED_SHORT.
glDrawElements(GL_TRIANGLES, numFaces * 3, GL_UNSIGNED_SHORT, &indexBuffer[0] );


Maybe that's it?

Share this post


Link to post
Share on other sites
Quote:
Original post by theZapper
When you set the pointer to both your normals and verts you've define them as GL_FLOAT,
glNormalPointer(GL_FLOAT,0, normalBuffer[offset]);
glVertexPointer(3, GL_FLOAT, 0, vertexBuffer[offset]);

but when you draw you are saying use GL_UNSIGNED_SHORT.
glDrawElements(GL_TRIANGLES, numFaces * 3, GL_UNSIGNED_SHORT, &indexBuffer[0] );


Maybe that's it?


GL_UNSIGNED_SHORT refers to the indices being of type GLushort. Have nothing to do with what the vertex arrays contains.

Share this post


Link to post
Share on other sites
naw yo, actually the array of indices are in short form, but when i used GL_SHORT type in draw elements, the mesh got drawn all wacky.. so i used unsigned instead and it worked.. and i just THOUGHT normals werent working because it was drawing diffrent from how it looked when i would draw the polygons manually with a for loop. but now i think i was just doing them WRONG when i did that :P

Share this post


Link to post
Share on other sites

This topic is 4337 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.

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