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

Thread: Displaying Models

  1. #1
    Newbie Newbie
    Join Date
    Oct 2013
    Posts
    1

    Displaying Models

    Hi guys! I am trying to display two or more models on the screen at the same time. I have successfully displayed one model using three buffers, vertex,color,and normal buffer:

    glGenBuffers(1, &vertexbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
    glBufferData(GL_ARRAY_BUFFER, model1.vertices.size() * sizeof(vec3), &model1.vertices[0], GL_STATIC_DRAW);


    glGenBuffers(1, &colorbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, colorbuffer);
    glBufferData(GL_ARRAY_BUFFER, model1.vertices.size() * sizeof(vec3), &model1.foreColors[0], GL_STATIC_DRAW);


    glGenBuffers(1, &normalbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, normalbuffer);
    glBufferData(GL_ARRAY_BUFFER, model1.vertices.size() * sizeof(vec3), &model1.normals[0], GL_STATIC_DRAW);

    ////////

    Now to display the second object, do I need to repeat the above code with a little change, instead model1, I should use model2?? I actually tried to use model2 instead model1, but what has displayed is just the first model1.

    I read in some resources , that I should use glBufferSubData instead of glBufferData, but the problem is that I dont know how to use it. Any idea please? Thanks

  2. #2
    Advanced Member Frequent Contributor Ehsan Kamrani's Avatar
    Join Date
    May 2005
    Posts
    534
    for each geometry,you should generate one VBO. glBufferSubData is useful for geometries that change over time(for example,skeletal animation)

Posting Permissions

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