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

#include <GlslRenderer.h>

+ Inheritance diagram for GlslRenderer:

Public Member Functions

ImageHandlerPtr createImageHandler (ImageLoaderPtr imageLoader)
 Create a texture handler for OpenGL textures. More...
 
virtual ~GlslRenderer ()
 Destructor. More...
 
Setup
void initialize (RenderContextHandle renderContextHandle=nullptr) override
 
Rendering
void createProgram (ShaderPtr shader) override
 
void createProgram (const StageMap &stages) override
 
void validateInputs () override
 Validate inputs for the program. More...
 
void updateUniform (const string &name, ConstValuePtr value) override
 Update the program with value of the uniform. More...
 
void setSize (unsigned int width, unsigned int height) override
 Set the size of the rendered image. More...
 
void render () override
 Render the current program to an offscreen buffer. More...
 
void renderTextureSpace (const Vector2 &uvMin, const Vector2 &uvMax)
 Render the current program in texture space to an off-screen buffer. More...
 
Utilities
ImagePtr captureImage (ImagePtr image=nullptr) override
 Capture the current contents of the off-screen hardware buffer as an image. More...
 
GLFramebufferPtr getFramebuffer () const
 Return the GL frame buffer. More...
 
GlslProgramPtr getProgram ()
 Return the GLSL program. More...
 
void drawScreenSpaceQuad (const Vector2 &uvMin=Vector2(0.0f), const Vector2 &uvMax=Vector2(1.0f))
 Submit geometry for a screen-space quad. More...
 
void setScreenColor (const Color3 &screenColor)
 Set the screen background color. More...
 
Color3 getScreenColor () const
 Return the screen background color. More...
 
- Public Member Functions inherited from ShaderRenderer
virtual ~ShaderRenderer ()
 
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...
 

Static Public Member Functions

static GlslRendererPtr create (unsigned int width=512, unsigned int height=512, Image::BaseType baseType=Image::BaseType::UINT8)
 Create a GLSL renderer instance. More...
 

Protected Member Functions

 GlslRenderer (unsigned int width, unsigned int height, Image::BaseType baseType)
 
- Protected Member Functions inherited from ShaderRenderer
 ShaderRenderer (unsigned int width, unsigned int height, Image::BaseType baseType, MatrixConvention matrixConvention=MatrixConvention::OpenGL)
 

Additional Inherited Members

- Public Types inherited from ShaderRenderer
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...
 
- Protected Attributes inherited from ShaderRenderer
unsigned int _width
 
unsigned int _height
 
Image::BaseType _baseType
 
MatrixConvention _matrixConvention
 
CameraPtr _camera
 
ImageHandlerPtr _imageHandler
 
GeometryHandlerPtr _geometryHandler
 
LightHandlerPtr _lightHandler
 

Detailed Description

Helper class for rendering generated GLSL code to produce images.

There are two main interfaces which can be used. One which takes in a HwShader and one which allows for explicit setting of shader stage code.

The main services provided are:

  • Validation: All shader stages are compiled and atteched to a GLSL shader program.
  • Introspection: The compiled shader program is examined for uniforms and attributes.
  • Binding: Uniforms and attributes which match the predefined variables generated the GLSL code generator will have values assigned to this. This includes matrices, attribute streams, and textures.
  • Rendering: The program with bound inputs will be used to drawing geometry to an offscreen buffer. An interface is provided to save this offscreen buffer to disk using an externally defined image handler.

Definition at line 42 of file GlslRenderer.h.

Constructor & Destructor Documentation

virtual GlslRenderer::~GlslRenderer ( )
inlinevirtual

Destructor.

Definition at line 55 of file GlslRenderer.h.

GlslRenderer::GlslRenderer ( unsigned int  width,
unsigned int  height,
Image::BaseType  baseType 
)
protected

Member Function Documentation

ImagePtr GlslRenderer::captureImage ( ImagePtr  image = nullptr)
overridevirtual

Capture the current contents of the off-screen hardware buffer as an image.

Reimplemented from ShaderRenderer.

static GlslRendererPtr GlslRenderer::create ( unsigned int  width = 512,
unsigned int  height = 512,
Image::BaseType  baseType = Image::BaseType::UINT8 
)
static

Create a GLSL renderer instance.

ImageHandlerPtr GlslRenderer::createImageHandler ( ImageLoaderPtr  imageLoader)
inline

Create a texture handler for OpenGL textures.

Definition at line 49 of file GlslRenderer.h.

void GlslRenderer::createProgram ( ShaderPtr  shader)
overridevirtual

Create GLSL program based on an input shader

Parameters
shaderInput HwShader

Reimplemented from ShaderRenderer.

void GlslRenderer::createProgram ( const StageMap stages)
overridevirtual

Create GLSL program based on shader stage source code.

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

Reimplemented from ShaderRenderer.

void GlslRenderer::drawScreenSpaceQuad ( const Vector2 uvMin = Vector2(0.0f),
const Vector2 uvMax = Vector2(1.0f) 
)

Submit geometry for a screen-space quad.

GLFramebufferPtr GlslRenderer::getFramebuffer ( ) const
inline

Return the GL frame buffer.

Definition at line 102 of file GlslRenderer.h.

GlslProgramPtr GlslRenderer::getProgram ( )
inline

Return the GLSL program.

Definition at line 108 of file GlslRenderer.h.

Color3 GlslRenderer::getScreenColor ( ) const
inline

Return the screen background color.

Definition at line 123 of file GlslRenderer.h.

void GlslRenderer::initialize ( RenderContextHandle  renderContextHandle = nullptr)
overridevirtual

Internal initialization of stages and OpenGL constructs required for program validation and rendering. An exception is thrown on failure. The exception will contain a list of initialization errors.

Parameters
renderContextHandleallows initializing the GlslRenderer with a Shared OpenGL Context

Reimplemented from ShaderRenderer.

void GlslRenderer::render ( )
overridevirtual

Render the current program to an offscreen buffer.

Reimplemented from ShaderRenderer.

void GlslRenderer::renderTextureSpace ( const Vector2 uvMin,
const Vector2 uvMax 
)

Render the current program in texture space to an off-screen buffer.

void GlslRenderer::setScreenColor ( const Color3 screenColor)
inline

Set the screen background color.

Definition at line 117 of file GlslRenderer.h.

void GlslRenderer::setSize ( unsigned int  width,
unsigned int  height 
)
overridevirtual

Set the size of the rendered image.

Reimplemented from ShaderRenderer.

void GlslRenderer::updateUniform ( const string name,
ConstValuePtr  value 
)
overridevirtual

Update the program with value of the uniform.

Reimplemented from ShaderRenderer.

void GlslRenderer::validateInputs ( )
overridevirtual

Validate inputs for the program.

Reimplemented from ShaderRenderer.


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