diff options
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.h | 282 |
1 files changed, 141 insertions, 141 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.h b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.h index ff71150..de8072c 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/COpenGLSLMaterialRenderer.h | |||
@@ -1,141 +1,141 @@ | |||
1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt | 1 | // Copyright (C) 2002-2012 Nikolaus Gebhardt |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | #ifndef __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ | 5 | #ifndef __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ |
6 | #define __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ | 6 | #define __C_OPENGL_SHADER_LANGUAGE_MATERIAL_RENDERER_H_INCLUDED__ |
7 | 7 | ||
8 | #include "IrrCompileConfig.h" | 8 | #include "IrrCompileConfig.h" |
9 | #ifdef _IRR_COMPILE_WITH_OPENGL_ | 9 | #ifdef _IRR_COMPILE_WITH_OPENGL_ |
10 | 10 | ||
11 | #ifdef _IRR_WINDOWS_API_ | 11 | #ifdef _IRR_WINDOWS_API_ |
12 | #define WIN32_LEAN_AND_MEAN | 12 | #define WIN32_LEAN_AND_MEAN |
13 | #include <windows.h> | 13 | #include <windows.h> |
14 | #include <GL/gl.h> | 14 | #include <GL/gl.h> |
15 | #include "glext.h" | 15 | #include "glext.h" |
16 | #else | 16 | #else |
17 | #if defined(_IRR_OPENGL_USE_EXTPOINTER_) | 17 | #if defined(_IRR_OPENGL_USE_EXTPOINTER_) |
18 | #define GL_GLEXT_LEGACY 1 | 18 | #define GL_GLEXT_LEGACY 1 |
19 | #else | 19 | #else |
20 | #define GL_GLEXT_PROTOTYPES 1 | 20 | #define GL_GLEXT_PROTOTYPES 1 |
21 | #endif | 21 | #endif |
22 | #if defined(_IRR_OSX_PLATFORM_) | 22 | #if defined(_IRR_OSX_PLATFORM_) |
23 | #include <OpenGL/gl.h> | 23 | #include <OpenGL/gl.h> |
24 | #else | 24 | #else |
25 | #include <GL/gl.h> | 25 | #include <GL/gl.h> |
26 | #endif | 26 | #endif |
27 | #if defined(_IRR_OPENGL_USE_EXTPOINTER_) | 27 | #if defined(_IRR_OPENGL_USE_EXTPOINTER_) |
28 | #include "glext.h" | 28 | #include "glext.h" |
29 | #endif | 29 | #endif |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | 32 | ||
33 | #include "IMaterialRenderer.h" | 33 | #include "IMaterialRenderer.h" |
34 | #include "IMaterialRendererServices.h" | 34 | #include "IMaterialRendererServices.h" |
35 | #include "IGPUProgrammingServices.h" | 35 | #include "IGPUProgrammingServices.h" |
36 | #include "irrArray.h" | 36 | #include "irrArray.h" |
37 | #include "irrString.h" | 37 | #include "irrString.h" |
38 | 38 | ||
39 | namespace irr | 39 | namespace irr |
40 | { | 40 | { |
41 | namespace video | 41 | namespace video |
42 | { | 42 | { |
43 | 43 | ||
44 | class COpenGLDriver; | 44 | class COpenGLDriver; |
45 | class IShaderConstantSetCallBack; | 45 | class IShaderConstantSetCallBack; |
46 | 46 | ||
47 | //! Class for using GLSL shaders with OpenGL | 47 | //! Class for using GLSL shaders with OpenGL |
48 | //! Please note: This renderer implements its own IMaterialRendererServices | 48 | //! Please note: This renderer implements its own IMaterialRendererServices |
49 | class COpenGLSLMaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices | 49 | class COpenGLSLMaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | 52 | ||
53 | //! Constructor | 53 | //! Constructor |
54 | COpenGLSLMaterialRenderer( | 54 | COpenGLSLMaterialRenderer( |
55 | COpenGLDriver* driver, | 55 | COpenGLDriver* driver, |
56 | s32& outMaterialTypeNr, | 56 | s32& outMaterialTypeNr, |
57 | const c8* vertexShaderProgram = 0, | 57 | const c8* vertexShaderProgram = 0, |
58 | const c8* vertexShaderEntryPointName = 0, | 58 | const c8* vertexShaderEntryPointName = 0, |
59 | E_VERTEX_SHADER_TYPE vsCompileTarget = video::EVST_VS_1_1, | 59 | E_VERTEX_SHADER_TYPE vsCompileTarget = video::EVST_VS_1_1, |
60 | const c8* pixelShaderProgram = 0, | 60 | const c8* pixelShaderProgram = 0, |
61 | const c8* pixelShaderEntryPointName = 0, | 61 | const c8* pixelShaderEntryPointName = 0, |
62 | E_PIXEL_SHADER_TYPE psCompileTarget = video::EPST_PS_1_1, | 62 | E_PIXEL_SHADER_TYPE psCompileTarget = video::EPST_PS_1_1, |
63 | const c8* geometryShaderProgram = 0, | 63 | const c8* geometryShaderProgram = 0, |
64 | const c8* geometryShaderEntryPointName = "main", | 64 | const c8* geometryShaderEntryPointName = "main", |
65 | E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, | 65 | E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0, |
66 | scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, | 66 | scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES, |
67 | scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, | 67 | scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP, |
68 | u32 verticesOut = 0, | 68 | u32 verticesOut = 0, |
69 | IShaderConstantSetCallBack* callback = 0, | 69 | IShaderConstantSetCallBack* callback = 0, |
70 | IMaterialRenderer* baseMaterial = 0, | 70 | IMaterialRenderer* baseMaterial = 0, |
71 | s32 userData = 0); | 71 | s32 userData = 0); |
72 | 72 | ||
73 | //! Destructor | 73 | //! Destructor |
74 | virtual ~COpenGLSLMaterialRenderer(); | 74 | virtual ~COpenGLSLMaterialRenderer(); |
75 | 75 | ||
76 | virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, | 76 | virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial, |
77 | bool resetAllRenderstates, IMaterialRendererServices* services); | 77 | bool resetAllRenderstates, IMaterialRendererServices* services); |
78 | 78 | ||
79 | virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); | 79 | virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype); |
80 | 80 | ||
81 | virtual void OnUnsetMaterial(); | 81 | virtual void OnUnsetMaterial(); |
82 | 82 | ||
83 | //! Returns if the material is transparent. | 83 | //! Returns if the material is transparent. |
84 | virtual bool isTransparent() const; | 84 | virtual bool isTransparent() const; |
85 | 85 | ||
86 | // implementations for the render services | 86 | // implementations for the render services |
87 | virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates); | 87 | virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates); |
88 | virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); | 88 | virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count); |
89 | virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count); | 89 | virtual bool setVertexShaderConstant(const c8* name, const bool* bools, int count); |
90 | virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count); | 90 | virtual bool setVertexShaderConstant(const c8* name, const s32* ints, int count); |
91 | virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); | 91 | virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); |
92 | virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); | 92 | virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count); |
93 | virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count); | 93 | virtual bool setPixelShaderConstant(const c8* name, const bool* bools, int count); |
94 | virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count); | 94 | virtual bool setPixelShaderConstant(const c8* name, const s32* ints, int count); |
95 | virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); | 95 | virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1); |
96 | virtual IVideoDriver* getVideoDriver(); | 96 | virtual IVideoDriver* getVideoDriver(); |
97 | 97 | ||
98 | protected: | 98 | protected: |
99 | 99 | ||
100 | //! constructor only for use by derived classes who want to | 100 | //! constructor only for use by derived classes who want to |
101 | //! create a fall back material for example. | 101 | //! create a fall back material for example. |
102 | COpenGLSLMaterialRenderer(COpenGLDriver* driver, | 102 | COpenGLSLMaterialRenderer(COpenGLDriver* driver, |
103 | IShaderConstantSetCallBack* callback, | 103 | IShaderConstantSetCallBack* callback, |
104 | IMaterialRenderer* baseMaterial, | 104 | IMaterialRenderer* baseMaterial, |
105 | s32 userData=0); | 105 | s32 userData=0); |
106 | 106 | ||
107 | void init(s32& outMaterialTypeNr, | 107 | void init(s32& outMaterialTypeNr, |
108 | const c8* vertexShaderProgram, | 108 | const c8* vertexShaderProgram, |
109 | const c8* pixelShaderProgram, | 109 | const c8* pixelShaderProgram, |
110 | const c8* geometryShaderProgram, | 110 | const c8* geometryShaderProgram, |
111 | scene::E_PRIMITIVE_TYPE inType=scene::EPT_TRIANGLES, | 111 | scene::E_PRIMITIVE_TYPE inType=scene::EPT_TRIANGLES, |
112 | scene::E_PRIMITIVE_TYPE outType=scene::EPT_TRIANGLE_STRIP, | 112 | scene::E_PRIMITIVE_TYPE outType=scene::EPT_TRIANGLE_STRIP, |
113 | u32 verticesOut=0); | 113 | u32 verticesOut=0); |
114 | 114 | ||
115 | bool createProgram(); | 115 | bool createProgram(); |
116 | bool createShader(GLenum shaderType, const char* shader); | 116 | bool createShader(GLenum shaderType, const char* shader); |
117 | bool linkProgram(); | 117 | bool linkProgram(); |
118 | 118 | ||
119 | COpenGLDriver* Driver; | 119 | COpenGLDriver* Driver; |
120 | IShaderConstantSetCallBack* CallBack; | 120 | IShaderConstantSetCallBack* CallBack; |
121 | IMaterialRenderer* BaseMaterial; | 121 | IMaterialRenderer* BaseMaterial; |
122 | 122 | ||
123 | struct SUniformInfo | 123 | struct SUniformInfo |
124 | { | 124 | { |
125 | core::stringc name; | 125 | core::stringc name; |
126 | GLenum type; | 126 | GLenum type; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | GLhandleARB Program; | 129 | GLhandleARB Program; |
130 | GLuint Program2; | 130 | GLuint Program2; |
131 | core::array<SUniformInfo> UniformInfo; | 131 | core::array<SUniformInfo> UniformInfo; |
132 | s32 UserData; | 132 | s32 UserData; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | 135 | ||
136 | } // end namespace video | 136 | } // end namespace video |
137 | } // end namespace irr | 137 | } // end namespace irr |
138 | 138 | ||
139 | #endif // compile with OpenGL | 139 | #endif // compile with OpenGL |
140 | #endif // if included | 140 | #endif // if included |
141 | 141 | ||