]> git.treefish.org Git - phys/latlib.git/blob - culooks.h
Made c++11 standard dependency obsolete.
[phys/latlib.git] / culooks.h
1 #ifndef CULOOKS_H
2 #define CULOOKS_H
3
4 #include <pthread.h>
5 #include <vector>
6 #include <GL/glut.h>
7 #include <GL/glx.h>
8 #include <GL/gl.h>
9 #include <X11/Xlib.h>
10 #include <X11/Xutil.h>
11 #include <string>
12
13 using namespace std;
14
15 class culooks
16 {
17  public:
18   
19   culooks (const char* name, const int& xcubes, const int& ycubes, const int& l, int *argc, char **argv);
20   void setLink (const int& cubeid, const int& posdir,
21                 const float& red, const float& green, const float& blue, const float& alpha);
22   void setPlaq (const int& cubeid, const int& posdir,
23                 const float& red, const float& green, const float& blue, const float& alpha);
24   void swapBuffers();
25   void hidePlaqs(const int& cubeid);
26   void hidePlaqs();
27   void hideLinks(const int& cubeid);
28   void hideLinks();
29   void setBgColor(const float& red, const float& green, const float& blue, const float& alpha);
30   void setWireColor(const float& r, const float& g, const float& b, const float& a);
31   void setFrameWidth(float width);
32   void setLinkWidth(float width);
33
34  private:
35
36   struct comarg {
37     int *argc;
38     char **argv;
39   };
40
41   static comarg comArg;
42   
43   class cube {
44   public:
45     cube (int l);
46     void draw();
47     int id;
48     float az, alt;
49     float azRotSpeed;
50     float zoom;
51     void setLink (const int& posdir, 
52                   const float& red, const float& green, const float& blue, const float& alpha);
53     void setPlaq (const int& posdir, 
54                   const float& red, const float& green, const float& blue, const float& alpha);
55     void swapLinkBuffer();
56     void swapPlaqBuffer();
57     void hidePlaqs();
58     void hideLinks();
59     void setWireColor(const float& r, const float& g, const float& b, const float& a);
60     void setFrameWidth(float width);
61     void setLinkWidth(float width);
62   private:
63     float wireColor[4];
64     void drawAll();
65     void drawBox();
66     static void drawFrame();
67     float *plaq;
68     float *link;
69     float *plaqbuf[2];
70     float *linkbuf[2];
71     int l;
72     int plaqbuf_active;
73     int linkbuf_active;
74     static int allid;
75     bool hideplaquettes;
76     bool hidelinks;
77     float framewidth;
78     float linkwidth;
79   };
80   
81   struct window {
82     int layout[2];
83     double aspect;
84     vector<cube> cubes;
85     int w, h;
86     int gwinid;
87     bool initialized;
88     string name;
89     float bgcolor[4];
90     bool redisplay;
91   };
92
93   class drawing 
94   {
95   private:
96     static int rotcube[3];
97     static culooks::window* getWin();
98     static int getCubeFromPos(int x, int y);
99     static void motionFunc(int x, int y);
100     static void mouseFunc(int button, int state, int x, int y);
101     static void reshapeFunc(int w, int h);
102     static void displayFunc();
103     static void initWindow(int winid);
104     static void idleFunc();
105   public:
106     static void* glutThread(void *leer);
107   };
108   
109   static vector< pair<int,window*> > Windows;
110   static pthread_t glThreadId;
111   static int windowid;
112   int mywid;
113 };
114
115 #endif