GL Studio Safety Critical Embedded C++ Runtime Library
GlsRenderObject Class Referenceabstract

#include <gls_render_object.h>

+ Inheritance diagram for GlsRenderObject:

Classes

struct  InitParameters
 

Public Member Functions

virtual void SetAlphaMode (const GlsAlphaMode alphaMode)
 
virtual void SetFillColor (const GlsColor &fillColor)
 
virtual void SetLineColor (const GlsColor &lineColor)
 
virtual void SetLineWidth (const GlsFloat32 lineWidth)
 
virtual void SetPolygonMode (const GlsPolygonMode polygonMode)
 
virtual void SetTextureIndex (const GlsUInt32 textureIndex)
 
virtual void OffsetTexture (const GlsVector2D &offset)=0
 
- Public Member Functions inherited from GlsDisplayObject
virtual void Draw (GlsStateManager &gl, const GlsFloat64 time)=0
 
virtual void Calculate (const GlsFloat64 time)
 
virtual GlsDisplayObjectPickTest (const GlsVector2D &windowCoord, GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
GlsDisplayObjectHandleEvent (GlsEvent &event)
 
ObjectType GetObjectType (void) const
 
void SetBlinking (const GlsBool blinking)
 
void SetBlinkRate (const GlsFloat32 blinkRate)
 
void SetDynamicRotation (const GlsVector3D &dynamicRotation)
 
void SetDynamicScale (const GlsVector3D &dynamicScale)
 
void SetDynamicTranslation (const GlsVector3D &dynamicTranslation)
 
void SetVisibility (const GlsBool visible)
 
void SetParent (GlsDisplayObject *const parent)
 
void SetPickMode (const PickMode pickMode)
 
GlsBool NeedCalculate (void) const
 
void InvalidatePickCache (void)
 

Protected Member Functions

 GlsRenderObject (const InitParameters &initParameters, GlsEventDispatcher *const eventDispatcher)
 
GLint GlsTextureFilterModeToGL (const GlsTextureFilterMode mode) const
 
void SetupDepthTest (GlsStateManager &gl) const
 
void SetupAlpha (GlsStateManager &gl) const
 
GlsBool SetupTexture (GlsStateManager &gl, const GlsUInt32 textureIndex) const
 
void SetupTextureFilterSettings (GlsStateManager &gl) const
 
void SetupBackfaceCulling (GlsStateManager &gl) const
 
void SetupShading (GlsStateManager &gl) const
 
void SetupLineStyle (GlsStateManager &gl) const
 
void SetupAntiAlias (GlsStateManager &gl) const
 
virtual ~GlsRenderObject ()
 
- Protected Member Functions inherited from GlsDisplayObject
 GlsDisplayObject (const InitParameters &initParameters, const ObjectType objectType, GlsEventDispatcher *const eventDispatcher)
 
virtual ~GlsDisplayObject ()
 
GlsBool CalcDrawMatrix (const GlsMatrixAffineD *const additionalTransform, const GlsBool includeLocation)
 
virtual void CalcWindowPickRegion (GlsInputManager &inputManager, const GlsMatrixAffineD::GLMatrixAffineF &parentDrawMatrix)
 
GlsBool IsBlinkedOff (const GlsFloat64 time) const
 

Protected Attributes

const GlsBool _antiAlias
 
const GlsTexturePalette_texturePalette
 
const GlsBool _textureRepeat
 
const GlsTextureMapMode _textureMapMode
 
const GlsTextureFilterMode _textureMagFilterMode
 
const GlsTextureFilterMode _textureMinFilterMode
 
const GlsBool _cullBackFace
 
const GlsDepthBufferMode _depthBufferMode
 
const GlsPolygonEndMode _polygonEndMode
 
const GlsShadingMode _shadingMode
 
GlsAlphaMode _alphaMode
 
GlsColor _lineColor
 
GlsUInt32 _textureIndex
 
GlsPolygonMode _polygonMode
 
GlsColor _fillColor
 
GlsFloat32 _lineWidth
 
- Protected Attributes inherited from GlsDisplayObject
const GlsMatrixAffineD _dcsMatrix
 
const GlsMatrixAffineD _dcsMatrixInverse
 
const GlsBool _dcsMatrixIsIdentity
 
const GlsVector3D _location
 
const GlsBool _needCalculate
 
const ObjectType _objectType
 
const PickRegion _pickRegion
 
GlsEventDispatcher *const _eventDispatcher
 
const GlsVector3D _rotationPoint
 
GlsBool _blinking
 
GlsFloat32 _blinkRate
 
GlsMatrixAffineD::GLMatrixAffineF _drawMatrix
 
GlsVector3D _dynamicRotation
 
GlsVector3D _dynamicScale
 
GlsBool _dynamicScaleIsUnity
 
GlsVector3D _dynamicTranslation
 
GlsBool _needCalcDrawMatrix
 
GlsBool _visible
 
PickMode _pickMode
 
GlsBool _windowPickRegionValid
 
GlsVector2D _windowPickLowerLeft
 
GlsVector2D _windowPickUpperRight
 
GlsVector2D _windowPickUpperLeft
 
GlsVector2D _windowPickLowerRight
 
GlsMatrixAffineD::GLMatrixAffineF _pickMatrix
 
GlsDisplayObject_parent
 

Static Protected Attributes

static const GLclampf ALPHA_MODE_2_LEVEL_REF
 

Additional Inherited Members

- Public Types inherited from GlsDisplayObject
enum  ObjectType { OBJECT_TYPE_COMPOSITE, OBJECT_TYPE_RENDERABLE }
 
enum  PickMode { PICK_MODE_NEVER, PICK_MODE_FIRST, PICK_MODE_ALWAYS }
 

Detailed Description

Defines an abstract class for a display object that is directly rendered to OpenGL (not a composite of other objects) and maintains its own draw settings

Invariant
base class invariant holds, _texturePalette.Invariant(); GlsTextureMapModeIsValid( _textureMapMode ), GlsTextureFilterModeIsValid( _textureMagFilterMode ), GlsTextureFilterModeIsValid( _textureMinFilterMode ), GlsDepthBufferModeIsValid( _depthBufferMode ), GlsPolygonEndModeIsValid( _polygonEndMode ), GlsAlphaModeIsValid( _alphaMode ), _lineColor.IsValid(), ( GlsTexturePalette::NO_TEXTURE == _textureIndex ) || ( _textureIndex < _texturePalette.GetSize() ), GlsPolygonModeIsValid( _polygonMode ), GlsShadingModeIsValid( _shadingMode ), _fillColor.IsValid(), GlsLineWidthIsValid( _lineWidth )

Constructor & Destructor Documentation

GlsRenderObject::GlsRenderObject ( const InitParameters initParameters,
GlsEventDispatcher *const  eventDispatcher 
)
protected

Construct with given initialization parameters

Parameters
initParametersinitialization parameters
eventDispatcherevent dispatcher for this object else GLS_NULL
Precondition
initParameters.IsValid()
Postcondition
object constructed
virtual GlsRenderObject::~GlsRenderObject ( )
protectedvirtual

Destructor - shall never be called

Precondition
none
Postcondition
none

Member Function Documentation

GLint GlsRenderObject::GlsTextureFilterModeToGL ( const GlsTextureFilterMode  mode) const
protected

Get the GL texture filter enum for the correspoding GlsTextureFilterMode

Parameters
modeGlsTextureFilterMode in question
Returns
GL texture filer enum for the given GlsTextureFilterMode
Precondition
GlsTextureFilterModeIsValid( mode )
Postcondition
none
virtual void GlsRenderObject::OffsetTexture ( const GlsVector2D offset)
pure virtual

Offset the texture on the object

Parameters
offsetx, y offset for texture
Precondition
offset.IsValid()
Postcondition
offset is added to the texture coordinates

Implemented in GlsText, GlsTriangleMesh, and GlsPolygon.

virtual void GlsRenderObject::SetAlphaMode ( const GlsAlphaMode  alphaMode)
virtual

Set the alpha mode

Parameters
alphaModedesired alpha mode
Precondition
GlsAlphaModeIsValid( alphaMode )
Postcondition
object has new alpha mode

Reimplemented in GlsText.

virtual void GlsRenderObject::SetFillColor ( const GlsColor fillColor)
virtual

Set the fill color

Parameters
fillColordesired fill color
Precondition
fillColor.IsValid()
Postcondition
object has new fill color

Reimplemented in GlsText.

virtual void GlsRenderObject::SetLineColor ( const GlsColor lineColor)
virtual

Set the line color

Parameters
lineColordesired line color
Precondition
lineColor.IsValid()
Postcondition
object has new line color

Reimplemented in GlsText.

virtual void GlsRenderObject::SetLineWidth ( const GlsFloat32  lineWidth)
virtual

Set the line width

Parameters
lineWidthnew line width, GlsRenderObject::LINE_WIDTH_MIN <= lineWidth <= GlsRenderObject::LINE_WIDTH_MAX
Precondition
GlsLineWidthIsValid( lineWidth )
Postcondition
object has new line width

Reimplemented in GlsText.

virtual void GlsRenderObject::SetPolygonMode ( const GlsPolygonMode  polygonMode)
virtual

Set the polygon mode

Parameters
polygonModenew polygon mode
Precondition
GlsPolygonModeIsValid( polygonMode )
Postcondition
object has new polygon mode

Reimplemented in GlsText.

virtual void GlsRenderObject::SetTextureIndex ( const GlsUInt32  textureIndex)
virtual

Set the desired texture index

Parameters
textureIndexdesired texture index into palette else GlsTexturePalette::NO_TEXTURE
Precondition
textureIndex is less than the size of the texture palette, else GlsTexturePalette::NO_TEXTURE, object's texture palette must have a valid texture (not an empty palette entry) at textureIndex if textureIndex != GlsTexturePalette::NO_TEXTURE
Postcondition
object has new texture index or is untextured if textureIndex == GlsTexturePalette::NO_TEXTURE

Reimplemented in GlsText, and GlsTriangleMesh.

void GlsRenderObject::SetupAlpha ( GlsStateManager gl) const
protected

Setup the GL alpha test and blend settings based on the current object settings

Parameters
glGL state manager to setup
Precondition
GlsAlphaModeIsValid( _alphaMode )
Postcondition
GL alpha test and blend settings are set based on current object settings
void GlsRenderObject::SetupAntiAlias ( GlsStateManager gl) const
protected

Setup GL with the proper antialias settings based on the current object settings

Parameters
glGL state manager to setup
Precondition
none
Postcondition
GL antialias settings are setup based on the current object settings
void GlsRenderObject::SetupBackfaceCulling ( GlsStateManager gl) const
protected

Setup GL with the proper backface culling mode based on the current object settings

Parameters
glGL state manager to setup
Precondition
none
Postcondition
GL backface culling mode is setup based on the current object settings
void GlsRenderObject::SetupDepthTest ( GlsStateManager gl) const
protected

Setup the GL depth settings based on current object settings

Parameters
glGL state manager to setup
Precondition
GlsDepthBufferModeIsValid( _depthBufferMode )
Postcondition
GL depth settings are set based on current object settings
void GlsRenderObject::SetupLineStyle ( GlsStateManager gl) const
protected

Setup GL with the proper line style settings based on the current object settings

Parameters
glGL state manager to setup
Precondition
GlsLineWidthIsValid( _lineWidth )
Postcondition
GL line style settings are setup based on the current object settings
void GlsRenderObject::SetupShading ( GlsStateManager gl) const
protected

Setup GL with the proper shading settings based on the current object settings

Parameters
glGL state manager to setup
Precondition
GlsShadingModeIsValid( _shadingMode )
Postcondition
GL shading settings are setup based on the current object settings
GlsBool GlsRenderObject::SetupTexture ( GlsStateManager gl,
const GlsUInt32  textureIndex 
) const
protected

Setup GL with the proper texture binding and parameters as indicated by the current object settings and the given texture index

Parameters
glGL state manager to setup
textureIndexindex of texture to setup
Returns
GLS_TRUE if this object has a texture else GLS_FALSE
Precondition
( textureIndex == GlsTexturePalette::NO_TEXTURE ) else ( textureIndex < _texturePalette.GetSize() and _texturePalette does not have an empty slot at textureIndex ), GlsTextureMapModeIsValid( _textureMapMode ), GlsTextureFilterModeIsValid( _textureMagFilterMode ), GlsTextureFilterModeIsValid( _textureMinFilterMode ),
Postcondition
GL texture binding and parameters are setup as indicated by the current object settings
void GlsRenderObject::SetupTextureFilterSettings ( GlsStateManager gl) const
protected

Setup GL with the proper texture filter settings based on the current object settings.

Parameters
glGL state manager to setup
Precondition
GlsTextureFilterModeIsValid( _textureMagFilterMode ), GlsTextureFilterModeIsValid( _textureMinFilterMode )
Postcondition
GL texture filter settings are setup based on the current object settings

Member Data Documentation

GlsAlphaMode GlsRenderObject::_alphaMode
protected

alpha mode

const GlsBool GlsRenderObject::_antiAlias
protected

GLS_TRUE if antialiasing is enabled else GLS_FALSE

const GlsBool GlsRenderObject::_cullBackFace
protected

GLS_TRUE if backface culling is enabled else GLS_FALSE

const GlsDepthBufferMode GlsRenderObject::_depthBufferMode
protected

depth buffer test / write mode

GlsColor GlsRenderObject::_fillColor
protected

fill color

GlsColor GlsRenderObject::_lineColor
protected

line color

GlsFloat32 GlsRenderObject::_lineWidth
protected

line width in pixels, GlsRenderObject::LINE_WIDTH_MIN <= lineWidth <= GlsRenderObject::LINE_WIDTH_MAX

const GlsPolygonEndMode GlsRenderObject::_polygonEndMode
protected

Polygon close mode

GlsPolygonMode GlsRenderObject::_polygonMode
protected

polygon mode

const GlsShadingMode GlsRenderObject::_shadingMode
protected

shading mode

GlsUInt32 GlsRenderObject::_textureIndex
protected

texture index into palette else GlsTexturePalette::NO_TEXTURE

const GlsTextureFilterMode GlsRenderObject::_textureMagFilterMode
protected

texture magnification filter mode

const GlsTextureMapMode GlsRenderObject::_textureMapMode
protected

texture mapping mode

const GlsTextureFilterMode GlsRenderObject::_textureMinFilterMode
protected

texture minification filter mode

const GlsTexturePalette& GlsRenderObject::_texturePalette
protected

palette with textures available to object

const GlsBool GlsRenderObject::_textureRepeat
protected

GLS_TRUE to enable texture repeat else GLS_FALSE for texture clamp

const GLclampf GlsRenderObject::ALPHA_MODE_2_LEVEL_REF
staticprotected

alpha function reference value when in 2 level alpha mode