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: Beginner question: Using vbos with vertexHandle/normalHandle causes trouble

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2012
    Posts
    4

    Beginner question: Using vbos with vertexHandle/normalHandle causes trouble

    I am loading a 3d model within java by parsing an *.obj file which was created by exporting it out of Blender. So far so good the import is working.
    I am storing all vertices and normals coordinates in an 2 ArrayLists<Vector3f>. Thats working.

    I am getting into trouble when importing 2 or 3 different models, because glgenBuffers() is returning values 1 and 2 when creating vbo_vertexHandle and vbo_normalHandle for the first object, 3 and 4 for the 2nd object and 5 and 6 for the 3rd object. Do I hav to have ONE global vertexHandle (all vertices of all 3 models) and ONE global normalHandle (all normal indices of all 3 objects) -> so I only have to work with Handles 1 and 2, or may I as I supposed store the vertexHandle and normalHandle for each object within the 3dmodel instance (1 and 2 for obj01, 2 and 3 for obj02...) and using them dependingly on WHICH model I want to render?

    Do anyone perhaps know a good src to learn how to deal with 2 or more different 3dobjects ( in java I mean real instances not only drawing 2 quads )?

    Thank you for the possible answer.
    regards Alexander

  2. #2

  3. #3
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421
    I guess he means VBO ID.
    Yes, every time you call glGenBuffers, you get a new ID.
    If you are just starting out and learning about GL, that is fine.
    Later on, if you want to optimize, then you can pack multiple models in a single large VBO. You can write a "VBO manager class" for that.
    You can even pack vertex, normal, texcoord in the same VBO.
    VBOs are explained here and there is a sample code
    http://www.opengl.org/wiki/Vertex_Buffer_Object
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

Posting Permissions

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