Strange Problem with vertex arrays

Started by
2 comments, last by silvermace 19 years, 4 months ago
I am getting lost... can you tell me the difference between this two codes? One is with vertex array and the other is without vertex array. http://rafb.net/paste/results/JeK0ZU11.html The shader has this parameters: fragment shader: PARAM light0color = state.light[0].diffuse; PARAM ambient = state.lightmodel.ambient; PARAM light0atten = state.light[0].attenuation; vertex shader: PARAM mvi[4] = {state.matrix.modelview.inverse}; PARAM mvit[4] = {state.matrix.modelview.invtrans}; PARAM mvp[4] = {state.matrix.mvp}; ATTRIB tangent = vertex.texcoord[1]; ATTRIB binormal = vertex.texcoord[2]; ATTRIB normal = vertex.normal; thsi is the code with the parameters only. not all the code. The problem i have is at lighting. using vertex arrays is not correct. any idea what is wrong? thanks in advance!
Advertisement
a few things...
quick note, your drawing 35 indices in the immediate mode one
and 34 in the vertex arrays one, but they are triangles, in both cases, your last triangle will be incomplete...

SetupShaders();glEnableClientState(GL_VERTEX_ARRAY);glEnableClientState(GL_NORMAL_ARRAY);glNormalPointer  (   GL_FLOAT, sizeof(tVector3), pNormalF);glVertexPointer  (3, GL_FLOAT, sizeof(tVector3), pVertPosF);glClientActiveTextureARB(GL_TEXTURE0_ARB);glEnableClientState(GL_TEXTURE_COORD_ARRAY);	glActiveTextureARB(GL_TEXTURE0_ARB);	glEnable(GL_TEXTURE_2D);	glTexCoordPointer(2, GL_FLOAT, sizeof(tVector2), pTexCoordF);	glBindTexture(GL_TEXTURE_2D, material.one_texID);glClientActiveTextureARB(GL_TEXTURE1_ARB);	glEnableClientState(GL_TEXTURE_COORD_ARRAY);	glActiveTextureARB(GL_TEXTURE1_ARB);	glTexCoordPointer(3, GL_FLOAT, sizeof(tVector3), ptangF);	glBindTexture(GL_TEXTURE_2D, material.two_texID);glClientActiveTextureARB(GL_TEXTURE2_ARB);glEnableClientState(GL_TEXTURE_COORD_ARRAY);	glActiveTextureARB(GL_TEXTURE2_ARB);	glTexCoordPointer(3, GL_FLOAT, sizeof(tVector3), pbinF);	glBindTexture(GL_TEXTURE_2D, material.three_texID);glDrawArrays(GL_TRIANGLES, 0, 33);  // how can you have 35/34 indexes when drawing TRIangles?glDisableClientState(GL_VERTEX_ARRAY);glDisableClientState(GL_NORMAL_ARRAY);// disable texcoord arraysfor(int i=0; i<3; i++) {     glClientActiveTextureARB(GL_TEXTURE0_ARB + i);     glDisableClientState(GL_TEXTURE_COORD_ARRAY);}glClientActiveTextureARB(GL_TEXTURE0_ARB);ShutDownShaders();
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
yes man. you are right. I didnt knew that i must enable 'GL_TEXTURE_COORD_ARRAY' for all the texture units i want. thank you
no prob, did you also take note of the vertex element count being invalid?

PS >> Rate me, ive been on 1129 so longs its annoying! :)
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website

This topic is closed to new replies.

Advertisement