]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/OpenGL/MaterialRenderer.h
dbac6cf6bfbe1016e8ea23dd4203bb1e98ce5e29
[irrlicht.git] / source / Irrlicht / OpenGL / MaterialRenderer.h
1 // Copyright (C) 2014 Patryk Nadrowski\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #pragma once\r
6 \r
7 #include "EMaterialTypes.h"\r
8 #include "IMaterialRenderer.h"\r
9 #include "IMaterialRendererServices.h"\r
10 #include "IGPUProgrammingServices.h"\r
11 #include "irrArray.h"\r
12 #include "irrString.h"\r
13 \r
14 #include "Common.h"\r
15 \r
16 namespace irr\r
17 {\r
18 namespace video\r
19 {\r
20 \r
21 class COpenGL3DriverBase;\r
22 \r
23 class COpenGL3MaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices\r
24 {\r
25 public:\r
26 \r
27         COpenGL3MaterialRenderer(\r
28                 COpenGL3DriverBase* driver,\r
29                 s32& outMaterialTypeNr,\r
30                 const c8* vertexShaderProgram = 0,\r
31                 const c8* pixelShaderProgram = 0,\r
32                 IShaderConstantSetCallBack* callback = 0,\r
33                 E_MATERIAL_TYPE baseMaterial = EMT_SOLID,\r
34                 s32 userData = 0);\r
35 \r
36         virtual ~COpenGL3MaterialRenderer();\r
37 \r
38         GLuint getProgram() const;\r
39 \r
40         virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,\r
41                 bool resetAllRenderstates, IMaterialRendererServices* services);\r
42 \r
43         virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype);\r
44 \r
45         virtual void OnUnsetMaterial();\r
46 \r
47         virtual bool isTransparent() const;\r
48 \r
49         virtual s32 getRenderCapability() const;\r
50 \r
51         void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) override;\r
52 \r
53         s32 getVertexShaderConstantID(const c8* name) override;\r
54         s32 getPixelShaderConstantID(const c8* name) override;\r
55         void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;\r
56         void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;\r
57         bool setVertexShaderConstant(s32 index, const f32* floats, int count) override;\r
58         bool setVertexShaderConstant(s32 index, const s32* ints, int count) override;\r
59         bool setVertexShaderConstant(s32 index, const u32* ints, int count) override;\r
60         bool setPixelShaderConstant(s32 index, const f32* floats, int count) override;\r
61         bool setPixelShaderConstant(s32 index, const s32* ints, int count) override;\r
62         bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;\r
63 \r
64         IVideoDriver* getVideoDriver() override;\r
65 \r
66 protected:\r
67 \r
68         COpenGL3MaterialRenderer(COpenGL3DriverBase* driver,\r
69                                         IShaderConstantSetCallBack* callback = 0,\r
70                                         E_MATERIAL_TYPE baseMaterial = EMT_SOLID,\r
71                                         s32 userData = 0);\r
72 \r
73         void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, bool addMaterial = true);\r
74 \r
75         bool createShader(GLenum shaderType, const char* shader);\r
76         bool linkProgram();\r
77 \r
78         COpenGL3DriverBase* Driver;\r
79         IShaderConstantSetCallBack* CallBack;\r
80 \r
81         bool Alpha;\r
82         bool Blending;\r
83         bool FixedBlending;\r
84 \r
85         struct SUniformInfo\r
86         {\r
87                 core::stringc name;\r
88                 GLenum type;\r
89                 GLint location;\r
90         };\r
91 \r
92         GLuint Program;\r
93         core::array<SUniformInfo> UniformInfo;\r
94         s32 UserData;\r
95 };\r
96 \r
97 \r
98 }\r
99 }\r