Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

narfidoo

OpenGL OpenGL question

This topic is 6374 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 may be stupid. I''m new. Say I have an array of vertices and an array of indices for triangles as well as an array of normals. How would I render my object in OpenGL? I have tried glDrawElements but that doesn''t work with the normals. I''m not sure what to do. Oh and I don''t want to draw the triangles seperately, I want them to be smoothly shaded together. Thanks, GG

Share this post


Link to post
Share on other sites
Advertisement
A-B
|/|
C_D

VECTOR verts[] = { A,B,C,D }
VECTOR norms[] = { A,B,C,D }
GLuint indices[] = { 0,1,2,1,2,3 }; // A B C B C D

glVertexPointer( 3, GL_FLOAT, 0, verts);
glNormalPointer( GL_FLOAT, 0, norms);
glDrawElements( GL_TRIANGLES, 6, GL_UNSIGNED_INT, indices );

will draw the two triangles u will also need to enable the clent states for vertices and normals


http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
Oh, I found out my problem.

My array had normals for each triangle, not each vertex. Any way I can do this?
Otherwise, how can I find the normal for a vertex?

Share this post


Link to post
Share on other sites
Just use the same normal for each vertex. You can have different normals for each vertex so things can look rounded with some shading type the way I understand it (like if you have polygons connects you put the same normal for vertexes that touch and it rounds it off...I think ) Anyway just put the same normal for each vertex, I know that works.


-=Foible=-

Share this post


Link to post
Share on other sites

  • 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!