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