Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::xgl::Helper Class Reference

Keeps track of color. More...

#include <Helper.h>

Public Types

typedef Matrix44::value_type value_type
 

Public Member Functions

 Helper (ShaderProgram *sp)
 Create helper for a shader program.
 
 Helper (Dynamic *dynamic=nullptr)
 Create helper for a dynamic object which shader program is used to initialize the helper. Method setVertex() passes the data to the given dynamic object as are methods beginMode() and endMode().
 
void setFlags (bool solid, bool paint=false)
 Helper flags which determine how the helper is active.
 
void setCameraAndModelMatrix (const QMatrix4x4 &camera, const QMatrix4x4 &model)
 Sets the camera and model matrices which needed for old style OpenGL.
 
bool isSolid () const
 Gets the solid flag.
 
bool isPainting () const
 Gets the paint flag.
 
void pushMatrix ()
 Pushes the current matrix to stack.
 
void popMatrix ()
 Pops the stored matrix from stack.
 
void pushCulling (CullingState state)
 Pushes the current culling settings to stack.
 
void popCulling ()
 Pops the stored culling settings to stack.
 
Matrix44 & matrix ()
 Gets the current matrix to modify.
 
void translate (value_type x, value_type y, value_type z)
 Performs a translation on the current matrix. Compatible with the OpenGL function.
 
void rotate (value_type angle, value_type x, value_type y, value_type z)
 Performs a rotation on the current matrix. Compatible with the OpenGL function.
 
void setColor (const Color &color)
 Sets the current color using a QColor type.
 
void setColor (const QColor &color)
 Sets the current color using a QColor type.
 
void setColor (float r, float g, float b, float a)
 Sets the current color using the rgba values. Compatible with the OpenGL function glColorXXX.
 
void setLineWidth (float width=1.0f)
 Sets the line width for GL_LINES and GL_LINE_STRIP.
 
void render (VertexArrayBase *object, bool is_model=true)
 Draws the element setting some shader uniforms depending on the given arguments.
 
void render (const std::function< void()> &callback, bool is_model=true)
 Sets the tracked state before rendering using the callback.
 
void beginMode (GLenum mode)
 
void endMode ()
 
void setNormal (double x, double y, double z)
 
void setVertex (double x, double y, double z)
 
void setVertex (Vector3D vec)
 
void setTexCoord (double x, double y)
 
void drawSphere (double radius, int slices, int stacks)
 
void drawDisk (double innerRadius, double outerRadius, int slices, int loops)
 
void drawCylinder (double baseRadius, double topRadius, double height, int slices, int stacks)
 
void drawPlaneLines (const Vector3D &a, const Vector3D &b, const Vector3D &, const Vector3D &d, int w_lines, int h_lines)
 
ShaderProgramshaderProgram ()
 Gets the Shader program.
 

Detailed Description

Keeps track of color.

Member Typedef Documentation

◆ value_type

typedef Matrix44::value_type sf::xgl::Helper::value_type

Type to use for OpenGL like functions.

Constructor & Destructor Documentation

◆ Helper() [1/2]

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

Create helper for a shader program.

◆ Helper() [2/2]

sf::xgl::Helper::Helper ( Dynamic dynamic = nullptr)
explicit

Create helper for a dynamic object which shader program is used to initialize the helper. Method setVertex() passes the data to the given dynamic object as are methods beginMode() and endMode().

Member Function Documentation

◆ beginMode()

void sf::xgl::Helper::beginMode ( GLenum  mode)

◆ drawCylinder()

void sf::xgl::Helper::drawCylinder ( double  baseRadius,
double  topRadius,
double  height,
int  slices,
int  stacks 
)

◆ drawDisk()

void sf::xgl::Helper::drawDisk ( double  innerRadius,
double  outerRadius,
int  slices,
int  loops 
)

◆ drawPlaneLines()

void sf::xgl::Helper::drawPlaneLines ( const Vector3D &  a,
const Vector3D &  b,
const Vector3D &  ,
const Vector3D &  d,
int  w_lines,
int  h_lines 
)

◆ drawSphere()

void sf::xgl::Helper::drawSphere ( double  radius,
int  slices,
int  stacks 
)

◆ endMode()

void sf::xgl::Helper::endMode ( )

◆ isPainting()

bool sf::xgl::Helper::isPainting ( ) const

Gets the paint flag.

◆ isSolid()

bool sf::xgl::Helper::isSolid ( ) const

Gets the solid flag.

◆ matrix()

Matrix44 & sf::xgl::Helper::matrix ( )

Gets the current matrix to modify.

◆ popCulling()

void sf::xgl::Helper::popCulling ( )

Pops the stored culling settings to stack.

◆ popMatrix()

void sf::xgl::Helper::popMatrix ( )

Pops the stored matrix from stack.

◆ pushCulling()

void sf::xgl::Helper::pushCulling ( CullingState  state)

Pushes the current culling settings to stack.

◆ pushMatrix()

void sf::xgl::Helper::pushMatrix ( )

Pushes the current matrix to stack.

◆ render() [1/2]

void sf::xgl::Helper::render ( const std::function< void()> &  callback,
bool  is_model = true 
)

Sets the tracked state before rendering using the callback.

Parameters
callbackLambda function containing setVertex() methods wrappen with beginMode() and endMode().
is_modelDetermines if the model matrix applies when rendering.

◆ render() [2/2]

void sf::xgl::Helper::render ( VertexArrayBase object,
bool  is_model = true 
)

Draws the element setting some shader uniforms depending on the given arguments.

Parameters
objectWhen NULL the object is not drawn.
is_modelTrue when the object is part of the model and not a static object as e.g. axes for orientation.

◆ rotate()

void sf::xgl::Helper::rotate ( value_type  angle,
value_type  x,
value_type  y,
value_type  z 
)

Performs a rotation on the current matrix. Compatible with the OpenGL function.

◆ setCameraAndModelMatrix()

void sf::xgl::Helper::setCameraAndModelMatrix ( const QMatrix4x4 &  camera,
const QMatrix4x4 &  model 
)

Sets the camera and model matrices which needed for old style OpenGL.

Parameters
camera
model

◆ setColor() [1/3]

void sf::xgl::Helper::setColor ( const Color color)

Sets the current color using a QColor type.

Parameters
colorQt color value. Compatible with the OpenGL function glColorXXX.

◆ setColor() [2/3]

void sf::xgl::Helper::setColor ( const QColor &  color)

Sets the current color using a QColor type.

Parameters
colorQt color value. Compatible with the OpenGL function glColorXXX.

◆ setColor() [3/3]

void sf::xgl::Helper::setColor ( float  r,
float  g,
float  b,
float  a 
)

Sets the current color using the rgba values. Compatible with the OpenGL function glColorXXX.

◆ setFlags()

void sf::xgl::Helper::setFlags ( bool  solid,
bool  paint = false 
)

Helper flags which determine how the helper is active.

Parameters
solidDetermines if a filled solid or wire frame is rendered.
paintDetermines if OpenGL old style (true) or new style (false) is used for rendering.

◆ setLineWidth()

void sf::xgl::Helper::setLineWidth ( float  width = 1.0f)

Sets the line width for GL_LINES and GL_LINE_STRIP.

Parameters
widthDefault OpenGL value is 1.

◆ setNormal()

void sf::xgl::Helper::setNormal ( double  x,
double  y,
double  z 
)

◆ setTexCoord()

void sf::xgl::Helper::setTexCoord ( double  x,
double  y 
)

◆ setVertex() [1/2]

void sf::xgl::Helper::setVertex ( double  x,
double  y,
double  z 
)

◆ setVertex() [2/2]

void sf::xgl::Helper::setVertex ( Vector3D  vec)

◆ shaderProgram()

ShaderProgram * sf::xgl::Helper::shaderProgram ( )

Gets the Shader program.

Returns
Pointer to the instance.

◆ translate()

void sf::xgl::Helper::translate ( value_type  x,
value_type  y,
value_type  z 
)

Performs a translation on the current matrix. Compatible with the OpenGL function.


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