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: From GL_LINE_STRIP to VBO/VAOs ?

  1. #1
    Junior Member Newbie techwinder's Avatar
    Join Date
    Feb 2016
    Location
    Paris, France
    Posts
    6

    From GL_LINE_STRIP to VBO/VAOs ?

    Hi everyone,
    I'm trying to upgrade some legacy OpenGL 1.0 code, but I don't understand how to use efficiently VertexArrayObjects and VertexBufferObjects. Drawing one line strip is OK, but how to draw many lines at once ?
    Formerly:
    Code :
    	glNewList(MYLIST, GL_COMPILE);
    	{
                    // 30 to 50 linestrips of different lengths
    		glBegin(GL_LINE_STRIP);
    		{
                               ...
    		}
    		glEnd();
                    ....
    		glBegin(GL_LINE_STRIP);
    		{
                               ...
    		}
    		glEnd();
    	}
    	glEndList();

    Should it be something like an array of VBOs, and one VAO to rule them all and on the GPU bind them ?
    Code :
    	vao.bind();
    	for(int i=0; i<vbo.size(); i++)
    	{
    		vbo[i].create();
    		vbo[i].bind();
    		vbo[i].allocate(vertices, sizeof(vertices));
    		vbo[i].release();
    	}
    	vao.release();

    BTW, I'm using the Qt5 framework.

    Any insight will be greatly appreciated.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,731
    Quote Originally Posted by techwinder View Post
    Should it be something like an array of VBOs, and one VAO to rule them all and on the GPU bind them ?
    There's no need to use multiple VBOs. A draw call doesn't have to use the entire VBO; you can draw any contiguous sub-range by specifying the appropriate values for the first and count parameters to glDrawArrays().

    If you don't need to change any state between strips, you can draw all of the strips with a single call to glMultiDrawArrays().

  3. #3
    Junior Member Newbie techwinder's Avatar
    Join Date
    Feb 2016
    Location
    Paris, France
    Posts
    6
    Great, thanks.

Posting Permissions

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