Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
circle.hpp
1 //////////////////////////////
2 //
3 // File: lxs/coregraphics/circle.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Jun 10 2014
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_CIRCLE__
15 #define __LXS_CIRCLE__
16 #include "helper/opengl.h"
17 #include<vector>
18 #include<string>
19 #include<map>
20 #include<boost/shared_ptr.hpp>
21 namespace LxS
22 {
23  namespace CoreGraphics
24  {
25  class Renderable;
26  //! circle - a generalized cut out section of a circle
27  class Circle : public Renderable
28  {
29  boost::shared_ptr<Shader> p_ShaderForReal;
30 
31  std::vector<GLfloat> vertices;
32  //!indices to squares as triangles (for rendering in GLES using vertex list)
33  std::vector<GLshort> indices;
34  //! structure representing character position - xywh - on a texture
35  float fraction; //0-1
36  float radius_in;
37  float radius_ex;
38 
39  float r1;
40  float g1;
41  float b1;
42  float a1;
43  float r2;
44  float g2;
45  float b2;
46  float a2;
47 
48  float pos_x;
49  float pos_z;
50  float pos_y;
51  float axis_x;
52  float axis_z;
53  float axis_y;
54  int resolution; // num of quads for full ring
55 
56  //! fill vertices/indices accordingly to setup
57  void Generate();
58  public:
59  Circle();
60  //! which fraction of circle will be drawn; by default entire circle=1 (and thus half circle = 0.5)
61  void SetFraction(float f);
62  //! currently configured fraction
63  float GetFraction() {return fraction;}
64  //! external and internal radius; if internal is 0 and external is nonzero, full circle will be drawn
65  void SetRadius(float r1,float r2);
66  //! center of the circle
67  void SetCenter(float x,float y, float z=0);
68  //! axis of the circle (by default 0,0,-1)
69  void SetAxis(float x,float y, float z);
70  //! initialize the circle
71  void Initialize(); // load and set up some resources
72 
73  //! color of first fraction;
74  void SetColor1(float r, float g, float b, float a);
75  //! color of first fraction;
76  void SetColor2(float r, float g, float b, float a);
77  //! render a circle
78  void Render(Rendermode mode);
79  void Animate(float dt) {}
80  void UnloadResources() {}
81  unsigned long GetFacesCount();
82  unsigned long GetTexelsCount() { return 0;}
83  };
84  }
85 }
86 
87 #endif
88 
89