]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/COGLES2MaterialRenderer.h
9c4c2c9feac0c6b9fe67c2f1c8abfac02767e226
[irrlicht.git] / source / Irrlicht / COGLES2MaterialRenderer.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 #ifndef __C_OGLES2_SL_MATERIAL_RENDERER_H_INCLUDED__\r
6 #define __C_OGLES2_SL_MATERIAL_RENDERER_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 \r
10 #ifdef _IRR_COMPILE_WITH_OGLES2_\r
11 \r
12 #include "EMaterialTypes.h"\r
13 #include "IMaterialRenderer.h"\r
14 #include "IMaterialRendererServices.h"\r
15 #include "IGPUProgrammingServices.h"\r
16 #include "irrArray.h"\r
17 #include "irrString.h"\r
18 \r
19 #include "COGLES2Common.h"\r
20 \r
21 namespace irr\r
22 {\r
23 namespace video\r
24 {\r
25 \r
26 class COGLES2Driver;\r
27 \r
28 class COGLES2MaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices\r
29 {\r
30 public:\r
31 \r
32         COGLES2MaterialRenderer(\r
33                 COGLES2Driver* driver,\r
34                 s32& outMaterialTypeNr,\r
35                 const c8* vertexShaderProgram = 0,\r
36                 const c8* pixelShaderProgram = 0,\r
37                 IShaderConstantSetCallBack* callback = 0,\r
38                 E_MATERIAL_TYPE baseMaterial = EMT_SOLID,\r
39                 s32 userData = 0);\r
40 \r
41         virtual ~COGLES2MaterialRenderer();\r
42 \r
43         GLuint getProgram() const;\r
44 \r
45         virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,\r
46                 bool resetAllRenderstates, IMaterialRendererServices* services);\r
47 \r
48         virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype);\r
49 \r
50         virtual void OnUnsetMaterial();\r
51 \r
52         virtual bool isTransparent() const;\r
53 \r
54         virtual s32 getRenderCapability() const;\r
55 \r
56         void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) override;\r
57 \r
58         s32 getVertexShaderConstantID(const c8* name) override;\r
59         s32 getPixelShaderConstantID(const c8* name) override;\r
60         void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;\r
61         void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1) override;\r
62         bool setVertexShaderConstant(s32 index, const f32* floats, int count) override;\r
63         bool setVertexShaderConstant(s32 index, const s32* ints, int count) override;\r
64         bool setVertexShaderConstant(s32 index, const u32* ints, int count) override;\r
65         bool setPixelShaderConstant(s32 index, const f32* floats, int count) override;\r
66         bool setPixelShaderConstant(s32 index, const s32* ints, int count) override;\r
67         bool setPixelShaderConstant(s32 index, const u32* ints, int count) override;\r
68 \r
69         IVideoDriver* getVideoDriver() override;\r
70 \r
71 protected:\r
72 \r
73         COGLES2MaterialRenderer(COGLES2Driver* driver,\r
74                                         IShaderConstantSetCallBack* callback = 0,\r
75                                         E_MATERIAL_TYPE baseMaterial = EMT_SOLID,\r
76                                         s32 userData = 0);\r
77 \r
78         void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, bool addMaterial = true);\r
79 \r
80         bool createShader(GLenum shaderType, const char* shader);\r
81         bool linkProgram();\r
82 \r
83         COGLES2Driver* Driver;\r
84         IShaderConstantSetCallBack* CallBack;\r
85 \r
86         bool Alpha;\r
87         bool Blending;\r
88         bool FixedBlending;\r
89 \r
90         struct SUniformInfo\r
91         {\r
92                 core::stringc name;\r
93                 GLenum type;\r
94                 GLint location;\r
95         };\r
96 \r
97         GLuint Program;\r
98         core::array<SUniformInfo> UniformInfo;\r
99         s32 UserData;\r
100 };\r
101 \r
102 \r
103 }\r
104 }\r
105 \r
106 #endif\r
107 #endif\r
108 \r