PDA

View Full Version : Invalid Vars Passed to OpenGL



nukem
11-01-2003, 08:15 PM
I have been studying my code for over a month now and I have come to determin what is wrong with it. The problem has to be with the way I am sending my data to OpenGL but I cannt figure out whats wrong with the way im doing it.

Here is my render function




//render the faces
VertexBuffer** faces;
void CRender::Render()
{
//go threw all the faces and render them
for(int i=0;i<facecount;i++)
{
//set the texture
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, faces[i]->textureID);

//set the lightmaps up
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, faces[i]->lightmapID);

//set the vertex pointer for each face
glVertexPointer(3, GL_FLOAT, sizeof(VertexBuffer), faces[i]->vert);
//assign texture pass to point to normal texture coords
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), faces[i]->texcoord);
//assign lightmap pass to point
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), faces[i]->lightmapcoord);
//draw it
glDrawElements(GL_TRIANGLES, faces[i]->meshvertcount, GL_UNSIGNED_INT, faces[i]->indices);
}
}


Here (http://zonkbonk.virtualave.net/NuclearGraphics.zip) is my complete source incase you need to look at anything else.

Can someone please help me?

Thanks
nuke



[This message has been edited by nukem (edited 11-01-2003).]

yakuza
11-02-2003, 08:33 PM
I'm no expert, but it looks to me like you've got a few things wrong there. First of all it appears you're drawing a vertex array per face, that's got to be a bad idea.

Second, I think you've got your VertexPointer and TexCoordPointer strides wrong (parameter 3). If they are the flat (not interleaved) arrays that they appear to be, then your stride should be 0 and not sizeof(VertexBuffer).

nukem
11-02-2003, 08:57 PM
How would you suggest drawing a face(Note this is for displaying Q3ABSPs)? I tryed changing sizeof(VertexBuffer) to 0 and I got the same results. vert is of the type Vect3 and texcoord and lightmapcoord are of the type Vect2. I trying chaning it to sizeof(Vect*) but I got the same results.

Thanks
nuke