Advertisement

glNormalPointer

Started by March 13, 2003 10:08 AM
1 comment, last by gorvelius 21 years, 11 months ago
can someone show me how to setup glEnableClientState(GL_NORMAL_ARRAY); i have the vertices and indeces i dont know how to setup the normals please help with some example code along these lines thx static GLfloat g_cube_vertices[] = {-1.0f, 1.0f, 1.0f,// 1.0f, 1.0f, 1.0f, //1 1.0f, -1.0f, 1.0f, //2 -1.0f, -1.0f, 1.0f, //3 -1.0f, 1.0f, -1.0f, //4 1.0f, 1.0f, -1.0f, //5 1.0f, -1.0f, -1.0f, //6 -1.0f, -1.0f, -1.0f}; //7 static GLubyte g_cube_indices[] = {0, 1, 2, 3,//front face 4, 5, 1, 0, //top face 3, 2, 6, 7, //bottom face 5, 4, 7, 6, //back face 1, 5, 6, 2, //right face 4, 0, 3, 7}; //left face //in render scene glEnableClientState(GL_VERTEX_ARRAY); //glEnableClientState(GL_NORMAL_ARRAY);//How?? glVertexPointer(3, GL_FLOAT, 0, g_cube_vertices); //glNormalPointer(GL_FLOAT, 0 , g_cube_normals);//How?? glDrawElements(GL_QUADS, 24, GL_UNSIGNED_BYTE,cube_indices);
Normals are just vectors pointing perpendicular to the surface, or triangle.

in this case the normals would be:


  static GLfloat g_cube_normals[] = {0.0f, 0.0f, 1.0f // front face0.0f, 1.0f, 0.0f, // top face0.0f, -1.0f, 0.0f, // bottom face0.0f, 0.0f, -1.0f, // back face1.0f, 0.0f, 0.0f, // right face-1.0f, 0.0f, 0.0f}; // left faceglEnableClientState(GL_NORMAL_ARRAY);glNormalPointer(GL_FLOAT, 0, g_cube_normals);  
Advertisement
thanks i appreciate the help theres no info any where i could find

[edited by - gorvelius on March 13, 2003 8:53:41 PM]

This topic is closed to new replies.

Advertisement