Jump to content
  • Advertisement
Sign in to follow this  
Unreal

Strange Problem with vertex arrays

This topic is 4962 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

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!

Share this post


Link to post
Share on other sites
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 arrays
for(int i=0; i<3; i++) {
glClientActiveTextureARB(GL_TEXTURE0_ARB + i);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

glClientActiveTextureARB(GL_TEXTURE0_ARB);

ShutDownShaders();

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!