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

Thread: Multiple Mesh

  1. #1
    Newbie Newbie
    Join Date
    Dec 2013
    Posts
    2

    Multiple Mesh

    Hey everyone,

    Recently I have been following some OpenGL tutorials that use freeglut and glew on windows and I've managed to get them all working and understand the basic steps you need to do to get a mesh onto the screen. However I am a little bit in the dark when it comes to getting multiple meshes on the screen. At this point in time I have not tried it yet, since I felt like asking someone who has done it before will prevent me from making the 'newb' mistakes someone else maybe ran into a bit further down the road when he/she started using OpenGL.

    The current steps I follow for a single mesh are (not showing all parameters for every function) :
    Code :
    GLuint vao;
    GLuint vbo;
    GLuint indexBufferID;
    GLuint textureBufferID;
    GLuint textureCoordID;
     
    glGenVertexArrays(1, &vao);
    glBindVertexArray(vao);
     
    glGenBuffers(1, &vbo);
    glBindBuffers(GL_ARRAY_BUFFER, vbo);
     
    glBufferData(...);
    glBufferSubData(..., vertices);
    glBufferSubData(..., normals);
    glBufferSubData(..., uvs);
     
    glGenBuffers(1, &indexBufferID);
    glBindBuffer(GL_ELEMENT_ARRAY, indexBufferID);
    glBufferData(..., indices, ...);
     
    // Texture stuff...

    I left out the texturing stuff, since I feel when I know the other steps I should be able to work with textures as well. However advise is always appreciated! So my question is: What is the best way to render multiple meshes and what trade-offs are there to keep in mind?

    Kind regards,

    Dijego

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,101
    In the first instance just make a VAO for each object.

    To render clear your render buffer, bind and render the first object then bind and render the second object then do the swap buffer.

    Long term your can improve on this but baby steps are a good thing.

  3. #3
    Newbie Newbie
    Join Date
    Dec 2013
    Posts
    2
    Hey tonyo_au,

    Thank you for the reply, I was thinking in that direction already glad to see its a good way to start out!

    Kind regards,

    Dijego

Posting Permissions

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