diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-06-07 20:45:14 +0900 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2016-06-08 17:12:28 +0900 |
commit | ce72e34b359c323ef7ff96a70500810a9cd8703a (patch) | |
tree | 7436ef509b6670c4331d2e2f0c552728e13ea1f8 /vcl/inc/opengl/program.hxx | |
parent | 4bdbfdd6426460c562746c67c29a3b5e2bef8563 (diff) |
opengl: batch drawing of polylines
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.
Change-Id: I49dc9c6260b459f4f4ce3a5e4fa4c8ad05a7b878
Diffstat (limited to 'vcl/inc/opengl/program.hxx')
-rw-r--r-- | vcl/inc/opengl/program.hxx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/vcl/inc/opengl/program.hxx b/vcl/inc/opengl/program.hxx index c737c1250aaa..b32aa05f250e 100644 --- a/vcl/inc/opengl/program.hxx +++ b/vcl/inc/opengl/program.hxx @@ -22,7 +22,6 @@ #include <tools/color.hxx> #include <opengl/texture.hxx> -#include <glm/glm.hpp> #include <unordered_map> typedef std::unordered_map< OString, GLuint, OStringHash > UniformCache; @@ -82,7 +81,7 @@ public: void SetAlphaCoord( const GLvoid* pData ); void SetMaskCoord(const GLvoid* pData); void SetExtrusionVectors(const GLvoid* pData); - void SetVertexColors(std::vector<glm::vec4>& rColorVector); + void SetVertexColors(std::vector<GLubyte>& rColorVector); void SetUniform1f( const OString& rName, GLfloat v1 ); void SetUniform2f( const OString& rName, GLfloat v1, GLfloat v2 ); @@ -107,11 +106,16 @@ public: bool DrawTexture( const OpenGLTexture& rTexture ); - void DrawArrays(GLenum GLenum, std::vector<GLfloat>& aVertices); + void DrawArrays(GLenum aMode, std::vector<GLfloat>& aVertices); + void DrawElements(GLenum aMode, GLuint nNumberOfVertices); -protected: bool EnableVertexAttrib(GLuint& rAttrib, const OString& rName); - void SetVertexAttrib( GLuint& rAttrib, const OString& rName, const GLvoid* pData, GLint nSize = 2 ); + + void SetVertexAttrib(GLuint& rAttrib, const OString& rName, GLint nSize, + GLenum eType, GLboolean bNormalized, GLsizei aStride, + const GLvoid* pPointer); + +protected: GLuint GetUniformLocation( const OString& rName ); }; |