Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
rendertexture.hpp
Go to the documentation of this file.
1 
23 #ifndef __RENDERTEXTURE__
24 #define __RENDERTEXTURE__
25 
26 #include <tucano/effect.hpp>
27 #include <tucano/texture.hpp>
28 #include <tucano/mesh.hpp>
29 
30 namespace Tucano
31 {
32 namespace Effects
33 {
34 
39 {
40 
41 private:
42 
45 
48 
49 public:
53  RenderTexture (void) {}
54 
58  virtual void initialize()
59  {
60  loadShader(shader, "rendertexture");
61  quad.createQuad();
62  }
63 
70  void renderTexture (Tucano::Texture& tex, Eigen::Vector2i viewport)
71  {
72  glViewport(0, 0, viewport[0], viewport[1]);
73 
74  shader.bind();
75  shader.setUniform("imageTexture", tex.bind());
76  shader.setUniform("viewportSize", viewport);
77  quad.setAttributeLocation(shader);
78  quad.render();
79 
80  shader.unbind();
81  tex.unbind();
82  }
83 };
84 }
85 }
86 
87 #endif
void createQuad(void)
Sets the mesh as Unit Quad.
Definition: mesh.hpp:841
Tucano::Shader shader
The mean filter shader.
Definition: rendertexture.hpp:44
Definition: bufferobject.hpp:34
void bind(int texture_unit)
Binds the texture to a given unit. Note that if there is another texture already binded to this unit...
Definition: texture.hpp:285
A Shader object represents one GLSL program.
Definition: shader.hpp:45
void renderTexture(Tucano::Texture &tex, Eigen::Vector2i viewport)
Renders the given texture.
Definition: rendertexture.hpp:70
virtual void initialize()
Initializes the effect, creating and loading the shader.
Definition: rendertexture.hpp:58
Tucano::Mesh quad
A quad to be rendered forcing one call of the fragment shader per image pixel (its just a proxy geome...
Definition: rendertexture.hpp:47
A simple effect to render a texture.
Definition: rendertexture.hpp:38
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
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
An OpenGL texture. It can be a simple texture or an FBO texture.
Definition: texture.hpp:41
RenderTexture(void)
Default Constructor.
Definition: rendertexture.hpp:53
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
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 unbind(void)
Unbinds this texture and frees the texture unit.
Definition: texture.hpp:367
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