Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
VertexArray.h
Go to the documentation of this file.
1#pragma once
2#include <QOpenGLExtraFunctions>
3#include <xgl/ShaderProgram.h>
5#include <xgl/global.h>
6#include <xgl/utils.h>
7
8namespace sf::xgl
9{
10
15{
16 public:
20 typedef GLuint handle_type;
21
26
30 ~VertexArray() override;
31
35 bool setup() override;
36
41 void draw() override;
42
46 void paint() override;
47
48 protected:
53 virtual bool doCreate() = 0;
54
59 virtual void doDraw() = 0;
60
64 virtual void doPaint() = 0;
65
71
79 template<typename VertexType, typename FieldType>
80 void setAttribPointer(ShaderProgram::Attribute sa, size_t offset);
81
82 private:
86 ShaderProgram* _shaderProgram;
87};
88
89template<typename VertexType, typename FieldType>
91{
92 setVertexAttribPointer<VertexType, FieldType>(_shaderProgram->attributeLocation(sa), offset);
93}
94
95}// namespace sf::xgl
Shader program having a default vertex and fragment shader.
Definition ShaderProgram.h:13
Attribute
Enumeration of available shader attributes to map data in the object buffers. The names of the enumer...
Definition ShaderProgram.h:22
int attributeLocation(Attribute sa) const
Gets layout input location of the given shader attribute.
Base class for Vertex array derived classes.
Definition VertexArrayBase.h:14
OpenGL base class and wrapper for vertex arrays.
Definition VertexArray.h:15
void setAttribPointer(ShaderProgram::Attribute sa, size_t offset)
Makes a call to glVertexAttribPointer() in a smart way.
Definition VertexArray.h:90
void paint() override
Paints the object old style OpenGL.
GLuint handle_type
Type for the handle of the vertex array.
Definition VertexArray.h:20
void draw() override
Draws the vertex array. Specifically called from the paintGL() function of the OpenGL widget.
bool setup() override
Sets up the vertex array for the OpenGL context.
virtual void doDraw()=0
Method to be overridden by a derived class. Called when the handle is valid from the draw() function.
ShaderProgram * shaderProgram()
Gets the associated shader program.
VertexArray(ShaderProgram *sp)
Constructor.
virtual void doPaint()=0
Method to be overridden by a derived class.
~VertexArray() override
Virtual destructor.
virtual bool doCreate()=0
Method to be overridden by a derived class.
Definition DemoRenderer.h:6
#define _XGL_CLASS
Definition xgl/global.h:35