LWJGL Forum

Programming => OpenGL => Topic started by: paandar on June 25, 2013, 17:30:58

Title: [SOLVED] VBO in ortographic projection won't draw...
Post by: paandar on June 25, 2013, 17:30:58
VBO in ortographic projection won't draw

Hi all, I'm trying to render a quad using VBOs with two components coordinates (x,y), and it's not working,
I don't see anything on screen.
I'd really appreciate a hint about this because don't know where the problem is, here is some code:


   public static void render_Coords_Uv(int pDataId, int pIdxsId, int pNumLelements, int pTextureId) {
       int bytes_x_vert;
       int offset;
       int prev_texture_name;

       glPushAttrib(GL_CURRENT_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT);

       //glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
       glEnable(GL_BLEND);
       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

       glEnable(GL_TEXTURE_2D);

       prev_texture_name = glGetInteger(GL_TEXTURE_BINDING_2D);

       glBindTexture(GL_TEXTURE_2D, pTextureId);

           ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, pDataId);
           ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, pIdxsId);

           // Bytes per vertex.
           // (3 por x, y, z + 2 por u, v) * 4 bytes.
           bytes_x_vert = (3 + 2) * 4;

           // Offset 0: vertex x, y, and z.
           offset = 0;
           glEnableClientState(GL_VERTEX_ARRAY);
           glVertexPointer(2, GL_FLOAT, bytes_x_vert, offset);

           // Offset 12: u, v.
           offset = 3 * 4;
           glEnableClientState(GL_TEXTURE_COORD_ARRAY);
           glTexCoordPointer(2, GL_FLOAT, bytes_x_vert, offset);

           // Render.
           glDrawElements(GL_TRIANGLES, pNumLelements, GL_UNSIGNED_INT, 0);

           glDisableClientState(GL_TEXTURE_COORD_ARRAY);
           glDisableClientState(GL_VERTEX_ARRAY);

       if (pTextureId != prev_texture_name)
           glBindTexture(GL_TEXTURE_2D, prev_texture_name);

       glPopAttrib();
   }


Thanks in advance...
Title: Re: VBO in ortographic projection won't draw...
Post by: paandar on June 25, 2013, 17:40:53
Nevermind, bytes_per_vert and offsets were wrong!! It's working now  ;D