1 #ifndef Renderable_HPP 2 #define Renderable_HPP 3 #include <vector> 4 #include <typeinfo> 5 #include "TextureManager.hpp" 6 #include "projectM-opengl.h" 7 #include <glm/mat4x4.hpp> 8 9 class BeatDetect; 10 11 12 class RenderContext 13 { 14 public: 15 float time; 16 int texsize; 17 float aspectRatio; 18 bool aspectCorrect; 19 BeatDetect *beatDetect; 20 TextureManager *textureManager; 21 GLuint programID_v2f_c4f; 22 GLuint programID_v2f_c4f_t2f; 23 GLint uniform_v2f_c4f_vertex_tranformation; 24 GLint uniform_v2f_c4f_vertex_point_size; 25 GLint uniform_v2f_c4f_t2f_vertex_tranformation; 26 GLint uniform_v2f_c4f_t2f_frag_texture_sampler; 27 glm::mat4 mat_ortho; 28 29 RenderContext(); 30 }; 31 32 class RenderItem 33 { 34 public: 35 RenderItem(); 36 ~RenderItem(); 37 38 float masterAlpha; 39 virtual void InitVertexAttrib() = 0; 40 virtual void Draw(RenderContext &context) = 0; 41 42 protected: 43 virtual void Init(); 44 45 GLuint m_vboID; 46 GLuint m_vaoID; 47 }; 48 49 typedef std::vector<RenderItem*> RenderItemList; 50 51 class DarkenCenter : public RenderItem 52 { 53 public: 54 DarkenCenter(); 55 void InitVertexAttrib(); 56 void Draw(RenderContext &context); 57 }; 58 59 class Shape : public RenderItem 60 { 61 public: 62 std::string imageUrl; 63 int sides; 64 bool thickOutline; 65 bool enabled; 66 bool additive; 67 bool textured; 68 69 float tex_zoom; 70 float tex_ang; 71 72 float x; /* x position */ 73 float y; /* y position */ 74 float radius; 75 float ang; 76 77 float r; /* red color value */ 78 float g; /* green color value */ 79 float b; /* blue color value */ 80 float a; /* alpha color value */ 81 82 float r2; /* red color value */ 83 float g2; /* green color value */ 84 float b2; /* blue color value */ 85 float a2; /* alpha color value */ 86 87 float border_r; /* red color value */ 88 float border_g; /* green color value */ 89 float border_b; /* blue color value */ 90 float border_a; /* alpha color value */ 91 92 93 Shape(); 94 ~Shape(); 95 void InitVertexAttrib(); 96 virtual void Draw(RenderContext &context); 97 98 private: 99 100 struct struct_data { 101 float point_x; 102 float point_y; 103 float color_r; 104 float color_g; 105 float color_b; 106 float color_a; 107 float tex_x; 108 float tex_y; 109 }; 110 111 GLuint m_vboID_texture; 112 GLuint m_vaoID_texture; 113 114 GLuint m_vboID_not_texture; 115 GLuint m_vaoID_not_texture; 116 }; 117 118 class Text : RenderItem 119 { 120 }; 121 122 class MotionVectors : public RenderItem 123 { 124 public: 125 float r; 126 float g; 127 float b; 128 float a; 129 float length; 130 float x_num; 131 float y_num; 132 float x_offset; 133 float y_offset; 134 135 void InitVertexAttrib(); 136 void Draw(RenderContext &context); 137 MotionVectors(); 138 }; 139 140 class Border : public RenderItem 141 { 142 public: 143 float outer_size; 144 float outer_r; 145 float outer_g; 146 float outer_b; 147 float outer_a; 148 149 float inner_size; 150 float inner_r; 151 float inner_g; 152 float inner_b; 153 float inner_a; 154 155 void InitVertexAttrib(); 156 void Draw(RenderContext &context); 157 Border(); 158 }; 159 160 struct TypeIdPair { TypeIdPairTypeIdPair161 TypeIdPair(const std::type_info & info1, const std::type_info & info2): id1(info1.name()), id2(info2.name()) {} TypeIdPairTypeIdPair162 TypeIdPair(const std::string & _id1, const std::string & _id2): id1(_id1), id2(_id2) {} 163 std::string id1; 164 std::string id2; operator <TypeIdPair165 inline bool operator<(const TypeIdPair & rhs) const { 166 return this->id1 < rhs.id1 || (this->id1 == rhs.id1 && this->id2 < rhs.id2); 167 } 168 operator >TypeIdPair169 inline bool operator>(const TypeIdPair & rhs) const { 170 return !operator<(rhs) && !operator==(rhs); 171 } 172 operator ==TypeIdPair173 inline bool operator==(const TypeIdPair & rhs) const { 174 return this->id1 == rhs.id1 && this->id2 == rhs.id2; 175 } 176 }; 177 178 #endif 179