Hello Guest

VBO Draws Cube Wrong

  • 1 Replies
  • 4443 Views
VBO Draws Cube Wrong
« on: April 01, 2012, 21:53:57 »
So I scoured the forums, and many examples, and got my VBO to render to screen, but my vertices are all screwed up.  I assume it has to do with how I set the size or the stride.  With just doing vertices, I didn't think stride mattered at all.
Here is what my cube looks like

Here's my minimal code.  I double checked the float arrays that are placed in the Floatbuffer, and the vertices seemed to load in correctly.  Any help would be appreciated, thanks :)

Code: [Select]
public static boolean render() {
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);  // Clear The Screen And The Depth Buffer
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
   
    Camera.lookThrough();
   
    //VBO
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    Util.checkGLError();
   
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, VBOVertexid);
    Util.checkGLError();
   
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textures.get(0));
   

    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, objects.get(0).vertices.size());
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
   
        Lighting.setLightPosition(GL11.GL_LIGHT1);
       
        return true;
    }

Re: VBO Draws Cube Wrong
« Reply #1 on: April 01, 2012, 22:34:05 »
Okay, I think my problem is I'm not using the faces information in my object file, thus I believe its only rendering the 8 vertices.  Quick last question, can I use the face information with OpenGL or do I have to calculate and add the triangles to the draw array when I'm loading in information from my object file?