Pioneer
StarfieldMaterial.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_STARFIELD_MATERIAL_H
5 #define _OGL_STARFIELD_MATERIAL_H
6 /*
7  * Starfield material.
8  * This does nothing very special except toggle POINT_SIZE
9  * The Program requires setting intensity using the generic emission parameter
10  */
11 #include "OpenGLLibs.h"
12 #include "Program.h"
13 #include "graphics/Material.h"
14 
15 namespace Graphics {
16  namespace OGL {
17  class StarfieldMaterial : public Material {
18  public:
19  virtual Program *CreateProgram(const MaterialDescriptor &) override
20  {
21  return new Program("starfield", "");
22  }
23 
24  virtual void Apply() override
25  {
27  glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
28  assert(this->texture0);
29  m_program->Use();
30  m_program->texture0.Set(this->texture0, 0);
32  }
33 
34  virtual void Unapply() override
35  {
36  static_cast<TextureGL *>(texture0)->Unbind();
37  glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
38  }
39  };
40  } // namespace OGL
41 } // namespace Graphics
42 
43 #endif
Definition: Material.h:57
Color emissive
Definition: Material.h:97
Texture * texture0
Definition: Material.h:86
Definition: MaterialGL.h:26
virtual void Apply() override
Definition: MaterialGL.cpp:11
Program * m_program
Definition: MaterialGL.h:40
Definition: Program.h:23
Uniform texture0
Definition: Program.h:45
Uniform emission
Definition: Program.h:42
virtual void Use()
Definition: Program.cpp:227
Definition: StarfieldMaterial.h:17
virtual void Apply() override
Definition: StarfieldMaterial.h:24
virtual Program * CreateProgram(const MaterialDescriptor &) override
Definition: StarfieldMaterial.h:19
virtual void Unapply() override
Definition: StarfieldMaterial.h:34
Definition: TextureGL.h:12
void Set(int)
Definition: Uniform.cpp:20
Definition: Background.h:13