]> git.treefish.org Git - phys/latlib.git/blob - culooks.h
...
[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
32  private:
33
34   struct comarg {
35     int *argc;
36     char **argv;
37   };
38
39   static comarg comArg;
40   
41   class cube {
42   public:
43     cube (int l);
44     void draw();
45     int id;
46     float az, alt;
47     float azRotSpeed;
48     float zoom;
49     void setLink (const int& posdir, 
50                   const float& red, const float& green, const float& blue, const float& alpha);
51     void setPlaq (const int& posdir, 
52                   const float& red, const float& green, const float& blue, const float& alpha);
53     void swapLinkBuffer();
54     void swapPlaqBuffer();
55     void hidePlaqs();
56     void hideLinks();
57     void setWireColor(const float& r, const float& g, const float& b, const float& a);
58   private:
59     float wireColor[4];
60     void drawAll();
61     void drawBox();
62     static void drawFrame();
63     float *plaq;
64     float *link;
65     float *plaqbuf[2];
66     float *linkbuf[2];
67     int l;
68     int plaqbuf_active;
69     int linkbuf_active;
70     static int allid;
71     bool hideplaquettes;
72     bool hidelinks;
73   };
74   
75   struct window {
76     int layout[2];
77     double aspect;
78     vector<cube> cubes;
79     int w, h;
80     int gwinid;
81     bool initialized;
82     string name;
83     float bgcolor[4];
84     bool redisplay;
85   };
86
87   class drawing 
88   {
89   private:
90     static int rotcube[3];
91     static culooks::window* getWin();
92     static int getCubeFromPos(int x, int y);
93     static void motionFunc(int x, int y);
94     static void mouseFunc(int button, int state, int x, int y);
95     static void reshapeFunc(int w, int h);
96     static void displayFunc();
97     static void initWindow(int winid);
98     static void idleFunc();
99   public:
100     static void* glutThread(void *leer);
101   };
102   
103   static vector< pair<int,window*> > Windows;
104   static pthread_t glThreadId;
105   static int windowid;
106   int mywid;
107 };
108
109 #endif