#include <cmath>
#include "ambientocclusion.h"
#include "blend.h"
+#include "renderer.h"
#include "shader.h"
#include "tests.h"
occlude_shdata.uniform("darkness", darkness);
}
-void AmbientOcclusion::render(const Texture2D &color, const Texture2D &depth)
+void AmbientOcclusion::render(Renderer &renderer, const Texture2D &color, const Texture2D &depth)
{
occlude_texturing.attach(0, depth);
combine_texturing.attach(0, depth);
combine_texturing.attach(1, color);
- Bind bind_mesh(quad);
{
+ Renderer::Push push(renderer);
BindRestore bind_fbo(fbo);
- Bind bind_tex(occlude_texturing);
- Bind bind_shader(occlude_shader);
- occlude_shdata.apply();
- quad.draw();
+ renderer.set_texturing(&occlude_texturing);
+ renderer.set_shader_program(&occlude_shader, &occlude_shdata);
+ quad.draw(renderer);
}
- Bind bind_tex(combine_texturing);
- Bind bind_shader(combine_shader);
- combine_shdata.apply();
- quad.draw();
+ Renderer::Push push(renderer);
+ renderer.set_texturing(&combine_texturing);
+ renderer.set_shader_program(&combine_shader, &combine_shdata);
+ quad.draw(renderer);
}
} // namespace GL
void set_depth_ratio(float);
void set_darkness(float);
- virtual void render(const Texture2D &, const Texture2D &);
+ virtual void render(Renderer &, const Texture2D &, const Texture2D &);
};
} // namespace GL
#include "blend.h"
#include "bloom.h"
#include "misc.h"
+#include "renderer.h"
#include "shader.h"
#include "tests.h"
#include "texunit.h"
combine_shdata.uniform("strength", s);
}
-void Bloom::render(const Texture2D &src, const Texture2D &)
+void Bloom::render(Renderer &renderer, const Texture2D &src, const Texture2D &)
{
- Bind bind_mesh(quad);
-
{
- Bind bind_shader(blur_shader);
- blur_shdata_common.apply();
+ Renderer::Push push(renderer);
+ renderer.set_shader_program(&blur_shader, &blur_shdata_common);
for(unsigned i=0; i<2; ++i)
{
BindRestore bind_fbo(fbo[i]);
- Bind bind_tex(i ? tex[0] : src);
- blur_shdata[i].apply();
- quad.draw();
+ Renderer::Push push2(renderer);
+ renderer.set_texture(i ? &tex[0] : &src);
+ renderer.add_shader_data(blur_shdata[i]);
+ quad.draw(renderer);
}
}
+ Renderer::Push push(renderer);
combine_texturing.attach(1, src);
- Bind bind_texturing(combine_texturing);
- Bind bind_shader(combine_shader);
- combine_shdata.apply();
- quad.draw();
+ renderer.set_texturing(&combine_texturing);
+ renderer.set_shader_program(&combine_shader, &combine_shdata);
+ quad.draw(renderer);
}
} // namespace GL
values mean more blurriness. */
void set_strength(float);
- virtual void render(const Texture2D &, const Texture2D &);
+ virtual void render(Renderer &, const Texture2D &, const Texture2D &);
};
} // namespace GL
#include "color.h"
#include "colorcurve.h"
#include "mesh.h"
+#include "renderer.h"
#include "shader.h"
#include "texture2d.h"
curve.storage(LUMINANCE, 256);
curve.set_min_filter(LINEAR);
curve.set_wrap(CLAMP_TO_EDGE);
+ texturing.attach(1, curve);
set_peak(0.2);
set_brightness(1.5);
curve.image(0, LUMINANCE, UNSIGNED_BYTE, curve_data);
}
-void ColorCurve::render(const Texture2D &color_buf, const Texture2D &)
+void ColorCurve::render(Renderer &renderer, const Texture2D &color_buf, const Texture2D &)
{
- Bind _bind_shader(shprog);
- shdata.apply();
- Bind _bind_mesh(quad);
- Bind _bind_tex(color_buf);
- Bind _bind_curve(curve, 1);
- quad.draw();
+ texturing.attach(0, color_buf);
+
+ Renderer::Push push(renderer);
+ renderer.set_shader_program(&shprog, &shdata);
+ renderer.set_texturing(&texturing);
+ quad.draw(renderer);
}
} // namespace GL
#include "program.h"
#include "programdata.h"
#include "texture1d.h"
+#include "texturing.h"
namespace Msp {
namespace GL {
Program shprog;
ProgramData shdata;
Texture1D curve;
+ Texturing texturing;
const Mesh &quad;
public:
/// Sets output mapping to linear. This is equivalent to set_gamma(1).
void set_linear();
- virtual void render(const Texture2D &, const Texture2D &);
+ virtual void render(Renderer &, const Texture2D &, const Texture2D &);
};
} // namespace GL
renderer.render(*j->renderable, i->get_tag());
}
- renderer.end();
-
if(target[0])
{
BindRestore unbind_depth_test(static_cast<DepthTest *>(0));
target[1-j]->fbo.bind();
else
out_fbo->bind();
- postproc[i]->render(target[j]->color, target[j]->depth);
+ postproc[i]->render(renderer, target[j]->color, target[j]->depth);
}
}
namespace Msp {
namespace GL {
+void PostProcessor::render(Renderer &, const Texture2D &color, const Texture2D &depth)
+{
+ render(color, depth);
+}
+
Shader &PostProcessor::get_fullscreen_vertex_shader()
{
static VertexShader shader(fullscreen_vs_source);
namespace GL {
class Mesh;
+class Renderer;
class Shader;
class Texture2D;
virtual ~PostProcessor() { }
/// Renders the effect.
- virtual void render(const Texture2D &color, const Texture2D &depth) = 0;
+ virtual void render(const Texture2D &, const Texture2D &) { }
+
+ virtual void render(Renderer &, const Texture2D &, const Texture2D &);
protected:
/** Returns a vertex shader suitable for rendering a full-screen quad.