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