added posteffectmodule
This commit is contained in:
parent
87a2c2c906
commit
fbc9a5d037
@ -25,6 +25,9 @@ const char* const ForwardModule::lightStr[] =
|
|||||||
|
|
||||||
void ForwardModule::renderGL(Camera* myCamera, Scene* scene)
|
void ForwardModule::renderGL(Camera* myCamera, Scene* scene)
|
||||||
{
|
{
|
||||||
|
// bind target
|
||||||
|
renderTarget->bindFBO();
|
||||||
|
|
||||||
// render ambient lighting
|
// render ambient lighting
|
||||||
glAssert(glClearColor(0, 0.1f, 0.05f, 1.)); // add attribute, and setter for clear color
|
glAssert(glClearColor(0, 0.1f, 0.05f, 1.)); // add attribute, and setter for clear color
|
||||||
glAssert(glClearDepth(1.0));
|
glAssert(glClearDepth(1.0));
|
||||||
@ -163,3 +166,9 @@ void ForwardModule::compileShaders(Scene* scene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ForwardModule::setRenderTarget(FrameBuffer* target)
|
||||||
|
{
|
||||||
|
if(target != NULL)
|
||||||
|
renderTarget = target;
|
||||||
|
}
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include <glew/glew.h>
|
#include <glew/glew.h>
|
||||||
#include "shadersource.h"
|
#include "shadersource.h"
|
||||||
#include "material.h"
|
#include "material.h"
|
||||||
|
#include "framebuffer.h"
|
||||||
|
|
||||||
class Light;
|
class Light;
|
||||||
class Scene;
|
class Scene;
|
||||||
@ -15,7 +16,10 @@ class PhongEntity;
|
|||||||
class ForwardModule : public Module
|
class ForwardModule : public Module
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ForwardModule() : shaderSources(NULL) {}
|
ForwardModule() :
|
||||||
|
shaderSources(NULL),
|
||||||
|
renderTarget(FrameBuffer::getScreen())
|
||||||
|
{}
|
||||||
|
|
||||||
virtual void renderGL(Camera* myCamera, Scene* scene);
|
virtual void renderGL(Camera* myCamera, Scene* scene);
|
||||||
virtual bool requiresModernOpenGL() {return true;} // write some compatibility code to change that to false
|
virtual bool requiresModernOpenGL() {return true;} // write some compatibility code to change that to false
|
||||||
@ -25,6 +29,8 @@ public:
|
|||||||
void setShaderSource(ShaderSource* source);
|
void setShaderSource(ShaderSource* source);
|
||||||
void compileShaders(Scene* scene);
|
void compileShaders(Scene* scene);
|
||||||
|
|
||||||
|
void setRenderTarget(FrameBuffer* target);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum {
|
enum {
|
||||||
// light flags
|
// light flags
|
||||||
@ -41,6 +47,7 @@ private:
|
|||||||
ShaderSource* shaderSources;
|
ShaderSource* shaderSources;
|
||||||
std::vector<Shader*> shaders;
|
std::vector<Shader*> shaders;
|
||||||
std::vector<unsigned int> flags;
|
std::vector<unsigned int> flags;
|
||||||
|
FrameBuffer* renderTarget;
|
||||||
|
|
||||||
void lightPass(Camera* myCamera, Scene* scene, Light* light, unsigned int type);
|
void lightPass(Camera* myCamera, Scene* scene, Light* light, unsigned int type);
|
||||||
};
|
};
|
||||||
|
@ -2,14 +2,18 @@
|
|||||||
#include "texture.h"
|
#include "texture.h"
|
||||||
#include "glassert.h"
|
#include "glassert.h"
|
||||||
|
|
||||||
FrameBuffer::FrameBuffer()
|
FrameBuffer::FrameBuffer(bool isNULL)
|
||||||
{
|
{
|
||||||
glAssert(glGenFramebuffers(1, &fbo));
|
if(isNULL)
|
||||||
|
fbo = 0;
|
||||||
|
else
|
||||||
|
glAssert(glGenFramebuffers(1, &fbo));
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBuffer::~FrameBuffer()
|
FrameBuffer::~FrameBuffer()
|
||||||
{
|
{
|
||||||
glAssert(glDeleteFramebuffers(1, &fbo));
|
if(fbo != 0)
|
||||||
|
glAssert(glDeleteFramebuffers(1, &fbo));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBuffer::addTexture(Texture* tex, GLenum attachment)
|
void FrameBuffer::addTexture(Texture* tex, GLenum attachment)
|
||||||
@ -35,3 +39,11 @@ Texture* FrameBuffer::getTexture(int texId)
|
|||||||
{
|
{
|
||||||
return textures[texId];
|
return textures[texId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FrameBuffer* FrameBuffer::getScreen()
|
||||||
|
{
|
||||||
|
static FrameBuffer* screen = NULL;
|
||||||
|
if(screen != NULL)
|
||||||
|
screen = new FrameBuffer(true);
|
||||||
|
return screen;
|
||||||
|
}
|
||||||
|
@ -13,13 +13,14 @@ protected:
|
|||||||
std::vector<Texture*> textures;
|
std::vector<Texture*> textures;
|
||||||
std::vector<GLuint> attachments;
|
std::vector<GLuint> attachments;
|
||||||
public:
|
public:
|
||||||
FrameBuffer();
|
FrameBuffer(bool isNULL = false);
|
||||||
~FrameBuffer();
|
~FrameBuffer();
|
||||||
void addTexture(Texture* tex, GLenum attachment);
|
void addTexture(Texture* tex, GLenum attachment);
|
||||||
void initGL();
|
void initGL();
|
||||||
|
|
||||||
void bindFBO();
|
void bindFBO();
|
||||||
Texture* getTexture(int texId);
|
Texture* getTexture(int texId);
|
||||||
|
static FrameBuffer* getScreen();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FRAMEBUFFER_H
|
#endif // FRAMEBUFFER_H
|
||||||
|
12
posteffectmodule.cpp
Normal file
12
posteffectmodule.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include "posteffectmodule.h"
|
||||||
|
|
||||||
|
PostEffectModule::PostEffectModule()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PostEffectModule::~PostEffectModule()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
17
posteffectmodule.h
Normal file
17
posteffectmodule.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef POSTEFFECTMODULE_H
|
||||||
|
#define POSTEFFECTMODULE_H
|
||||||
|
|
||||||
|
#include "module.h"
|
||||||
|
|
||||||
|
class FrameBuffer;
|
||||||
|
|
||||||
|
class PostEffectModule : public Module
|
||||||
|
{
|
||||||
|
FrameBuffer* inputFBO;
|
||||||
|
FrameBuffer* outputFBO;
|
||||||
|
public:
|
||||||
|
PostEffectModule();
|
||||||
|
~PostEffectModule();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // POSTEFFECTMODULE_H
|
Loading…
x
Reference in New Issue
Block a user