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