virtual void bindBuffer(unsigned int width = 0, unsigned int height = 0) = 0;
virtual void unbindBuffer() = 0;
virtual void useBuffer() const = 0;
+ virtual void clearUseBuffer(unsigned int mask) const = 0;
- virtual void updateSize(unsigned int _width, unsigned int _height) = 0;
+ virtual void updateSize(unsigned int width, unsigned int height) = 0;
virtual operator unsigned int() const
{
//glTexParameteri(texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
}
+ //if (data != nullptr)
+ //{
+ // float* _data = new float[width*height*4]();
+ // std::fill_n(_data, width*height * 4, 0);
+ // glTexImage2D(texture_target, 0, texture_internal, width, height, 0, texture_format, texture_type, _data);
+ // delete _data;
+ //}
+ //
+ //else
glTexImage2D(texture_target, 0, texture_internal, width, height, 0, texture_format, texture_type, data);
+
}
void Texture::unbindTexture()
Shader::getShader()->setUniformLocation(bindTargets[_unit], _unit);
}
+void Texture::leaveTexture(bindTarget _unit)
+{
+
+ /* bind Texture*/
+ glActiveTexture(GL_TEXTURE0 + _unit);
+ glBindTexture(GL_TEXTURE_2D, 0); //BADHACK
+
+ Shader::getShader()->setUniformLocation(bindTargets[_unit], _unit);
+}
+
void Texture::updateSize(unsigned int _width, unsigned int _height)
{
if (_width == 0 || _height == 0)
virtual void unbindTexture();
virtual void useTexture(bindTarget = uCOLOR) const;
+ static void leaveTexture(bindTarget = uCOLOR);
+
virtual void updateSize(unsigned int width = 0, unsigned int height = 0);
virtual void downscale(unsigned int lvl);
}
+void dBufferObject::clearUseBuffer(unsigned int _mask) const
+{
+ glBindFramebuffer(buffer_target, handle);
+
+ if (_mask & GL_DEPTH_BUFFER_BIT)
+ glClear(GL_DEPTH_BUFFER_BIT);
+}
+
//void dBufferObject::unbindBuffer()
//{
// for (unsigned int i = 0; i < dim; i++)
// virtual void unbindBuffer() override;
// virtual void useBuffer() const override;
+ virtual void clearUseBuffer(unsigned int mask = 256) const override;
// virtual void clearBuffer() const override;
glBindFramebuffer(buffer_target, handle);
/*Bind Texture Buffers (COLOR)*/
- unsigned int* attachments = new unsigned int[dim];
+ attachments = new unsigned int[dim];
for (unsigned int i = 0; i < dim; i++)
{
textures[i].bindTexture(_width, _height);
glDrawBuffers(dim, attachments);
if (glCheckFramebufferStatus(buffer_target) != GL_FRAMEBUFFER_COMPLETE)
Message::error("fBufferObject: Framebuffer not complete!");
-
- delete attachments;
}
void fBufferObject::unbindBuffer()
{
+ delete attachments;
+
for (unsigned int i = 0; i < dim; i++)
{
textures[i].unbindTexture();
}
+void fBufferObject::clearUseBuffer(unsigned int _mask) const
+{
+ glBindFramebuffer(buffer_target, handle);
+
+ if (dim <= 1)
+ glClear(_mask);
+ else
+ {
+ if(_mask & GL_COLOR_BUFFER_BIT)
+ for (unsigned int i = 0; i < dim; i++)
+ {
+ glDrawBuffer(attachments[i]);
+ glClearColor(0.f, 0.f, 0.f, 1.f);
+ glClear(GL_COLOR_BUFFER_BIT);
+ glClear(GL_DEPTH_BUFFER_BIT);
+ }
+
+ glDrawBuffers(dim, attachments);
+ glClear(_mask);
+ }
+}
+
void fBufferObject::useBuffer() const
{
glBindFramebuffer(buffer_target, handle);
}
-void fBufferObject::clearBuffer()
+void fBufferObject::leaveBuffer()
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
}
virtual void bindBuffer(unsigned int width = 0, unsigned int height = 0) override;
virtual void unbindBuffer() override;
+ virtual void clearUseBuffer(unsigned int mask = 16640) const override;
virtual void useBuffer() const override;
- static void clearBuffer();
+ static void leaveBuffer();
virtual void updateSize(unsigned int _width, unsigned int _height) override;
protected:
unsigned int dim;
Texture* textures = nullptr;
+ unsigned int* attachments;
rBufferObject* rBO = nullptr;
glGenRenderbuffers(1, &handle);
}
+void rBufferObject::clearUseBuffer(unsigned int _mask) const
+{
+ glBindFramebuffer(buffer_target, handle);
+
+ if (_mask & GL_DEPTH_BUFFER_BIT)
+ glClear(GL_DEPTH_BUFFER_BIT);
+}
+
void rBufferObject::useBuffer() const
{
glBindRenderbuffer(buffer_target, handle);
}
-void rBufferObject::clearBuffer()
+void rBufferObject::leaveBuffer()
{
glBindRenderbuffer(GL_RENDERBUFFER, 0);
}
virtual void bindBuffer(unsigned int width = 0, unsigned int height = 0) override;
virtual void unbindBuffer() override;
+ virtual void clearUseBuffer(unsigned int mask = 256) const override;
virtual void useBuffer() const override;
-
- static void clearBuffer();
+ static void leaveBuffer();
void updateSize(unsigned int _width, unsigned int _height) override;
bt_dynamics_world->setGravity(btVector3(0, YFALL_SPEED, 0));
/*BUFFERS*/
- render = new fBufferObject();
+ render = new fBufferObject(2);
render->bindBuffer(W_WIDTH, W_HEIGHT);
blurPingPong = new fBufferObject*[2];
motionVecs = new fBufferObject();
motionVecs->bindBuffer(W_WIDTH , W_HEIGHT);
- fBufferObject::clearBuffer();
+ fBufferObject::leaveBuffer();
//Graphix::disableEffects(EF_BLOOM);
//Graphix::disableEffects(EF_MOTION_BLUR);
}
else
{
- fBufferObject::clearBuffer();
+ fBufferObject::leaveBuffer();
}
/* DRAW SCENE -> SkyBox */
if (lastScreen != nullptr)
lastScreen->useBuffer();
else
- fBufferObject::clearBuffer();
+ fBufferObject::leaveBuffer();
if (Events::isKToggleActive(SDLK_F6))
{
motionVecs->getTexture()->useTexture(uBLURVEC);
bool firstit = true;
- for (int i = 0; i < 1; i++)
+ for (int i = 0; i < 2; i++)
{
postRenderPingPong[!postRenderPP]->useBuffer();
// }
// camera.useCamera();
- // fBufferObject::clearBuffer();
+ // fBufferObject::leaveBuffer();
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// drawSceneObjects();
Shader::getShader(SH_ACTIVE)->setUniformLocation("uFilterThreshold",1.2f);
lastScreen->getTexture()->useTexture();
Model::getPlaneModel()->drawModel(mat4(1.f));
+
+ horizontal_blurPP = !horizontal_blurPP;
+
+ blurPingPong[!horizontal_blurPP]->useBuffer();
+ glClear(GL_COLOR_BUFFER_BIT);
+ Shader::getShader(SH_BLEND)->useShader();
+ blurPingPong[horizontal_blurPP]->getTexture(0)->useTexture(uBLEND);
+ render->getTexture(1)->useTexture(uCOLOR);
+ Model::getPlaneModel()->drawModel(mat4(1.f));
+
horizontal_blurPP = !horizontal_blurPP;
/* BLUR BRIGHTNESS */
/* FINAL DRAW -> if needed*/
if (lastScreen != nullptr)
{
- fBufferObject::clearBuffer();
+ fBufferObject::leaveBuffer();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (Graphix::testEffect(EF_BLOOM))
Shader::getShader(SH_BASICTEXTURE)->useShader();
}
- lastScreen->getTexture()->useTexture(uCOLOR);
+ lastScreen->getTexture(0)->useTexture(uCOLOR);
Model::getPlaneModel()->drawModel(mat4(1.f));
}
case DRAW_Model:
default:
texture->useTexture();
+
+ if (timeresistant)
+ Shader::getShader(SH_ACTIVE)->setUniformLocation("uAddGlow", true);
model->drawModel(modelMat, dr_Model, vec4(0.9f, 0.f, 0.f, 1.f), currentAnimation, AnimationTime);
+ if (timeresistant)
+ Shader::getShader(SH_ACTIVE)->setUniformLocation("uAddGlow", false);
break;
case DRAW_Wire:
texture->useTexture();
virtual void startanimation(uint index, float speed);
virtual void setanimationtime(float time);
virtual void setAnimationLoop(bool loop);
- bool timeresistant;
+ bool timeresistant = false;
bool ignore;
bool movable = true;
else
BrightColor = vec4(0.);
}
+ BrightColor = vec4(0.f);
}
\ No newline at end of file
in vec4 DirLightSpacePos;
layout(location = 0) out vec4 FragColor;
+layout(location = 1) out vec4 AddGlow;
uniform sampler2D uColorTexture;
uniform sampler2DShadow uPointLightXP;
uniform vec4 material; //vec4 in the form (ambient, point, directional, glossyness); so far it was (1, 1, 1, 3)
uniform vec3 dirLightColor;
uniform vec3 AmbientLightColor;
+uniform bool uAddGlow = false;
float DirLightCalcShadowFactor(vec4 LightSpacePos)
{
+ PointLightColor1 * material[1] * (cosThetaPoint1 + pow(SpecularCosPoint1, specularConst)) / squaredist1
+ DirLightCalcShadowFactor(DirLightSpacePos) * dirLightColor * material[2] * (cosThetaDirection1 + pow(SpecularCosDirection1, specularConst))
), uvColor.a);
+
+ if (uAddGlow)
+ {
+ AddGlow = vec4(0.f, dot(FragColor.rgb, vec3(0.2126f, 0.7152f, 0.0722f)),0.f,.6f);
+ }
+ else
+ AddGlow = vec4(0.f);
//FragColor = vec4((normalize(worldNormal)+1)/2, 1.0f);
//FragColor = vec4(length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, length(DirectionalLightDirection1) - 1.0f, 1.0f);