Cafu Engine
MatSys::RendererI Class Referenceabstract

This class provides an interface to a renderer. More...

#include "Renderer.hpp"

Inheritance diagram for MatSys::RendererI:

Public Types

enum  RenderActionT { AMBIENT, STENCILSHADOW, LIGHTING }
 
enum  MatrixNameT { MODEL_TO_WORLD, WORLD_TO_VIEW, PROJECTION, END_MARKER }
 
enum  PickingRenderModeT { RENDER, SELECT, FEEDBACK }
 

Public Member Functions

virtual bool IsSupported () const =0
 Returns true if this renderer is supported on this system (e.g. More...
 
virtual bool DoesSupportCompressedSHL () const =0
 Returns true if this renderer supports SHL rendering with compressed (indexed) SHLMaps, false otherwise. More...
 
virtual bool DoesSupportUncompressedSHL () const =0
 Returns true if this renderer supports SHL rendering with uncompressed SHLMaps (four coefficients per SHLMap), false otherwise. More...
 
virtual int GetPreferenceNr () const =0
 Returns a "global" preference number for this renderer. More...
 
virtual void Initialize ()=0
 Call this after a successful call to IsSupported() in order to prepare the renderer for use. More...
 
virtual void Release ()=0
 Call this in order to release this renderer. More...
 
virtual const char * GetDescription () const =0
 Returns a description of this renderer, e.g. More...
 
virtual MatSys::RenderMaterialTRegisterMaterial (const MaterialT *Material) const =0
 Registers the Material with the renderer, and returns a handle for future reference. More...
 
virtual const MaterialTGetMaterialFromRM (MatSys::RenderMaterialT *RenderMaterial) const =0
 Returns the MaterialT object that was used in RegisterMaterial() to create the RenderMaterial. More...
 
virtual unsigned long GetAmbientShaderIDFromRM (MatSys::RenderMaterialT *RenderMaterial) const =0
 Returns the ID of the ambient shader of the RenderMaterial. More...
 
virtual unsigned long GetLightShaderIDFromRM (MatSys::RenderMaterialT *RenderMaterial) const =0
 Returns the ID of the light shader of the RenderMaterial. More...
 
virtual void FreeMaterial (MatSys::RenderMaterialT *RenderMaterial)=0
 Used to free the previously registered (render-)material. More...
 
virtual void BeginFrame (double Time)=0
 Call this to begin rendering a new frame. More...
 
virtual void EndFrame ()=0
 Call this to end the current frame. More...
 
virtual void PreCache ()=0
 This function pre-caches all textures of all materials that have been registered with RegisterMaterial() so far. More...
 
virtual void SetCurrentRenderAction (RenderActionT RA)=0
 This activates a specific render action, as is required for multi-pass rendering with dynamic lights and stencil shadows. More...
 
virtual RenderActionT GetCurrentRenderAction () const =0
 Returns the currently set render action. More...
 
virtual void SetGenPurposeRenderingParam (unsigned long Index, float Value)=0
 
virtual void SetGenPurposeRenderingParam (unsigned long Index, int Value)=0
 
virtual float GetGenPurposeRenderingParamF (unsigned long Index) const =0
 
virtual int GetGenPurposeRenderingParamI (unsigned long Index) const =0
 
virtual void SetCurrentAmbientLightColor (float r, float g, float b)=0
 
virtual float * GetCurrentAmbientLightColor ()=0
 
virtual const float * GetCurrentAmbientLightColor () const =0
 
virtual void SetCurrentLightSourcePosition (float x, float y, float z)=0
 
virtual float * GetCurrentLightSourcePosition ()=0
 
virtual const float * GetCurrentLightSourcePosition () const =0
 
virtual void SetCurrentLightSourceRadius (float r)=0
 
virtual float & GetCurrentLightSourceRadius ()=0
 
virtual const float & GetCurrentLightSourceRadius () const =0
 
virtual void SetCurrentLightSourceDiffuseColor (float r, float g, float b)=0
 
virtual float * GetCurrentLightSourceDiffuseColor ()=0
 
virtual const float * GetCurrentLightSourceDiffuseColor () const =0
 
virtual void SetCurrentLightSourceSpecularColor (float r, float g, float b)=0
 
virtual float * GetCurrentLightSourceSpecularColor ()=0
 
virtual const float * GetCurrentLightSourceSpecularColor () const =0
 
virtual void SetCurrentEyePosition (float x, float y, float z)=0
 
virtual float * GetCurrentEyePosition ()=0
 
virtual const float * GetCurrentEyePosition () const =0
 
virtual void PushLightingParameters ()=0
 Pushes all lighting parameters onto a stack. More...
 
virtual void PopLightingParameters ()=0
 Pops (restores) the lighting parameters that have previously been pushed onto the stack. More...
 
virtual void ClearColor (float r, float g, float b, float a)=0
 
virtual void Flush ()=0
 
virtual const Matrix4x4fTGetMatrix (MatrixNameT MN) const =0
 
virtual const Matrix4x4fTGetMatrixInv (MatrixNameT MN) const =0
 
virtual const Matrix4x4fTGetMatrixModelView () const =0
 
virtual void SetMatrix (MatrixNameT MN, const Matrix4x4fT &Matrix)=0
 
virtual void Translate (MatrixNameT MN, float x, float y, float z)=0
 
virtual void Scale (MatrixNameT MN, float scale)=0
 
virtual void RotateX (MatrixNameT MN, float angle)=0
 
virtual void RotateY (MatrixNameT MN, float angle)=0
 
virtual void RotateZ (MatrixNameT MN, float angle)=0
 
virtual void PushMatrix (MatrixNameT MN)=0
 
virtual void PopMatrix (MatrixNameT MN)=0
 
virtual void SetViewport (int x, int y, int width, int height)=0
 
virtual void GetViewport (int viewport[4])=0
 
virtual void SetSelectionBuffer (unsigned long Size, unsigned int *Buffer)=0
 
virtual unsigned long SetPickingRenderMode (PickingRenderModeT PRM)=0
 
virtual void InitNameStack ()=0
 
virtual void LoadName (unsigned long Name)=0
 
virtual void PushName (unsigned long Name)=0
 
virtual void PopName ()=0
 
virtual void SetCurrentMaterial (MatSys::RenderMaterialT *RenderMaterial)=0
 
virtual MatSys::RenderMaterialTGetCurrentMaterial () const =0
 
virtual void LockCurrentMaterial (bool LockCM_)=0
 
virtual void SetCurrentLightMap (TextureMapI *LightMap)=0
 
virtual void SetCurrentLightDirMap (TextureMapI *LightDirMap)=0
 
virtual void SetCurrentSHLMaps (const ArrayT< TextureMapI * > &SHLMaps)=0
 
virtual void SetCurrentSHLLookupMap (TextureMapI *SHLLookupMap)=0
 
virtual void RenderMesh (const MatSys::MeshT &Mesh)=0
 
virtual ~RendererI ()
 This ABC does neither have nor need a destructor, because no implementation will ever be deleted via a pointer to a RendererI. More...
 

Detailed Description

This class provides an interface to a renderer.

The interface is specified as ABC in order to share the renderer across exe/dll boundaries.

Constructor & Destructor Documentation

virtual MatSys::RendererI::~RendererI ( )
inlinevirtual

This ABC does neither have nor need a destructor, because no implementation will ever be deleted via a pointer to a RendererI.

(The implementations are singletons after all.) See the Singleton pattern and the C++ FAQ 21.05 (the "precise rule") for more information. g++ however issues a warning with no such destructor, so I provide one anyway and am safe.

Member Function Documentation

virtual void MatSys::RendererI::BeginFrame ( double  Time)
pure virtual

Call this to begin rendering a new frame.

This function typically clears the screen and calls other implementation specific functions to start a new frame. Time is the global time in seconds at which this frame starts.

Implemented in RendererImplT.

virtual bool MatSys::RendererI::DoesSupportCompressedSHL ( ) const
pure virtual

Returns true if this renderer supports SHL rendering with compressed (indexed) SHLMaps, false otherwise.

Implemented in RendererImplT.

virtual bool MatSys::RendererI::DoesSupportUncompressedSHL ( ) const
pure virtual

Returns true if this renderer supports SHL rendering with uncompressed SHLMaps (four coefficients per SHLMap), false otherwise.

Implemented in RendererImplT.

virtual void MatSys::RendererI::EndFrame ( )
pure virtual

Call this to end the current frame.

This function typically calls functions like SwapBuffers() and other implementation specific functions to end a frame.

Implemented in RendererImplT.

virtual void MatSys::RendererI::FreeMaterial ( MatSys::RenderMaterialT RenderMaterial)
pure virtual

Used to free the previously registered (render-)material.

If RenderMaterial happens to be the currently used material, SetCurrentMaterial(NULL) is automatically called before RenderMaterial is deleted.

Implemented in RendererImplT.

virtual unsigned long MatSys::RendererI::GetAmbientShaderIDFromRM ( MatSys::RenderMaterialT RenderMaterial) const
pure virtual

Returns the ID of the ambient shader of the RenderMaterial.

This number can be used by the calling code in order to adjust the draw order (for the AMBIENT render action). It is guaranteed that the returned value is reasonably small, that is, not greater than the number of shaders that are employed in this renderer.

Implemented in RendererImplT.

virtual RenderActionT MatSys::RendererI::GetCurrentRenderAction ( ) const
pure virtual

Returns the currently set render action.

Implemented in RendererImplT.

virtual const char* MatSys::RendererI::GetDescription ( ) const
pure virtual

Returns a description of this renderer, e.g.

for informing the users about the underlying technique (OpenGL, DirectX, ...), the capabilities, or details about the implementation.

Implemented in RendererImplT.

virtual unsigned long MatSys::RendererI::GetLightShaderIDFromRM ( MatSys::RenderMaterialT RenderMaterial) const
pure virtual

Returns the ID of the light shader of the RenderMaterial.

This number can be used by the calling code in order to adjust the draw order (for the LIGHTING render action). It is guaranteed that the returned value is reasonably small, that is, not greater than the number of shaders that are employed in this renderer.

Implemented in RendererImplT.

virtual const MaterialT* MatSys::RendererI::GetMaterialFromRM ( MatSys::RenderMaterialT RenderMaterial) const
pure virtual

Returns the MaterialT object that was used in RegisterMaterial() to create the RenderMaterial.

Implemented in RendererImplT.

virtual int MatSys::RendererI::GetPreferenceNr ( ) const
pure virtual

Returns a "global" preference number for this renderer.

This helps the caller code the select the "best" or "most preferred" renderer among many.

Implemented in RendererImplT.

virtual void MatSys::RendererI::Initialize ( )
pure virtual

Call this after a successful call to IsSupported() in order to prepare the renderer for use.

Implemented in RendererImplT.

virtual bool MatSys::RendererI::IsSupported ( ) const
pure virtual

Returns true if this renderer is supported on this system (e.g.

required OpenGL extensions are present, version of DirectX matches, ...), and returns false otherwise. This function must not be called before the underlying video environment (i.e. the OpenGL rendering context) has been initialized. No preceeding call to Initialize() is required, and the environment is left as clean as it was found, such that no subsequent actions (i.e. calls to this function of other renderers) get into trouble.

Implemented in RendererImplT.

virtual void MatSys::RendererI::PopLightingParameters ( )
pure virtual

Pops (restores) the lighting parameters that have previously been pushed onto the stack.

Nothing happens if the stack is empty.

Implemented in RendererImplT.

virtual void MatSys::RendererI::PreCache ( )
pure virtual

This function pre-caches all textures of all materials that have been registered with RegisterMaterial() so far.

As a result, the delay that otherwise occurs when new textures are first used for rendering is minimized.

Implemented in RendererImplT.

virtual void MatSys::RendererI::PushLightingParameters ( )
pure virtual

Pushes all lighting parameters onto a stack.

The depth of the stack is only limited by available memory. The following parameters are covered: Light source position and radius, light source diffuse and specular color, and the eye position. The ambient light color is currently NOT covered.

Implemented in RendererImplT.

virtual MatSys::RenderMaterialT* MatSys::RendererI::RegisterMaterial ( const MaterialT Material) const
pure virtual

Registers the Material with the renderer, and returns a handle for future reference.

NULL can be passed for Material, in which case a "null" handle will be returned, which is nonetheless valid (but just won't cause any rendering output later).

Implemented in RendererImplT.

virtual void MatSys::RendererI::Release ( )
pure virtual

Call this in order to release this renderer.

Implemented in RendererImplT.

virtual void MatSys::RendererI::SetCurrentRenderAction ( RenderActionT  RA)
pure virtual

This activates a specific render action, as is required for multi-pass rendering with dynamic lights and stencil shadows.

Rendering geometry will only consider those parts of the materials that are relevant for their currently set action.

Implemented in RendererImplT.


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