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