SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGLVertexArrayExt.h
Go to the documentation of this file.
1 /**
2  * \file SLGLVertexArrayExt.h
3  * \brief Extension class with functions for quick line & point drawing
4  * \date January 2016
5  * \authors Marcus Hudritsch
6  * \copyright http://opensource.org/licenses/GPL-3.0
7  * \remarks Please use clangformat to format the code. See more code style on
8  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
9 */
10 
11 #ifndef SLGLVERTEXARRAYEXT_H
12 #define SLGLVERTEXARRAYEXT_H
13 
14 #include <SLGLVertexArray.h>
15 
16 //-----------------------------------------------------------------------------
17 //! SLGLVertexArray adds Helper Functions for quick Line & Point Drawing
18 /*! These functions where separated from SLGLVertexAttribute because they use
19 the predefined shader ColorUniform and have there for references to the classes
20 SLScene and SLGLProgram.
21 */
23 {
24 public:
26  virtual ~SLGLVertexArrayExt() { ; }
27 
28  //! Adds or updates & generates a position vertex attribute for colored line or point drawing
29  void generateVertexPos(SLVVec2f* p) { generateVertexPos((SLuint)p->size(), 2, &p->operator[](0)); }
30 
31  //! Adds or updates & generates a position vertex attribute for colored line or point drawing
32  void generateVertexPos(SLVVec3f* p) { generateVertexPos((SLuint)p->size(), 3, &p->operator[](0)); }
33 
34  //! Adds or updates & generates a position vertex attribute for colored line or point drawing
35  void generateVertexPos(SLVVec4f* p) { generateVertexPos((SLuint)p->size(), 4, &p->operator[](0)); }
36 
37  //! Draws the array as the specified primitive with the color
38  void drawArrayAsColored(SLGLPrimitiveType primitiveType,
39  SLCol4f color,
40  SLfloat lineOrPointSize = 1.0f,
41  SLuint indexFirstVertex = 0,
42  SLuint countVertices = 0);
43 
44  //! Draws the VAO by element indices with the specified primitive with the color
45  void drawElementAsColored(SLGLPrimitiveType primitiveType,
46  SLCol4f color,
47  SLfloat pointSize,
48  SLuint indexFirstVertex = 0,
49  SLuint countVertices = 0);
50 
51 private:
52  //! Adds or updates & generates a position vertex attribute for colored line or point drawing
54  SLint elementSize,
55  void* dataPointer);
56 };
57 //-----------------------------------------------------------------------------
58 
59 #endif
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
int SLint
Definition: SL.h:170
SLGLPrimitiveType
Definition: SLGLEnums.h:30
Wrapper class around OpenGL Vertex Array Objects (VAO)
vector< SLVec2f > SLVVec2f
Definition: SLVec2.h:143
vector< SLVec3f > SLVVec3f
Definition: SLVec3.h:325
vector< SLVec4f > SLVVec4f
Definition: SLVec4.h:239
SLGLVertexArray adds Helper Functions for quick Line & Point Drawing.
void generateVertexPos(SLVVec2f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
void drawElementAsColored(SLGLPrimitiveType primitiveType, SLCol4f color, SLfloat pointSize, SLuint indexFirstVertex=0, SLuint countVertices=0)
Draws the VAO by element indices with the specified primitive with the color.
void drawArrayAsColored(SLGLPrimitiveType primitiveType, SLCol4f color, SLfloat lineOrPointSize=1.0f, SLuint indexFirstVertex=0, SLuint countVertices=0)
Draws the array as the specified primitive with the color.
void generateVertexPos(SLVVec3f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
void generateVertexPos(SLVVec4f *p)
Adds or updates & generates a position vertex attribute for colored line or point drawing.
SLGLVertexArray encapsulates the core OpenGL drawing.
SLuint numVertices() const