Hello Guest

[SOLVED] VBO in ortographic projection won't draw...

  • 1 Replies
  • 2225 Views
[SOLVED] VBO in ortographic projection won't draw...
« 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:

Code: [Select]
   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...
« Last Edit: June 25, 2013, 17:44:52 by paandar »

Re: VBO in ortographic projection won't draw...
« Reply #1 on: June 25, 2013, 17:40:53 »
Nevermind, bytes_per_vert and offsets were wrong!! It's working now  ;D