Pioneer
MaterialGL.h
Go to the documentation of this file.
1 // Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _OGL_MATERIAL_H
5 #define _OGL_MATERIAL_H
6 /*
7  * Multi-purpose OGL material.
8  *
9  * Generally, the idea is that a Program contains uniforms but
10  * a material sets them, using the standard parameters of Graphics::Material
11  * or whatever necessary to achieve an effect
12  *
13  * Programs are owned by the renderer, since they are shared between materials.
14  */
15 #include "OpenGLLibs.h"
16 #include "graphics/Material.h"
17 
18 namespace Graphics {
19 
20  class RendererOGL;
21 
22  namespace OGL {
23 
24  class Program;
25 
26  class Material : public Graphics::Material {
27  public:
28  Material() {}
29  // Create an appropriate program for this material.
30  virtual Program *CreateProgram(const MaterialDescriptor &) = 0;
31  // bind textures, set uniforms
32  virtual void Apply() override;
33  virtual void Unapply() override;
34  virtual bool IsProgramLoaded() const override final;
35  virtual void SetProgram(Program *p) { m_program = p; }
36  virtual void SetCommonUniforms(const matrix4x4f &mv, const matrix4x4f &proj) override;
37 
38  protected:
39  friend class Graphics::RendererOGL;
42  };
43  } // namespace OGL
44 } // namespace Graphics
45 #endif
Definition: Material.h:57
Definition: Material.h:81
Definition: MaterialGL.h:26
virtual Program * CreateProgram(const MaterialDescriptor &)=0
virtual bool IsProgramLoaded() const override final
Definition: MaterialGL.cpp:21
virtual void Unapply() override
Definition: MaterialGL.cpp:17
RendererOGL * m_renderer
Definition: MaterialGL.h:41
Material()
Definition: MaterialGL.h:28
virtual void SetProgram(Program *p)
Definition: MaterialGL.h:35
virtual void Apply() override
Definition: MaterialGL.cpp:11
Program * m_program
Definition: MaterialGL.h:40
virtual void SetCommonUniforms(const matrix4x4f &mv, const matrix4x4f &proj) override
Definition: MaterialGL.cpp:26
Definition: Program.h:23
Definition: RendererGL.h:45
Definition: Background.h:13