Use utils function for renderbloom/blend

This commit is contained in:
Vincent Lejeune 2014-03-30 20:49:14 +02:00
parent 9a5e3d9c9c
commit 1481a110a5
3 changed files with 18 additions and 24 deletions

View File

@ -210,18 +210,11 @@ void renderBloom(ITexture *in)
const float threshold = World::getWorld()->getTrack()->getBloomThreshold();
glUseProgram(FullScreenShader::BloomShader::Program);
glBindVertexArray(FullScreenShader::BloomShader::vao);
glUniform1f(FullScreenShader::BloomShader::uniform_low, threshold);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glUniform1i(FullScreenShader::BloomShader::uniform_texture, 0);
setTexture(0, getTextureGLuint(in), GL_NEAREST, GL_NEAREST);
FullScreenShader::BloomShader::setUniforms(0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
static
@ -235,18 +228,10 @@ void renderBloomBlend(ITexture *in)
glUseProgram(FullScreenShader::BloomBlendShader::Program);
glBindVertexArray(FullScreenShader::BloomBlendShader::vao);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, getTextureGLuint(in));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glUniform1i(FullScreenShader::BloomBlendShader::uniform_texture, 0);
setTexture(0, getTextureGLuint(in), GL_LINEAR, GL_LINEAR);
FullScreenShader::BloomBlendShader::setUniforms(0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
}
static

View File

@ -1762,7 +1762,6 @@ namespace FullScreenShader
{
GLuint BloomShader::Program;
GLuint BloomShader::uniform_texture;
GLuint BloomShader::uniform_low;
GLuint BloomShader::vao;
void BloomShader::init()
{
@ -1770,13 +1769,16 @@ namespace FullScreenShader
GL_VERTEX_SHADER, file_manager->getAsset("shaders/screenquad.vert").c_str(),
GL_FRAGMENT_SHADER, file_manager->getAsset("shaders/bloom.frag").c_str());
uniform_texture = glGetUniformLocation(Program, "tex");
uniform_low = glGetUniformLocation(Program, "low");
vao = createVAO(Program);
}
void BloomShader::setUniforms(unsigned TU_tex)
{
glUniform1i(FullScreenShader::BloomShader::uniform_texture, TU_tex);
}
GLuint BloomBlendShader::Program;
GLuint BloomBlendShader::uniform_texture;
GLuint BloomBlendShader::uniform_low;
GLuint BloomBlendShader::vao;
void BloomBlendShader::init()
{
@ -1787,6 +1789,11 @@ namespace FullScreenShader
vao = createVAO(Program);
}
void BloomBlendShader::setUniforms(unsigned TU_tex)
{
glUniform1i(FullScreenShader::BloomShader::uniform_texture, TU_tex);
}
GLuint ColorLevelShader::Program;
GLuint ColorLevelShader::uniform_tex;
GLuint ColorLevelShader::uniform_inlevel;

View File

@ -457,20 +457,22 @@ class BloomShader
{
public:
static GLuint Program;
static GLuint uniform_texture, uniform_low;
static GLuint uniform_texture;
static GLuint vao;
static void init();
static void setUniforms(unsigned TU_tex);
};
class BloomBlendShader
{
public:
static GLuint Program;
static GLuint uniform_texture, uniform_low;
static GLuint uniform_texture;
static GLuint vao;
static void init();
static void setUniforms(unsigned TU_tex);
};
class ColorLevelShader