SCV  4.2.1
Simple Components for Visual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ComponentTexture.h
Go to the documentation of this file.
1 
7 #ifndef __SCV_COMPONENT_TEXTURE_H__
8 #define __SCV_COMPONENT_TEXTURE_H__
9 
10 #ifndef DOXYGEN_SKIP_THIS
11 #include "Point.h"
12 #include "ColorRGBA.h"
13 #include "MatrixTemplate.h"
14 #endif // DOXYGEN_SKIP_THIS
15 
16 namespace scv {
17 
24 public:
25  ComponentTexture(GLsizei width, GLsizei height);
26  virtual ~ComponentTexture(void);
27 
28  inline void setTextureEnvMode(GLfloat param) {
29  _textureEnvMode = param;
30  }
31 
32  //initializes the current ComponentTexture texture
33  inline void enable(void) {
34  glBindTexture(GL_TEXTURE_2D, _textureId);
35  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, _textureEnvMode);
36  }
37 
38  inline void disable(void) {
39  //disables de current texture
40  glBindTexture(GL_TEXTURE_2D, 0);
41  }
42 
43  inline GLsizei getWidth(void) const {
44  return _textureSize[0];
45  }
46  inline GLsizei getHeight(void) const {
47  return _textureSize[1];
48  }
49  inline GLuint getTextureId(void) const {
50  return _textureId;
51  }
52 
53  void display(void);
54 
55  void display(const int translateX, const int translateY, GLuint clipX, GLuint clipY, GLsizei clipWidth, GLsizei clipHeight);
56 
57  void display(const Point &translate, int id);
58  void display(const int translateX, const int translateY, int id);
59 
60  void display(const Point &translate, int id, const Point &textSize);
61  void display(const int translateX, const int translateY, int id, const int textSizeX, const int textSizeY);
62 
63  int addTexture(const Point &textCoords, MatrixTemplate<ColorRGBA> clip);
64  int addTexture(const Point &textCoords, unsigned int w, unsigned int h, const unsigned char* data);
65  int addTexture(const Point &textCoords, ColorRGBA color);
66  void clearTextureIds(void);
67  int addTextureId(const Point &textCoords, unsigned int w, unsigned int h);
68  void setTexture(const Point &textCoords, MatrixTemplate<ColorRGBA> clip, int id);
69  void createTexture(void);
70 
71 private:
72  GLuint _textureId;
73  GLsizei _textureSize[2]; // width, height
74  GLfloat _textureEnvMode;
75 
76  MatrixTemplate<ColorRGBA> *_texture;
77  std::vector<Point> _textCoords;
78  std::vector<Point> _textSize;
79 };
80 
81 inline void ComponentTexture::display(const int translateX, const int translateY, int id) {
82  display(Point(translateX, translateY), id);
83 }
84 
85 inline void ComponentTexture::display(const int translateX, const int translateY, int id, const int textSizeX, const int textSizeY) {
86  display(Point(translateX, translateY), id, Point(textSizeX, textSizeY));
87 }
88 
89 } // namespace scv
90 
91 #endif // __SCV_COMPONENT_TEXTURE_H__