Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Invalid Vars Passed to OpenGL

  1. #1
    Member Regular Contributor
    Join Date
    Aug 2001
    Posts
    259

    Invalid Vars Passed to OpenGL

    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

    Code :
    //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 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).]

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2001
    Location
    Fort Collins, Colorado
    Posts
    446

    Re: Invalid Vars Passed to OpenGL

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

  3. #3
    Member Regular Contributor
    Join Date
    Aug 2001
    Posts
    259

    Re: Invalid Vars Passed to OpenGL

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •