~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to include/IMaterialRendererServices.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
4
 
 
5
#ifndef __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__
 
6
#define __I_MATERIAL_RENDERER_SERVICES_H_INCLUDED__
 
7
 
 
8
#include "SMaterial.h"
 
9
#include "S3DVertex.h"
 
10
 
 
11
namespace irr
 
12
{
 
13
namespace video
 
14
{
 
15
 
 
16
class IVideoDriver;
 
17
 
 
18
 
 
19
//! Interface providing some methods for changing advanced, internal states of a IVideoDriver.
 
20
class IMaterialRendererServices
 
21
{
 
22
public:
 
23
 
 
24
        //! Destructor
 
25
        virtual ~IMaterialRendererServices() {}
 
26
 
 
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
 
32
        fog enabling.
 
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;
 
40
 
 
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:
 
47
        \code
 
48
        virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
 
49
        {
 
50
                video::IVideoDriver* driver = services->getVideoDriver();
 
51
 
 
52
                f32 time = (f32)os::Timer::getTime()/100000.0f;
 
53
                services->setVertexShaderConstant("fTime", &time, 1);
 
54
 
 
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);
 
59
        }
 
60
        \endcode
 
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.
 
65
        */
 
66
        virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count) = 0;
 
67
 
 
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;
 
75
 
 
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;
 
85
 
 
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;
 
93
 
 
94
        //! Get pointer to the IVideoDriver interface
 
95
        /** \return Pointer to the IVideoDriver interface */
 
96
        virtual IVideoDriver* getVideoDriver() = 0;
 
97
};
 
98
 
 
99
} // end namespace video
 
100
} // end namespace irr
 
101
 
 
102
#endif
 
103