Sign in to follow this  
evl_one

problem with normal with ArrayList

Recommended Posts

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[i].normals[ii])*3)],normalList[((tempy[i].normals[ii]-1)*3)+1],normalList[((tempy[i].normals[ii]-1)*3)+2] ); glVertex3f(vertexlist[ ((tempy[i].vertex[ii]-1)*3) ] ,vertexlist[ ((tempy[i].vertex[ii]-1)*3)+1 ] , vertexlist[ ((tempy[i].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() );

Share this post


Link to post
Share on other sites

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