opengl: batch drawing of polylines

Desktop / LibreOffice - Tomaž Vajngerl [collabora.co.uk] - 8 June 2016 03:12 UTC

To get polylines to draw in a batch it was necessary to refactor the polyline code to work with GL_TRIANGLES instead of the previous used GL_TRIANGLE_STRIP. For this and to make the code easier to handle a new class was introduced: LineBuilder, which purpose is to assemble vertices for a polyline (line ends, line joints).

In addition we need to know the line width, anti-aliasing (AA) per
vertex basis (in addition to color, normal and extrusion) so we can draw many polylines with one draw call. This info is now stored in Vertex struct which is used when drawing lines or triangles (fills).

Uploading of vertices has also been changed, previously we uploaded the vertices with the drawcall. a convention in Modern OpenGL is however to use VBO (Vertex Buffer Object) for this. With this we can upload the to the GPU vertices independently and not upload them if this is not needed (which is currently not used yet). A vector of Vertex structs is now uploaded to the GPU using a VBO which is handeled with a new VertexBufferObject class.

In addition to reduce the ammount of duplicated vertices, we use a index vector (handled by IndexBufferObject class) where we only define the indices of the vertex buffer which should be drawn.

ce72e34 opengl: batch drawing of polylines
vcl/Library_vcl.mk | 1 +
vcl/inc/opengl/BufferObject.hxx | 89 ++++++++
vcl/inc/opengl/LineRenderUtils.hxx | 54 +++++
vcl/inc/opengl/RenderList.hxx | 30 ++-
vcl/inc/opengl/VertexUtils.hxx | 112 +++++-----
vcl/inc/opengl/program.hxx | 14 +-
vcl/inc/openglgdiimpl.hxx | 4 +-
vcl/opengl/LineRenderUtils.cxx | 185 ++++++++++++++++
vcl/opengl/RenderList.cxx | 314 ++++++++++++++++++++-------
vcl/opengl/combinedFragmentShader.glsl | 20 +-
vcl/opengl/combinedVertexShader.glsl | 32 ++-
vcl/opengl/gdiimpl.cxx | 361 +++++---------------------------
vcl/opengl/program.cxx | 28 ++-
13 files changed, 750 insertions(+), 494 deletions(-)

Upstream: cgit.freedesktop.org


  • Share