Sign in to follow this  
Unreal

Strange Problem with vertex arrays

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
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

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