problem with normal with ArrayList

Started by
-1 comments, last by evl_one 18 years, 9 months ago
Hi folk, I hope you guys can help me out of this. I try to speed up my obj viewer with vertex array list and drawelements. If i try to display the objectin( in normal mode between glbeg) and glend() it display correctly. If it try to display the same object with gldrawelements is get normals problems.All the normals are wrong, b8ut when i switch to display it in glbegin() and glend() is get the right result. what i'm doing wrong ??? thx in advance. evl_one ps : here is the code with the normal mode : glBegin(GL_TRIANGLES); for(int i = 0; i< totpoly;i++) { glColor3f(1.0f,0.5f,0.0f); for(int ii=0; ii<3;ii++) { glNormal3f(normalList[((tempy.normals[ii])*3)],normalList[((tempy.normals[ii]-1)*3)+1],normalList[((tempy.normals[ii]-1)*3)+2] ); glVertex3f(vertexlist[ ((tempy.vertex[ii]-1)*3) ] ,vertexlist[ ((tempy.vertex[ii]-1)*3)+1 ] , vertexlist[ ((tempy.vertex[ii]-1)*3)+2 ]); } } glEnd(); and i use this code to display in vertex array. glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); vector3D position = (*iObjectCounter)->getTranslate(); glTranslatef(position.x,position.y-7.0f,position.z-20.0f); vector3D vRot = (*iObjectCounter)->getRotation(); glRotatef(vRot.x,0.0f,1.0f,0); glVertexPointer(3, GL_DOUBLE, 0, vertexlist); glNormalPointer(GL_DOUBLE, 0, normalList); glColor3f(1.0f,0.5f,0.0f); glDrawElements(GL_TRIANGLES, (*iObjectCounter)->getTotalFaces()*3 , GL_UNSIGNED_SHORT,(*iObjectCounter)->getFaceList() );

This topic is closed to new replies.

Advertisement