Loading...
Searching...
No Matches
irr::video::IShaderConstantSetCallBack Class Referenceabstract

Interface making it possible to set constants for gpu programs every frame. More...

`#include <IShaderConstantSetCallBack.h>`

Inheritance diagram for irr::video::IShaderConstantSetCallBack:

## Public Member Functions

virtual void | OnSetConstants (IMaterialRendererServices *services, s32 userData)=0
| Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set.
virtual void | OnSetMaterial (const SMaterial &material)
| Called to let the callBack know the used material (optional method).
Public Member Functions inherited from irr::IReferenceCounted
| IReferenceCounted ()
| Constructor.
virtual | ~IReferenceCounted ()
| Destructor.
bool | drop () const
| Drops the object. Decrements the reference counter by one.
const c8 * | getDebugName () const
| Returns the debug name of the object.
s32 | getReferenceCount () const
| Get the reference count.
void | grab () const
| Grabs the object. Increments the reference counter by one.

## Additional Inherited Members

Protected Member Functions inherited from irr::IReferenceCounted
void | setDebugName (const c8 *newName)
| Sets the debug name of the object.

## Detailed Description

Interface making it possible to set constants for gpu programs every frame.

Implement this interface in an own class and pass a pointer to it to one of the methods in IGPUProgrammingServices when creating a shader. The OnSetConstants method will be called every frame now.

Definition at line 21 of file IShaderConstantSetCallBack.h.

## Member Function Documentation

## OnSetConstants()

virtual void irr::video::IShaderConstantSetCallBack::OnSetConstants | ( | IMaterialRendererServices * | services,
|  | s32 | userData )

pure virtual

Called by the engine when the vertex and/or pixel shader constants for an material renderer should be set.

Implement the IShaderConstantSetCallBack in an own class and implement your own OnSetConstants method using the given IMaterialRendererServices interface. Pass a pointer to this class to one of the methods in IGPUProgrammingServices when creating a shader. The OnSetConstants method will now be called every time before geometry is being drawn using your shader material. A sample implementation would look like this:

virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
video::IVideoDriver* driver = services->getVideoDriver();
// set clip matrix at register 4
core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
worldViewProj *= driver->getTransform(video::ETS_VIEW);
worldViewProj *= driver->getTransform(video::ETS_WORLD);
services->setVertexShaderConstant(&worldViewProj.M[0], 4, 4);
// for high level shading languages, this would be another solution:
//services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16);
// set some light color at register 9
video::SColorf col(0.0f,1.0f,1.0f,0.0f);
services->setVertexShaderConstant(reinterpret_cast<const f32*>(&col), 9, 1);
// for high level shading languages, this would be another solution:
//services->setVertexShaderConstant("myColor", reinterpret_cast<f32*>(&col), 4);
}
irr::video::IMaterialRendererServices
Interface providing some methods for changing advanced, internal states of a IVideoDriver.
Definition IMaterialRendererServices.h:21
irr::video::IMaterialRendererServices::setVertexShaderConstant
virtual bool setVertexShaderConstant(const c8 *name, const f32 *floats, int count)=0
Sets a constant for the vertex shader based on a name.
irr::video::IMaterialRendererServices::getVideoDriver
virtual IVideoDriver * getVideoDriver()=0
Get pointer to the IVideoDriver interface.
irr::video::IShaderConstantSetCallBack::OnSetConstants
virtual void OnSetConstants(IMaterialRendererServices *services, s32 userData)=0
Called by the engine when the vertex and/or pixel shader constants for an material renderer should be...
irr::video::IVideoDriver
Interface to driver which is able to perform 2d and 3d graphics functions.
Definition IVideoDriver.h:257
irr::video::IVideoDriver::getTransform
virtual const core::matrix4 & getTransform(E_TRANSFORMATION_STATE state) const =0
Returns the transformation set by setTransform.
irr::video::SColorf
Class representing a color with four floats.
Definition SColor.h:459
irr::core::matrix4
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2235
irr::video::ETS_VIEW
@ ETS_VIEW
View transformation.
Definition IVideoDriver.h:55
irr::video::ETS_WORLD
@ ETS_WORLD
World transformation.
Definition IVideoDriver.h:57
irr::video::ETS_PROJECTION
@ ETS_PROJECTION
Projection transformation.
Definition IVideoDriver.h:59
irr::f32
float f32
32 bit floating point variable.
Definition irrTypes.h:104
irr::s32
signed int s32
32 bit signed variable.
Definition irrTypes.h:66

Parameters

  services | Pointer to an interface providing methods to set the constants for the shader.
  userData | Userdata int which can be specified when creating the shader.

## OnSetMaterial()

virtual void irr::video::IShaderConstantSetCallBack::OnSetMaterial | ( | const SMaterial & | material | ) |

inline virtual

Called to let the callBack know the used material (optional method).

class MyCallBack : public IShaderConstantSetCallBack
{
const video::SMaterial *UsedMaterial;
OnSetMaterial(const video::SMaterial& material)
{
UsedMaterial=&material;
}
OnSetConstants(IMaterialRendererServices* services, s32 userData)
{
services->setVertexShaderConstant("myColor", reinterpret_cast<f32*>(&UsedMaterial->color), 4);
}
}
irr::video::IShaderConstantSetCallBack
Interface making it possible to set constants for gpu programs every frame.
Definition IShaderConstantSetCallBack.h:22
irr::video::IShaderConstantSetCallBack::OnSetMaterial
virtual void OnSetMaterial(const SMaterial &material)
Called to let the callBack know the used material (optional method).
Definition IShaderConstantSetCallBack.h:44
irr::video::SMaterial
Struct for holding parameters for a material renderer.
Definition SMaterial.h:227

Definition at line 44 of file IShaderConstantSetCallBack.h.

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

- IShaderConstantSetCallBack.h

- Irrlicht Engine Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on for Irrlicht 3D Engine by Doxygen 1.15.0