]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/COpenGLShaderMaterialRenderer.h
Reduce IrrCompileConfig usage to files that actually need it
[irrlicht.git] / source / Irrlicht / COpenGLShaderMaterialRenderer.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\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_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__\r
6 #define __C_OPENGL_SHADER_MATERIAL_RENDERER_H_INCLUDED__\r
7 \r
8 \r
9 #ifdef _IRR_COMPILE_WITH_OPENGL_\r
10 \r
11 #include "IMaterialRenderer.h"\r
12 \r
13 #include "COpenGLCommon.h"\r
14 \r
15 namespace irr\r
16 {\r
17 namespace video\r
18 {\r
19 \r
20 class COpenGLDriver;\r
21 class IShaderConstantSetCallBack;\r
22 \r
23 //! Class for using vertex and pixel shaders with OpenGL (asm not glsl!)\r
24 class COpenGLShaderMaterialRenderer : public IMaterialRenderer\r
25 {\r
26 public:\r
27 \r
28         //! Constructor\r
29         COpenGLShaderMaterialRenderer(COpenGLDriver* driver,\r
30                 s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,\r
31                 IShaderConstantSetCallBack* callback, E_MATERIAL_TYPE baseMaterial, s32 userData);\r
32 \r
33         //! Destructor\r
34         virtual ~COpenGLShaderMaterialRenderer();\r
35 \r
36         virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,\r
37                 bool resetAllRenderstates, IMaterialRendererServices* services) override;\r
38 \r
39         bool OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype) override;\r
40 \r
41         void OnUnsetMaterial() override;\r
42 \r
43         //! Returns if the material is transparent.\r
44         bool isTransparent() const override;\r
45 \r
46         //! Access the callback provided by the users when creating shader materials\r
47         IShaderConstantSetCallBack* getShaderConstantSetCallBack() const override\r
48         { \r
49                 return CallBack;\r
50         }\r
51 \r
52 protected:\r
53 \r
54         //! constructor only for use by derived classes who want to\r
55         //! create a fall back material for example.\r
56         COpenGLShaderMaterialRenderer(COpenGLDriver* driver,\r
57                                         IShaderConstantSetCallBack* callback,\r
58                                         E_MATERIAL_TYPE baseMaterial, s32 userData=0);\r
59 \r
60         // must not be called more than once!\r
61         void init(s32& outMaterialTypeNr, const c8* vertexShaderProgram,\r
62                 const c8* pixelShaderProgram, E_VERTEX_TYPE type);\r
63 \r
64         bool createPixelShader(const c8* pxsh);\r
65         bool createVertexShader(const c8* vtxsh);\r
66         bool checkError(const irr::c8* type);\r
67 \r
68         COpenGLDriver* Driver;\r
69         IShaderConstantSetCallBack* CallBack;\r
70 \r
71         // I didn't write this, but here's my understanding:\r
72         // Those flags seem to be exclusive so far (so could be an enum). \r
73         // Maybe the idea was to make them non-exclusive in future (basically having a shader-material)\r
74         // Actually currently there's not even any need to cache them (probably even slower than not doing so).\r
75         // They seem to be mostly for downward compatibility. \r
76         // I suppose the idea is to use SMaterial.BlendOperation + SMaterial.BlendFactor and a simple non-transparent type as base for more flexibility in the future.\r
77         // Note that SMaterial.BlendOperation + SMaterial.BlendFactor are in some drivers already evaluated before OnSetMaterial.\r
78         bool Alpha;\r
79         bool Blending;\r
80         bool FixedBlending;\r
81         bool AlphaTest;\r
82 \r
83         GLuint VertexShader;\r
84         // We have 4 values here, [0] is the non-fog version, the other three are\r
85         // ARB_fog_linear, ARB_fog_exp, and ARB_fog_exp2 in that order\r
86         core::array<GLuint> PixelShader;\r
87         s32 UserData;\r
88 };\r
89 \r
90 \r
91 } // end namespace video\r
92 } // end namespace irr\r
93 \r
94 #endif\r
95 #endif\r
96 \r