Pioneer
SphereImpostorMaterial.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 #ifndef _GL2_SPHEREIMPOSTORMATERIAL_H
4 #define _GL2_SPHEREIMPOSTORMATERIAL_H
5 /*
6  * Billboard sphere impostor
7  */
8 #include "MaterialGL.h"
9 #include "Program.h"
10 #include "libs.h"
11 namespace Graphics {
12 
13  namespace OGL {
14 
16  public:
18  {
19  return new Program("billboard_sphereimpostor", "");
20  }
21 
22  virtual void Apply() override
23  {
26 
27  //Light uniform parameters
28  for (Uint32 i = 0; i < m_renderer->GetNumLights(); i++) {
29  const Light &Light = m_renderer->GetLight(i);
32  const vector3f &pos = Light.GetPosition();
33  m_program->lights[i].position.Set(pos.x, pos.y, pos.z, (Light.GetType() == Light::LIGHT_DIRECTIONAL ? 0.f : 1.f));
34  }
35  }
36  };
37  } // namespace OGL
38 } // namespace Graphics
39 #endif
Definition: Light.h:14
const vector3f & GetPosition() const
Definition: Light.h:30
@ LIGHT_DIRECTIONAL
Definition: Light.h:19
LightType GetType() const
Definition: Light.h:29
const Color & GetDiffuse() const
Definition: Light.h:31
const Color & GetSpecular() const
Definition: Light.h:32
Definition: Material.h:57
Definition: MaterialGL.h:26
RendererOGL * m_renderer
Definition: MaterialGL.h:41
virtual void Apply() override
Definition: MaterialGL.cpp:11
Program * m_program
Definition: MaterialGL.h:40
Definition: Program.h:23
UniformLight lights[4]
Definition: Program.h:65
Uniform sceneAmbient
Definition: Program.h:57
Definition: SphereImpostorMaterial.h:15
Program * CreateProgram(const MaterialDescriptor &) override
Definition: SphereImpostorMaterial.h:17
virtual void Apply() override
Definition: SphereImpostorMaterial.h:22
void Set(int)
Definition: Uniform.cpp:20
virtual Uint32 GetNumLights() const override final
Definition: RendererGL.h:93
const Light & GetLight(const Uint32 idx) const
Definition: Renderer.h:104
const Color & GetAmbientColor() const
Definition: Renderer.h:111
T y
Definition: vector3.h:18
T x
Definition: vector3.h:18
T z
Definition: vector3.h:18
Definition: Background.h:13
Uniform position
Definition: Program.h:63
Uniform diffuse
Definition: Program.h:61
Uniform specular
Definition: Program.h:62