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 5 of 5

Thread: VBO following Objects are the same

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    9

    Question VBO following Objects are the same

    Hey everybody,
    I've got a VBO class where I create a vbo with texture and stuff.
    This is how it looks like
    Code :
    GLfloat vertexBuffer[8] = {
            0.0F, 0.0F,
            0.0F, height,
            width, height,
            width, 0.0F
        };
     
        GLfloat textureBuffer[8] = {
            texturePositionX, texturePositionY,
            texturePositionX, texturePositionY + textureHeight,
            texturePositionX + textureWidth, texturePositionY + textureHeight,
            texturePositionX + textureWidth, texturePositionY
        };
     
        GLubyte indexBuffer[4] = {
            0, 2, 4, 6
        };
        glGenBuffers(1, &vbIdentifier);
        glBindBuffer(GL_ARRAY_BUFFER, vbIdentifier);
        glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), NULL, GL_STATIC_DRAW);
        glBufferSubData(GL_ARRAY_BUFFER, 0, 8 * sizeof(GLfloat), vertexBuffer);
        glVertexPointer(2, GL_FLOAT, sizeof(GLfloat), 0);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
     
        glGenBuffers(1, &tbIdentifier);
        glBindBuffer(GL_ARRAY_BUFFER, tbIdentifier);
        glBufferData(GL_ARRAY_BUFFER, 8 * sizeof(GLfloat), NULL, GL_STATIC_DRAW);
        glBufferSubData(GL_ARRAY_BUFFER, 0, 8 * sizeof(GLfloat), textureBuffer);
        glTexCoordPointer(2, GL_FLOAT, sizeof(GLfloat), 0);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
     
        glGenBuffers(1, &ivbIdentifier);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ivbIdentifier);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, 4 * sizeof(GLubyte), indexBuffer, GL_STATIC_DRAW);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    (I program under mac osx)
    Thats how i initialize my VBO. Now when I create two different VBOs the first VBO is the same as the second VBO. Why does this happen?
    Thx for help !
    Greetings Cookiesoft

  2. #2
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    17
    what do you mean by the same?
    the ids? or the data?

    If you mean the data, you need to show the rendering of the buffers, since gl*Pointer is client state and you need to activate those pointer during rendering, unless you use vertex array objects...

    See

    http://www.opengl.org/registry/specs...fer_object.txt

    at the very end of the document where the examples are.

    I mean, the gl*Pointer calls are meaningless in this context, to my knowledge. You need to use those pointers if you want to render.
    You also need to activate the client state for those pointers. So every time you render you need to set those pointer. If you like to give VAO a chance, you only need to activate those pointers once for each VAO.

    http://www.opengl.org/registry/specs...ray_object.txt
    Last edited by noopnoop; 05-30-2013 at 07:08 AM.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    9
    I mean the data is the same(the width and height and texcoords stay the same). And I activated the pointer during rendering:
    Code :
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
     
        glBindBuffer(GL_ARRAY_BUFFER, vbIdentifier);
        glBindBuffer(GL_ARRAY_BUFFER, tbIdentifier);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ivbIdentifier);
        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
     
        glDrawElements(GL_QUADS, 8, GL_UNSIGNED_BYTE, 0);
     
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        glDisableClientState(GL_VERTEX_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
    So I don't think that this is the problem.

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2013
    Posts
    9
    Oh srry now I got it! I've put the Pointer line in the render code not in the init code! Thanks!

  5. #5
    Junior Member Newbie
    Join Date
    May 2013
    Posts
    17
    Quote Originally Posted by cookiesoft View Post
    I've put the Pointer line in the render code not in the init code!
    I bet you mean the other way around... Glad it helped.

Tags for this Thread

Posting Permissions

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