charcoal/OpenGLEngine/LitScene.h
elipzer 1eea92a3af LitScene Phong Lighting Complete
Now, LitScene allows for simple lighting. (Shadows still to come).
Ambient, specular, and diffuse lighting available and each mesh's
vertex can define a material that defines its reflectivity. An
example scene was added to the MyApplication as the scene for the
6 button.
2018-09-15 03:46:42 -04:00

53 lines
1.2 KiB
C++

#pragma once
#include <vector>
#include "AutoPrerenderingScene.h"
#include "BuiltinTypes.h"
#include "Camera.h"
#include "Batched.h"
#include "LitBatch.h"
#include "LitShaderProgram.h"
namespace charcoal
{
namespace builtin
{
// A scene lit by the Phong Reflection Model (See https://en.wikipedia.org/wiki/Phong_reflection_model )
class LitScene : public AutoPrerenderingScene, public Batched<LitRenderable, LitBatch>
{
public:
LitScene(Application& application) : AutoPrerenderingScene(application) {}
virtual ~LitScene() {}
void init() override;
void use() override;
void unuse() override;
void render() override;
protected:
void set_camera(const Camera* p_camera) { m_p_camera = p_camera; }
Light& add_light(
const Position& position,
const Light::Power& power,
const ColorRGB ambient,
const ColorRGB diffuse,
const ColorRGB specular,
const Light::Fade& fade
)
{
m_lights.emplace_back(position, power, ambient, diffuse, specular, fade);
return m_lights.back();
}
private:
LitShaderProgram m_shader_program;
const Camera* m_p_camera = nullptr;
std::vector<Light> m_lights;
};
}
}