HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShaderRenderer Class Reference

#include <ShaderRenderer.h>

+ Inheritance diagram for ShaderRenderer:

Public Types

enum  MatrixConvention { MatrixConvention::OpenGL = 0, MatrixConvention::Metal = 1 }
 Viewing API matrix conventions designation (default to OpenGL). More...
 
using StageMap = StringMap
 A map with name and source code for each shader stage. More...
 

Public Member Functions

virtual ~ShaderRenderer ()
 
Setup
virtual void initialize (RenderContextHandle=nullptr)
 Initialize the renderer. More...
 
void setCamera (CameraPtr camera)
 Set the camera. More...
 
CameraPtr getCamera () const
 Return the camera. More...
 
void setImageHandler (ImageHandlerPtr imageHandler)
 Set the image handler used by this renderer for image I/O. More...
 
ImageHandlerPtr getImageHandler () const
 Return the image handler. More...
 
void setLightHandler (LightHandlerPtr lightHandler)
 Set the light handler used by this renderer for light bindings. More...
 
LightHandlerPtr getLightHandler () const
 Return the light handler. More...
 
void setGeometryHandler (GeometryHandlerPtr geometryHandler)
 Set the geometry handler. More...
 
GeometryHandlerPtr getGeometryHandler () const
 Return the geometry handler. More...
 
Rendering
virtual void createProgram (ShaderPtr shader)
 Create program based on an input shader. More...
 
virtual void createProgram (const StageMap &stages)
 
virtual void validateInputs ()
 Validate inputs for the program. More...
 
virtual void updateUniform (const string &name, ConstValuePtr value)
 Update the program with value of the uniform. More...
 
virtual void setSize (unsigned int width, unsigned int height)
 Set the size of the rendered image. More...
 
virtual void render ()
 Render the current program to produce an image. More...
 
Utilities
virtual ImagePtr captureImage (ImagePtr image=nullptr)
 Capture the current rendered output as an image. More...
 

Protected Member Functions

 ShaderRenderer (unsigned int width, unsigned int height, Image::BaseType baseType, MatrixConvention matrixConvention=MatrixConvention::OpenGL)
 

Protected Attributes

unsigned int _width
 
unsigned int _height
 
Image::BaseType _baseType
 
MatrixConvention _matrixConvention
 
CameraPtr _camera
 
ImageHandlerPtr _imageHandler
 
GeometryHandlerPtr _geometryHandler
 
LightHandlerPtr _lightHandler
 

Detailed Description

Base class for renderers that generate shader code to produce images.

Definition at line 30 of file ShaderRenderer.h.

Member Typedef Documentation

A map with name and source code for each shader stage.

Definition at line 40 of file ShaderRenderer.h.

Member Enumeration Documentation

Viewing API matrix conventions designation (default to OpenGL).

Enumerator
OpenGL 
Metal 

Definition at line 34 of file ShaderRenderer.h.

Constructor & Destructor Documentation

virtual ShaderRenderer::~ShaderRenderer ( )
inlinevirtual

Definition at line 43 of file ShaderRenderer.h.

ShaderRenderer::ShaderRenderer ( unsigned int  width,
unsigned int  height,
Image::BaseType  baseType,
MatrixConvention  matrixConvention = MatrixConvention::OpenGL 
)
protected

Member Function Documentation

virtual ImagePtr ShaderRenderer::captureImage ( ImagePtr  image = nullptr)
inlinevirtual

Capture the current rendered output as an image.

Reimplemented in GlslRenderer, and OslRenderer.

Definition at line 127 of file ShaderRenderer.h.

virtual void ShaderRenderer::createProgram ( ShaderPtr  shader)
virtual

Create program based on an input shader.

Reimplemented in GlslRenderer, and OslRenderer.

virtual void ShaderRenderer::createProgram ( const StageMap stages)
virtual

Create program based on shader stage source code.

Parameters
stagesMap of name and source code for the shader stages.

Reimplemented in GlslRenderer, and OslRenderer.

CameraPtr ShaderRenderer::getCamera ( ) const
inline

Return the camera.

Definition at line 58 of file ShaderRenderer.h.

GeometryHandlerPtr ShaderRenderer::getGeometryHandler ( ) const
inline

Return the geometry handler.

Definition at line 94 of file ShaderRenderer.h.

ImageHandlerPtr ShaderRenderer::getImageHandler ( ) const
inline

Return the image handler.

Definition at line 70 of file ShaderRenderer.h.

LightHandlerPtr ShaderRenderer::getLightHandler ( ) const
inline

Return the light handler.

Definition at line 82 of file ShaderRenderer.h.

virtual void ShaderRenderer::initialize ( RenderContextHandle  = nullptr)
inlinevirtual

Initialize the renderer.

Reimplemented in GlslRenderer, and OslRenderer.

Definition at line 49 of file ShaderRenderer.h.

virtual void ShaderRenderer::render ( )
inlinevirtual

Render the current program to produce an image.

Reimplemented in GlslRenderer, and OslRenderer.

Definition at line 120 of file ShaderRenderer.h.

void ShaderRenderer::setCamera ( CameraPtr  camera)
inline

Set the camera.

Definition at line 52 of file ShaderRenderer.h.

void ShaderRenderer::setGeometryHandler ( GeometryHandlerPtr  geometryHandler)
inline

Set the geometry handler.

Definition at line 88 of file ShaderRenderer.h.

void ShaderRenderer::setImageHandler ( ImageHandlerPtr  imageHandler)
inline

Set the image handler used by this renderer for image I/O.

Definition at line 64 of file ShaderRenderer.h.

void ShaderRenderer::setLightHandler ( LightHandlerPtr  lightHandler)
inline

Set the light handler used by this renderer for light bindings.

Definition at line 76 of file ShaderRenderer.h.

virtual void ShaderRenderer::setSize ( unsigned int  width,
unsigned int  height 
)
virtual

Set the size of the rendered image.

Reimplemented in GlslRenderer, and OslRenderer.

virtual void ShaderRenderer::updateUniform ( const string name,
ConstValuePtr  value 
)
virtual

Update the program with value of the uniform.

Reimplemented in GlslRenderer.

virtual void ShaderRenderer::validateInputs ( )
inlinevirtual

Validate inputs for the program.

Reimplemented in GlslRenderer, and OslRenderer.

Definition at line 111 of file ShaderRenderer.h.

Member Data Documentation

Image::BaseType ShaderRenderer::_baseType
protected

Definition at line 141 of file ShaderRenderer.h.

CameraPtr ShaderRenderer::_camera
protected

Definition at line 145 of file ShaderRenderer.h.

GeometryHandlerPtr ShaderRenderer::_geometryHandler
protected

Definition at line 147 of file ShaderRenderer.h.

unsigned int ShaderRenderer::_height
protected

Definition at line 140 of file ShaderRenderer.h.

ImageHandlerPtr ShaderRenderer::_imageHandler
protected

Definition at line 146 of file ShaderRenderer.h.

LightHandlerPtr ShaderRenderer::_lightHandler
protected

Definition at line 148 of file ShaderRenderer.h.

MatrixConvention ShaderRenderer::_matrixConvention
protected

Definition at line 143 of file ShaderRenderer.h.

unsigned int ShaderRenderer::_width
protected

Definition at line 139 of file ShaderRenderer.h.


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