]> git.treefish.org Git - phys/latlib.git/blobdiff - culooks.cpp
...
[phys/latlib.git] / culooks.cpp
index b54eddd2394f31d7fe14309e53530d7e2b72f229..cb5eda7ffde80f186a1600be00e50d32ba8aeac4 100644 (file)
@@ -1,5 +1,13 @@
 #include "culooks.h"
 
 #include "culooks.h"
 
+#include <vector>
+#include <GL/glut.h>
+#include <GL/glx.h>
+#include <GL/gl.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <iostream>
 #include <math.h>
 
 vector< pair<int,culooks::window*> > culooks::Windows;
 #include <math.h>
 
 vector< pair<int,culooks::window*> > culooks::Windows;
@@ -7,94 +15,8 @@ pthread_t culooks::glThreadId;
 
 int culooks::windowid = 0;
 
 
 int culooks::windowid = 0;
 
-int culooks::cube::allid = 0;
-
 using namespace std;
 
 using namespace std;
 
-void culooks::cube::draw()
-{
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-
-  //cout << zoom << endl;
-
-  glScalef(zoom, zoom, zoom);
-  glRotatef(az, 0, 1, 0);
-  glRotatef(alt, 1, 0, 0);
-
-  /*
-  glBegin(GL_QUADS);
-  glVertex2f(-1, -1); glVertex2f(1, -1); glVertex2f(1, 1); glVertex2f(-1, 1);
-  glEnd();
-  */
-
-  //drawBox();
-  drawAll();
-
-  glPopMatrix();
-}
-
-void culooks::cube::drawAll()
-{
-  glMatrixMode(GL_MODELVIEW);
-  glPushMatrix();
-
-  glTranslatef(-1,-1,-1);
-
-  for (int iz=0; iz<l; iz++) {
-    for (int iy=0; iy<l; iy++) {
-      for (int ix=0; ix<l; ix++) {
-       glPushMatrix();
-       glTranslatef(2.0*ix/l,2.0*iy/l,2.0*iz/l);
-       glScalef(2.0/l,2.0/l,2.0/l);
-
-       /* draw links */
-       glBegin(GL_LINES);
-       glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 0],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 1],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 2],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 3]);
-       glVertex3f(0,0,0); glVertex3f(1,0,0);
-       glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 0],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 1],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 2],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 3]);
-       glVertex3f(0,0,0); glVertex3f(0,1,0);
-       glColor4f(link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 0],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 1],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 2],
-                 link[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 3]);
-       glVertex3f(0,0,0); glVertex3f(0,0,1);
-       glEnd();
-
-       /* draw plaquettes */
-       glColor4f(1,1,1,0.5);
-       glBegin(GL_QUADS);
-       glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 0],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 1],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 2],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 2*4 + 3]);
-       glVertex3f(0, 0, 0); glVertex3f(1, 0, 0); glVertex3f(1, 1, 0); glVertex3f(0, 1, 0);
-       glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 0],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 1],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 2],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 1*4 + 3]);
-       glVertex3f(0, 0, 0); glVertex3f(1, 0, 0); glVertex3f(1, 0, 1); glVertex3f(0, 0, 1);
-       glColor4f(plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 0],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 1],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 2],
-                 plaq[iz*l*l*3*4 + iy*l*3*4 + ix*3*4 + 0*4 + 3]);
-       glVertex3f(0, 0, 0); glVertex3f(0, 1, 0); glVertex3f(0, 1, 1); glVertex3f(0, 0, 1);
-       glEnd();
-
-       glPopMatrix();
-      }
-    }
-  }
-    
-  glPopMatrix();
-}
-
 namespace mygl 
 {
   int rotcube[3];
 namespace mygl 
 {
   int rotcube[3];
@@ -239,10 +161,8 @@ namespace mygl
        initWindow(iwin);
   }
 
        initWindow(iwin);
   }
 
-  static void* glutThread(void *_wincon)
+  static void* glutThread(void *leer)
   {
   {
-    culooks::wincontext *wincon = (culooks::wincontext *)_wincon;
-    glXMakeCurrent( wincon->gDisplay, wincon->gDrawable, wincon->gContext );
     initWindow(0);
     glutIdleFunc(&idleFunc_master);
     glutMainLoop();
     initWindow(0);
     glutIdleFunc(&idleFunc_master);
     glutMainLoop();
@@ -288,32 +208,11 @@ culooks::culooks (const char* name, const int& xcubes, const int& ycubes, const
   Windows.push_back( pair<int,culooks::window*>(0, Win) );
   
   if (windowid == 0) {
   Windows.push_back( pair<int,culooks::window*>(0, Win) );
   
   if (windowid == 0) {
-    wincon.gContext = glXGetCurrentContext();
-    wincon.gDisplay = glXGetCurrentDisplay();
-    wincon.gDrawable = glXGetCurrentDrawable();
-
     glXMakeCurrent(0,0,0);
     glXMakeCurrent(0,0,0);
-
-    pthread_create(&glThreadId, 0, &mygl::glutThread, &wincon);
+    pthread_create(&glThreadId, 0, &mygl::glutThread, NULL);
   }
 
   mywid = windowid;
   windowid++;
 }
 
   }
 
   mywid = windowid;
   windowid++;
 }
 
-culooks::cube::cube(int _l)
-{
-  l = _l;
-  link = new float[l*l*l*3 * 4];
-  plaq = new float[l*l*l*3 * 4];
-  az = 30;
-  alt = -20;
-  zoom = 0.6;
-  id = allid;
-  allid++;
-
-  for (int i=0; i<l*l*l*3; i++) {
-    link[i*4+0]=1; link[i*4+3]=0.6;
-    plaq[i*4+1]=1; plaq[i*4+3]=0.2;
-  }
-}