85 lines
2.0 KiB
C++
85 lines
2.0 KiB
C++
#ifndef FORWARDMODULE_H
|
|
#define FORWARDMODULE_H
|
|
|
|
#include "opengl.h"
|
|
#include "module.h"
|
|
#include <vector>
|
|
#include <set>
|
|
#include <cstddef>
|
|
#include "shadersource.h"
|
|
#include "material.h"
|
|
#include "framebuffer.h"
|
|
#include "light.h"
|
|
#include <unordered_map>
|
|
|
|
class GeometryNode;
|
|
class Scene;
|
|
class PhongEntity;
|
|
|
|
class ForwardModule : public Module
|
|
{
|
|
public:
|
|
ForwardModule() : shaderSources(NULL)
|
|
{
|
|
|
|
}
|
|
|
|
virtual void renderGL(Camera* myCamera, Scene* scene);
|
|
virtual void resize(int w, int h) {width = w; height = h;}
|
|
|
|
void setShaderSource(ShaderSource* source);
|
|
void compileShaders(Scene* scene);
|
|
|
|
private:
|
|
struct Pass
|
|
{
|
|
Shader* shader;
|
|
const std::vector<GeometryNode*> &geometry;
|
|
const std::vector<Light*> &lights;
|
|
|
|
Pass(Shader *myShader,
|
|
const std::vector<GeometryNode*> &geomIt,
|
|
const std::vector<Light*> &lightIt) :
|
|
shader(myShader),
|
|
geometry(geomIt),
|
|
lights(lightIt)
|
|
{}
|
|
};
|
|
|
|
std::unordered_map<unsigned int, std::vector<GeometryNode*>> geometry;
|
|
std::unordered_map<unsigned int, std::vector<Light*>> lights;
|
|
AmbientLight ambientLight;
|
|
std::vector<Pass> passes;
|
|
ShaderSource* shaderSources;
|
|
|
|
int width;
|
|
int height;
|
|
};
|
|
|
|
class PassScheduler
|
|
{
|
|
struct Pass
|
|
{
|
|
Shader* shader;
|
|
const std::vector<GeometryNode*> &geometry;
|
|
const std::vector<Light*> &lights;
|
|
|
|
Pass(Shader *myShader,
|
|
const std::vector<GeometryNode*> &geomIt,
|
|
const std::vector<Light*> &lightIt) :
|
|
shader(myShader),
|
|
geometry(geomIt),
|
|
lights(lightIt)
|
|
{}
|
|
};
|
|
|
|
std::unordered_map<unsigned int, std::vector<GeometryNode*>> geometry;
|
|
std::unordered_map<unsigned int, std::vector<Light*>> lights;
|
|
ShaderSource* shaderSources;
|
|
|
|
public:
|
|
void compileShaders(Scene *scene, std::vector<Pass> &passes);
|
|
};
|
|
|
|
#endif // FORWARDMODULE_H
|