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

Base class for Vertex array derived classes. More...

#include <VertexArrayBase.h>

Inheritance diagram for sf::xgl::VertexArrayBase:
Collaboration diagram for sf::xgl::VertexArrayBase:

Public Types

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

 VertexArrayBase (QObject *parent=nullptr)
 Default Qt object constructor.
 
virtual void draw ()=0
 Draws the vertex array. Specifically called from the paintGL() function of the OpenGL widget.
 
virtual void paint ()=0
 Paints the object old style OpenGL.
 
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.
 

Static Public Member Functions

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.
 

Protected Member Functions

virtual bool setup ()=0
 Sets up the vertex array for the OpenGL context.
 
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.
 

Detailed Description

Base class for Vertex array derived classes.

Member Typedef Documentation

◆ NormalsDataType

Type for extracting normals from all used vertices.

◆ VertexMember

Type used to describe vertex structure members.

Member Enumeration Documentation

◆ EDrawMode

Drawing mode of by the template.

Enumerator
dmDrawArrays 

Call OpenGL glDrawArrays() function.

dmDrawElements 

Call OpenGL glDrawElements() function.

◆ ERenderOption

Render options.

Enumerator
roNone 

Entry for choosing not to set any flag.

roWires 

Render using wires instead of filled.

roNormals 

Render the normals as.

◆ EVertexMember

Possible member of a vertex structure. Where the position can not be omitted as part of the vertex.

Enumerator
vmPosition 

Position member of vec3 type.

vmNormal 

Normal member of vec3 type.

vmColor 

Color member of vec4 type.

vmTexCoord 

Texture coord member of vec2 type

Constructor & Destructor Documentation

◆ VertexArrayBase()

sf::xgl::VertexArrayBase::VertexArrayBase ( QObject *  parent = nullptr)
explicit

Default Qt object constructor.

Member Function Documentation

◆ callGenerate()

bool sf::xgl::VertexArrayBase::callGenerate ( )
protected

Makes a call to virtual function generate() when the #_generateFlag is set using triggerGenerate().

◆ clearData()

◆ draw()

◆ generate()

virtual void sf::xgl::VertexArrayBase::generate ( )
protectedpure virtual

Generate the data needed for creation of vertex array and/or indices. Is or must be called by setup() function.

Implemented in sf::xgl::Axes, sf::xgl::Cone, sf::xgl::Cube, sf::xgl::Cylinder, sf::xgl::Disk, sf::xgl::Dynamic, sf::xgl::Line, sf::xgl::Normals, sf::xgl::Rectangle, sf::xgl::Sphere, and sf::xgl::Tube.

◆ getDefaultColor()

static const Color & sf::xgl::VertexArrayBase::getDefaultColor ( )
static

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:

struct Vertex
{
vector3f position;
vector3f normal;
// Use the function here to initialize.
vector4f color{getDefaultColor()};
};
std::array< GLfloat, 4 > vector4f
Type which correspond with a GLSL type and used to implement Vertex structures.
Definition Types.h:25
std::array< GLfloat, 3 > vector3f
Type which correspond with a GLSL type and used to implement Vertex structures.
Definition Types.h:21

◆ getNormalsData()

◆ getRenderOptions()

RenderOptions sf::xgl::VertexArrayBase::getRenderOptions ( ) const

Gets the render options.

◆ hasColor()

◆ hasTexture()

virtual bool sf::xgl::VertexArrayBase::hasTexture ( ) const
pure virtual

◆ isTriggered()

bool sf::xgl::VertexArrayBase::isTriggered ( ) const
protected

Gets the flag if data is to be (re-)generated. Flag is set to True initially.

Returns
True when triggerd.

◆ modifyContext()

virtual void sf::xgl::VertexArrayBase::modifyContext ( bool  before,
bool  draw,
size_t  mode_index 
)
protectedvirtual

Allows modifying the OpenGL context before and after drawing.

Parameters
beforeTrue when this function is called before drawing and False when after.
drawTrue when called for drawing and not painting (is old style OpenGL).
mode_indexIndex of the mode list. When painting the

Reimplemented in sf::xgl::Line, and sf::xgl::Normals.

◆ paint()

◆ setDefaultColor()

static void sf::xgl::VertexArrayBase::setDefaultColor ( const QColor &  color)
static

Sets the default color used by the vertex structures when not set by the derived class.

◆ setRenderOptions()

void sf::xgl::VertexArrayBase::setRenderOptions ( RenderOptions  options)

Modify the render options which will trigger a regeneration of the vertices and indices.

◆ setup()

◆ triggerGenerate()

void sf::xgl::VertexArrayBase::triggerGenerate ( )

Sets a flag to trigger data generation when the data is called for.


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