Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
groupbox.hpp
Go to the documentation of this file.
1 
23 #ifndef __GROUPBOX__
24 #define __GROUPBOX__
25 
26 #include <tucano/shapes/quad.hpp>
27 #include <tucano/gui/element.hpp>
28 #include <Eigen/Dense>
29 
30 namespace Tucano
31 {
32 
33 namespace GUI
34 {
35 
42 
43 protected:
44 
46  Eigen::Vector4f color;
47 
49  vector < Tucano::GUI::Element* > elements;
50 
51 public:
52 
56  GroupBox (void)
57  {
58  GroupBox(10, 10, 0, 0);
59  }
60 
68  GroupBox (int w, int h, int x, int y)
69  {
70  color << 0.0, 0.8, 0.8, 1.0;
71  dimensions << w, h;
72  position << x, y;
75  num_params = 0;
76  }
77 
86  GroupBox (int w, int h, int x, int y, string texture)
87  {
88  GroupBox (w, h, x, y);
89  setTexture (texture);
90  }
91 
95  void add (Element *el)
96  {
97  elements.push_back(el);
98  }
99 
100  vector < Tucano::GUI::Element *> * elementList (void)
101  {
102  return &elements;
103  }
104 
105  int getType (void)
106  {
107  return Tucano::GUI::GROUPBOX;
108  }
109 
114  void setColor (const Eigen::Vector4f& c)
115  {
116  color = c;
117  }
118 
124  void render ( Tucano::Camera &camera_2d, Shader &shader )
125  {
126  if (!visible)
127  return;
128 
129  shader.bind();
130 
131  shader.setUniform("modelMatrix", model_matrix);
132  shader.setUniform("viewMatrix", camera_2d.getViewMatrix());
133  shader.setUniform("projectionMatrix", camera_2d.getProjectionMatrix());
134  shader.setUniform("in_Color", color);
135  shader.setUniform("shapetex", texture.bind());
136 
137  quad.setAttributeLocation(shader);
138 
139  quad.bindBuffers();
142 
143  shader.unbind();
144  texture.unbind();
145 
146  for (unsigned int i = 0; i < elements.size(); ++i)
147  {
148  elements[i]->render(camera_2d, shader);
149  }
150 
151  }
152 
153 };
154 }
155 }
156 #endif
Eigen::Vector2i dimensions
Dimensions in pixels.
Definition: element.hpp:66
Eigen::Vector2i position
Position of top-left corner in pixels.
Definition: element.hpp:69
Base class for all GUI elements (buttons, sliders ...)
Definition: element.hpp:52
void getViewMatrix(GLdouble *matrix)
Return the modelview matrix as a GLdouble array.
Definition: camera.hpp:126
virtual void setModelMatrix(void)
Sets the element model matrix.
Definition: element.hpp:195
Tucano::Texture texture
Element texture.
Definition: element.hpp:75
void getProjectionMatrix(GLdouble *matrix)
Return the projection matrix as a GLdouble array.
Definition: camera.hpp:142
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
int getType(void)
Returns the element type.
Definition: groupbox.hpp:105
void render(Tucano::Camera &camera_2d, Shader &shader)
Renders the groupbox and all elements inside.
Definition: groupbox.hpp:124
A Shader object represents one GLSL program.
Definition: shader.hpp:45
GroupBox(void)
Default constructor.
Definition: groupbox.hpp:56
The gui group box is just a placeholder for other gui elements. It can be used to group elements...
Definition: groupbox.hpp:41
bool visible
Flag to show/hide element.
Definition: element.hpp:98
Eigen::Vector4f color
Color.
Definition: groupbox.hpp:46
GroupBox(int w, int h, int x, int y, string texture)
Overload constructor that receives dimensions and texture file.
Definition: groupbox.hpp:86
Definition: element.hpp:43
void setColor(const Eigen::Vector4f &c)
Sets the button color.
Definition: groupbox.hpp:114
int num_params
Number of parameters for the callback.
Definition: element.hpp:60
void unbind(void)
Disables the shader program.
Definition: shader.hpp:1184
Eigen::Affine3f model_matrix
Model Matrix for placing element.
Definition: element.hpp:63
vector< Tucano::GUI::Element * > elements
Vector containing gui elements inside box.
Definition: groupbox.hpp:49
virtual void unbindBuffers(void)
Unbinds all buffers.
Definition: mesh.hpp:702
virtual void setTexture(string file)
Loads the button texture file.
Definition: element.hpp:173
void add(Element *el)
Adds an element to the gui.
Definition: groupbox.hpp:95
int element_type
Type of element.
Definition: element.hpp:57
void bind(void)
Enables the shader program for usage.
Definition: shader.hpp:1176
GroupBox(int w, int h, int x, int y)
Overload Constructor.
Definition: groupbox.hpp:68
vector< Tucano::GUI::Element * > * elementList(void)
Definition: groupbox.hpp:100
virtual void renderElements(void)
Call the draw method for rendering triangles. This method requires that a index buffer has been creat...
Definition: mesh.hpp:726
virtual void bindBuffers(void)
Binds all buffers.
Definition: mesh.hpp:677
Defines an abstract camera with a projection and view matrices.
Definition: camera.hpp:37
void setAttributeLocation(Shader *shader)
Automatically sets the attribute locations for a given Shader.
Definition: mesh.hpp:541
Shapes::Quad quad
Quad to hold texture.
Definition: element.hpp:72
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