MaterialX 1.39.1
|
Helper class for rendering generated GLSL code to produce images. More...
#include <GlslRenderer.h>
Public Member Functions | |
ImageHandlerPtr | createImageHandler (ImageLoaderPtr imageLoader) |
Create a texture handler for OpenGL textures. | |
virtual | ~GlslRenderer () |
Destructor. | |
Setup | |
void | initialize (RenderContextHandle renderContextHandle=nullptr) override |
Internal initialization of stages and OpenGL constructs required for program validation and rendering. More... | |
Rendering | |
void | createProgram (ShaderPtr shader) override |
Create GLSL program based on an input shader. More... | |
void | createProgram (const StageMap &stages) override |
Create GLSL program based on shader stage source code. More... | |
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. | |
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. | |
GlslProgramPtr | getProgram () |
Return the GLSL program. | |
void | drawScreenSpaceQuad (const Vector2 &uvMin=Vector2(0.0f), const Vector2 &uvMax=Vector2(1.0f)) |
Submit geometry for a screen-space quad. | |
void | setScreenColor (const Color3 &screenColor) |
Set the screen background color. | |
Color3 | getScreenColor () const |
Return the screen background color. | |
Public Member Functions inherited from ShaderRenderer | |
void | setCamera (CameraPtr camera) |
Set the camera. | |
CameraPtr | getCamera () const |
Return the camera. | |
void | setImageHandler (ImageHandlerPtr imageHandler) |
Set the image handler used by this renderer for image I/O. | |
ImageHandlerPtr | getImageHandler () const |
Return the image handler. | |
void | setLightHandler (LightHandlerPtr lightHandler) |
Set the light handler used by this renderer for light bindings. | |
LightHandlerPtr | getLightHandler () const |
Return the light handler. | |
void | setGeometryHandler (GeometryHandlerPtr geometryHandler) |
Set the geometry handler. | |
GeometryHandlerPtr | getGeometryHandler () const |
Return the geometry handler. | |
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. | |
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 class | MatrixConvention { OpenGL = 0 , Metal = 1 } |
Viewing API matrix conventions designation (default to OpenGL). | |
using | StageMap = StringMap |
A map with name and source code for each shader stage. | |
Protected Attributes inherited from ShaderRenderer | |
unsigned int | _width |
unsigned int | _height |
Image::BaseType | _baseType |
MatrixConvention | _matrixConvention |
CameraPtr | _camera |
ImageHandlerPtr | _imageHandler |
GeometryHandlerPtr | _geometryHandler |
LightHandlerPtr | _lightHandler |
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:
Capture the current contents of the off-screen hardware buffer as an image.
Reimplemented from ShaderRenderer.
|
overridevirtual |
Create GLSL program based on shader stage source code.
stages | Map of name and source code for the shader stages. |
Reimplemented from ShaderRenderer.
|
overridevirtual |
Create GLSL program based on an input shader.
shader | Input HwShader |
Reimplemented from ShaderRenderer.
|
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.
renderContextHandle | allows initializing the GlslRenderer with a Shared OpenGL Context |
Reimplemented from ShaderRenderer.
|
overridevirtual |
Render the current program to an offscreen buffer.
Reimplemented from ShaderRenderer.
|
overridevirtual |
Set the size of the rendered image.
Reimplemented from ShaderRenderer.
|
overridevirtual |
Update the program with value of the uniform.
Reimplemented from ShaderRenderer.
|
overridevirtual |
Validate inputs for the program.
Reimplemented from ShaderRenderer.