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
7 #include "EMaterialTypes.h"
8 #include "IMaterialRenderer.h"
9 #include "IMaterialRendererServices.h"
10 #include "IGPUProgrammingServices.h"
12 #include "irrString.h"
21 class COpenGL3DriverBase;
23 class COpenGL3MaterialRenderer : public IMaterialRenderer, public IMaterialRendererServices
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,
36 virtual ~COpenGL3MaterialRenderer();
38 GLuint getProgram() const;
40 virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
41 bool resetAllRenderstates, IMaterialRendererServices* services);
43 virtual bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype);
45 virtual void OnUnsetMaterial();
47 virtual bool isTransparent() const;
49 virtual s32 getRenderCapability() const;
51 void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial, bool resetAllRenderstates) override;
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;
64 IVideoDriver* getVideoDriver() override;
68 COpenGL3MaterialRenderer(COpenGL3DriverBase* driver,
69 IShaderConstantSetCallBack* callback = 0,
70 E_MATERIAL_TYPE baseMaterial = EMT_SOLID,
73 void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram, bool addMaterial = true);
75 bool createShader(GLenum shaderType, const char* shader);
78 COpenGL3DriverBase* Driver;
79 IShaderConstantSetCallBack* CallBack;
93 core::array<SUniformInfo> UniformInfo;