Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
rectangle2d.hpp
1 //////////////////////////////
2 //
3 // File: lxs/windowing/rectangle2d.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Oct 24 2012
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_RECT2D_WINDOW__
15 #define __LXS_RECT2D_WINDOW__
16 #include "helper/opengl.hpp"
17 #include "lxs/windowing/window.hpp"
18 namespace LxS
19 {
20  namespace CoreGraphics
21  {
22  class Shader;
23  }
24  namespace Windowing
25  {
26  //! a picture to be spanned and presented somewhere in 2D (a bitmap texture)
27  class Rectangle2D: public Window
28  {
29  std::string filename;
30  boost::shared_ptr<LxS::CoreGraphics::Shader> p_ShaderForReal;
31  float r,g,b,a;
32  float aspect;
33  GLint mag_filter;
34  GLint min_filter;
35  bool auto_alpha;
36  public:
37  //! return file name used to render this background
38  const std::string & GetFilename() {return filename;}
39  //! if set to true, blackest parts of textures will be treated as transparent
40  void SetAutoAlpha(bool y) {auto_alpha=y;}
41  Rectangle2D();
42  // texture is stretched to dimensions of Rectangle
43  //! opengl texture magnification filter
44  void SetTexMagFilter(GLint mf) {mag_filter=mf;}
45  //! opengl texture minification filter
46  void SetTexMinFilter(GLint mf) { min_filter=mf;}
47  //! stretching mode
48  void SetAutoAspect() {aspect=0;}
49  //! texture is maximized and centered; letterbox style
50  void SetFixedAspect(float a) {aspect = a;}
51  //! transparency level
52  void SetAlpha(float a) {this->a = a;}
53  //! transparency level
54  float GetAlpha() {return a;}
55  //! path of a texture
56  void SetFileName(const std::string & _filename)
57  {filename.assign(_filename);}
58  //! path of a texture
59  std::string GetFileName(){return filename;}
60  void Initialize();
61  void Render(Rendermode mode);
62  void UnloadResources();
64  unsigned long GetTexelsCount() ;
65  unsigned long GetFacesCount() {return 20;}
66 
68  };
69  }
70 }
71 #endif