1 #pragma once 2 3 #include "irender.h" 4 #include "iglrender.h" 5 #include "ishader.h" 6 #include "moduleobservers.h" 7 8 #include <list> 9 10 class OpenGLShaderPass; 11 namespace render { class OpenGLStateManager; } 12 13 class OpenGLShader: public Shader { 14 private: 15 typedef std::list<OpenGLShaderPass*> Passes; 16 Passes m_passes; 17 IShader* m_shader; 18 std::size_t m_used; 19 ModuleObservers m_observers; 20 21 // The state manager we will be inserting/removing OpenGL states from (this 22 // will be the OpenGLRenderSystem). 23 render::OpenGLStateManager& _glStateManager; 24 25 public: 26 OpenGLShader(render::OpenGLStateManager& glStateManager); 27 28 ~OpenGLShader(); 29 30 void destroy(); 31 void addRenderable(const OpenGLRenderable& renderable, const Matrix4& modelview); 32 void incrementUsed(); 33 void decrementUsed(); 34 bool realised() const; 35 void attach(ModuleObserver& observer); 36 void detach(ModuleObserver& observer); 37 void realise(const std::string& name); 38 void unrealise(); 39 GLTexture& getTexture() const; 40 unsigned int getFlags() const; 41 IShader& getShader() const; 42 OpenGLState& appendDefaultPass(); 43 44 GLenum convertBlendFactor(BlendFactor factor); 45 46 // Append a blend (non-interaction) layer 47 void appendBlendLayer(const ShaderLayer& layer); 48 49 void visitShaderLayers(const ShaderLayer& layer); 50 51 typedef MemberCaller1<OpenGLShader, const ShaderLayer&, &OpenGLShader::visitShaderLayers> 52 ShaderLayerVisitor; 53 54 /// \todo Define special-case shaders in a data file. 55 void construct(const std::string& name); 56 57 // return true if it's a common texture (tex_common) 58 bool isTransparent(const std::string& name); 59 60 void constructNormalShader(const std::string& name); 61 }; 62