Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
renderbuffer.hpp
Go to the documentation of this file.
1 
23 #ifndef __RENDERBUFFER__
24 #define __RENDERBUFFER__
25 
26 #include <tucano/tucano.hpp>
27 
28 namespace Tucano
29 {
30 namespace Effects
31 {
32 
36 class RenderBuffer : public Effect
37 {
38 
39 private:
40 
43 
46 
48  bool use_aa_filter = false;
49 
50 public:
54  RenderBuffer (void) {}
55 
59  virtual void initialize()
60  {
61  loadShader(shader, "renderbuffer");
62  quad.createQuad();
63  }
64 
65  void applyAAFilter (bool a)
66  {
67  use_aa_filter = a;
68  }
69 
77  void render (Tucano::Framebuffer& fbo, GLint attach_id = 0)
78  {
79  glViewport(0, 0, fbo.getWidth(), fbo.getHeight());
80 
81  shader.bind();
82  shader.setUniform("tex", fbo.bindAttachment(attach_id));
83  shader.setUniform("use_aa_filter", (int)use_aa_filter);
84  quad.setAttributeLocation(shader);
85  quad.render();
86 
87  shader.unbind();
88  fbo.unbindAttachments();
89  }
90 };
91 }
92 
93 }
94 
95 #endif
virtual void initialize()
Initializes the effect, creating and loading the shader.
Definition: renderbuffer.hpp:59
void createQuad(void)
Sets the mesh as Unit Quad.
Definition: mesh.hpp:841
int getHeight(void)
Returns the height of the FBO.
Definition: framebuffer.hpp:893
Tucano::Mesh quad
A quad to be rendered forcing one call of the fragment shader per image pixel (its just a proxy geome...
Definition: renderbuffer.hpp:45
Definition: bufferobject.hpp:34
void applyAAFilter(bool a)
Definition: renderbuffer.hpp:65
A Shader object represents one GLSL program.
Definition: shader.hpp:45
RenderBuffer(void)
Default Constructor.
Definition: renderbuffer.hpp:54
A simple effect to render a buffer without any interpolation.
Definition: renderbuffer.hpp:36
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
bool use_aa_filter
use gaussian filter as antialiasing
Definition: renderbuffer.hpp:48
A wrapper class for creating and using FBOs.
Definition: framebuffer.hpp:44
virtual Shader * loadShader(string shader_name)
Loads a shader by filename, initializes it, and inserts in shaders list.
Definition: effect.hpp:73
virtual void render(void)
Render the mesh triangles. The method binds the buffers, calls the method to render triangles...
Definition: mesh.hpp:756
void unbindAttachments(void)
Unbinds all texture attachments.
Definition: framebuffer.hpp:528
int getWidth(void)
Returns the width of the FBO.
Definition: framebuffer.hpp:884
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
void render(Tucano::Framebuffer &fbo, GLint attach_id=0)
Renders the given FBO attachment.
Definition: renderbuffer.hpp:77
Tucano::Shader shader
The mean filter shader.
Definition: renderbuffer.hpp:42
A common Mesh, usually containing triagles or points.
Definition: mesh.hpp:194
void setAttributeLocation(Shader *shader)
Automatically sets the attribute locations for a given Shader.
Definition: mesh.hpp:541
The Effect class is a holder for Shaders. It is completely optional, but is contains a few methods fo...
Definition: effect.hpp:43
void bindAttachment(int attachment, int texture_unit)
Binds a texture attachment to a given texture unit.
Definition: framebuffer.hpp:510
void setUniform(GLint location, GLint a, GLint b, GLint c, GLint d)
Sets an uniform integer 4D vector (ivec4) given a location and the vector values. ...
Definition: shader.hpp:1258