View Full Version : Invalid Vars Passed to OpenGL

11-01-2003, 07: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
glBindTexture(GL_TEXTURE_2D, faces[i]->textureID);

//set the lightmaps up
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
glTexCoordPointer(2, GL_FLOAT, sizeof(VertexBuffer), faces[i]->texcoord);
//assign lightmap pass to point
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?


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

11-02-2003, 07: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).

11-02-2003, 07: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.