Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::xgl::VertexArray Class Referenceabstract

OpenGL base class and wrapper for vertex arrays. More...

#include <VertexArray.h>

Inheritance diagram for sf::xgl::VertexArray:
Collaboration diagram for sf::xgl::VertexArray:

Public Types

typedef GLuint handle_type
 Type for the handle of the vertex array.
 
- Public Types inherited from sf::xgl::VertexArrayBase
enum  EVertexMember : VertexMember { vmPosition = 1 << 0 , vmNormal = 1 << 1 , vmColor = 1 << 2 , vmTexCoord = 1 << 3 }
 Possible member of a vertex structure. Where the position can not be omitted as part of the vertex. More...
 
enum  EDrawMode { dmDrawArrays , dmDrawElements }
 Drawing mode of by the template. More...
 
enum  ERenderOption : int { roNone = 0 , roWires = 1 << 0 , roNormals = 1 << 1 }
 Render options. More...
 
typedef unsigned VertexMember
 Type used to describe vertex structure members.
 
typedef TVector< std::pair< vector3f, vector3f > > NormalsDataType
 Type for extracting normals from all used vertices.
 

Public Member Functions

 VertexArray (ShaderProgram *sp)
 Constructor.
 
 ~VertexArray () override
 Virtual destructor.
 
bool setup () override
 Sets up the vertex array for the OpenGL context.
 
void draw () override
 Draws the vertex array. Specifically called from the paintGL() function of the OpenGL widget.
 
void paint () override
 Paints the object old style OpenGL.
 
- Public Member Functions inherited from sf::xgl::VertexArrayBase
 VertexArrayBase (QObject *parent=nullptr)
 Default Qt object constructor.
 
virtual bool hasColor () const =0
 Determines if Vertex has a color component.
 
virtual bool hasTexture () const =0
 Determines if Vertex has a texture mapping component.
 
virtual NormalsDataType getNormalsData () const =0
 Gets the information from the vertices to make normals visible.
 
void triggerGenerate ()
 Sets a flag to trigger data generation when the data is called for.
 
void setRenderOptions (RenderOptions options)
 Modify the render options which will trigger a regeneration of the vertices and indices.
 
RenderOptions getRenderOptions () const
 Gets the render options.
 

Protected Member Functions

virtual bool doCreate ()=0
 Method to be overridden by a derived class.
 
virtual void doDraw ()=0
 Method to be overridden by a derived class. Called when the handle is valid from the draw() function.
 
virtual void doPaint ()=0
 Method to be overridden by a derived class.
 
ShaderProgramshaderProgram ()
 Gets the associated shader program.
 
template<typename VertexType , typename FieldType >
void setAttribPointer (ShaderProgram::Attribute sa, size_t offset)
 Makes a call to glVertexAttribPointer() in a smart way.
 
- Protected Member Functions inherited from sf::xgl::VertexArrayBase
virtual void clearData ()=0
 Clears the data to generate array buffers.
 
bool callGenerate ()
 Makes a call to virtual function generate() when the #_generateFlag is set using triggerGenerate().
 
virtual void generate ()=0
 Generate the data needed for creation of vertex array and/or indices. Is or must be called by setup() function.
 
virtual void modifyContext (bool before, bool draw, size_t mode_index)
 Allows modifying the OpenGL context before and after drawing.
 
bool isTriggered () const
 Gets the flag if data is to be (re-)generated. Flag is set to True initially.
 

Additional Inherited Members

- Static Public Member Functions inherited from sf::xgl::VertexArrayBase
static const ColorgetDefaultColor ()
 Gets the default color used by the vertex structures when not set by the derived class. Created to have a single location for the default color.
An example how it is used:
 
static void setDefaultColor (const QColor &color)
 Sets the default color used by the vertex structures when not set by the derived class.
 

Detailed Description

OpenGL base class and wrapper for vertex arrays.

Member Typedef Documentation

◆ handle_type

Type for the handle of the vertex array.

Constructor & Destructor Documentation

◆ VertexArray()

sf::xgl::VertexArray::VertexArray ( ShaderProgram sp)
explicit

Constructor.

◆ ~VertexArray()

sf::xgl::VertexArray::~VertexArray ( )
override

Virtual destructor.

Member Function Documentation

◆ doCreate()

virtual bool sf::xgl::VertexArray::doCreate ( )
protectedpure virtual

Method to be overridden by a derived class.

Returns
Handle of the created array.

◆ doDraw()

virtual void sf::xgl::VertexArray::doDraw ( )
protectedpure virtual

Method to be overridden by a derived class. Called when the handle is valid from the draw() function.

◆ doPaint()

virtual void sf::xgl::VertexArray::doPaint ( )
protectedpure virtual

Method to be overridden by a derived class.

◆ draw()

void sf::xgl::VertexArray::draw ( )
overridevirtual

Draws the vertex array. Specifically called from the paintGL() function of the OpenGL widget.

Implements sf::xgl::VertexArrayBase.

◆ paint()

void sf::xgl::VertexArray::paint ( )
overridevirtual

Paints the object old style OpenGL.

Implements sf::xgl::VertexArrayBase.

◆ setAttribPointer()

template<typename VertexType , typename FieldType >
void sf::xgl::VertexArray::setAttribPointer ( ShaderProgram::Attribute  sa,
size_t  offset 
)
protected

Makes a call to glVertexAttribPointer() in a smart way.

Template Parameters
VertexTypeThe vertex structure.
FieldTypeStructure field which is a std::array<> having a 'value_type'.
Parameters
saShader attribute.
offset

◆ setup()

bool sf::xgl::VertexArray::setup ( )
overridevirtual

Sets up the vertex array for the OpenGL context.

Implements sf::xgl::VertexArrayBase.

◆ shaderProgram()

ShaderProgram * sf::xgl::VertexArray::shaderProgram ( )
protected

Gets the associated shader program.

Returns
Reference to the program.

The documentation for this class was generated from the following file: