1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__
6
#define __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__
19
//! Interface providing some methods for changing advanced, internal states of a IVideoDriver.
20
class IMaterialRendererServices
25
virtual ~IMaterialRendererServices() {}
27
//! Can be called by an IMaterialRenderer to make its work easier.
28
/** Sets all basic renderstates if needed.
29
Basic render states are diffuse, ambient, specular, and emissive color,
30
specular power, bilinear and trilinear filtering, wireframe mode,
31
grouraudshading, lighting, zbuffer, zwriteenable, backfaceculling and
33
\param material The new material to be used.
34
\param lastMaterial The material used until now.
35
\param resetAllRenderstates Set to true if all renderstates should be
36
set, regardless of their current state. */
37
virtual void setBasicRenderStates(const SMaterial& material,
38
const SMaterial& lastMaterial,
39
bool resetAllRenderstates) = 0;
41
//! Sets a constant for the vertex shader based on a name.
42
/** This can be used if you used a high level shader language like GLSL
43
or HLSL to create a shader. Example: If you created a shader which has
44
variables named 'mWorldViewProj' (containing the WorldViewProjection
45
matrix) and another one named 'fTime' containing one float, you can set
46
them in your IShaderConstantSetCallBack derived class like this:
48
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
50
video::IVideoDriver* driver = services->getVideoDriver();
52
f32 time = (f32)os::Timer::getTime()/100000.0f;
53
services->setVertexShaderConstant("fTime", &time, 1);
55
core::matrix4 worldViewProj(driver->getTransform(video::ETS_PROJECTION));
56
worldViewProj *= driver->getTransform(video::ETS_VIEW);
57
worldViewProj *= driver->getTransform(video::ETS_WORLD);
58
services->setVertexShaderConstant("mWorldViewProj", worldViewProj.M, 16);
61
\param name Name of the variable
62
\param floats Pointer to array of floats
63
\param count Amount of floats in array.
64
\return True if successful.
66
virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) = 0;
68
//! Sets a vertex shader constant.
69
/** Can be used if you created a shader using pixel/vertex shader
70
assembler or ARB_fragment_program or ARB_vertex_program.
71
\param data: Data to be set in the constants
72
\param startRegister: First register to be set
73
\param constantAmount: Amount of registers to be set. One register consists of 4 floats. */
74
virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0;
76
//! Sets a constant for the pixel shader based on a name.
77
/** This can be used if you used a high level shader language like GLSL
78
or HLSL to create a shader. See setVertexShaderConstant() for an
79
example on how to use this.
80
\param name Name of the variable
81
\param floats Pointer to array of floats
82
\param count Amount of floats in array.
83
\return True if successful. */
84
virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count) = 0;
86
//! Sets a pixel shader constant.
87
/** Can be used if you created a shader using pixel/vertex shader
88
assembler or ARB_fragment_program or ARB_vertex_program.
89
\param data Data to be set in the constants
90
\param startRegister First register to be set.
91
\param constantAmount Amount of registers to be set. One register consists of 4 floats. */
92
virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) = 0;
94
//! Get pointer to the IVideoDriver interface
95
/** \return Pointer to the IVideoDriver interface */
96
virtual IVideoDriver* getVideoDriver() = 0;
99
} // end namespace video
100
} // end namespace irr