]> git.treefish.org Git - phys/latlib.git/blobdiff - culooks_drawing.cpp
made hypercache multi-observable.
[phys/latlib.git] / culooks_drawing.cpp
index fb5773c6f11bda0675ce298e1bac829f49a3863e..65c7644f61671f500750e18b2a9fa730989b9d1e 100644 (file)
@@ -93,8 +93,8 @@ void culooks::drawing::reshapeFunc(int w, int h)
 void culooks::drawing::displayFunc()
 {
   culooks::window *Win = getWin();
-    
-  glClearColor(0,0,0,0);
+
+  glClearColor(Win->bgcolor[0], Win->bgcolor[1], Win->bgcolor[2], Win->bgcolor[3]);
   glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
     
   glMatrixMode(GL_MODELVIEW);
@@ -118,33 +118,50 @@ void culooks::drawing::displayFunc()
  
 void culooks::drawing::initWindow(int winid)
 {
+  
+  glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH);
   glutInitWindowSize(culooks::Windows[winid].second->w, culooks::Windows[winid].second->h);
   glutInitWindowPosition(winid*100,winid*100);
   glutCreateWindow( ("culooks / " + culooks::Windows[winid].second->name).c_str() );
-    
+
+  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
+  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);      
+  glHint(GL_POINT_SMOOTH_HINT, GL_NICEST);     
+  glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
+
   glutDisplayFunc(&drawing::displayFunc);
   glutReshapeFunc(&drawing::reshapeFunc);
   glutMotionFunc(&drawing::motionFunc);
   glutMouseFunc(&drawing::mouseFunc);
-
-  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
-  glEnable( GL_BLEND );
+  glutIdleFunc(&drawing::idleFunc);
 
   culooks::Windows[winid].first = glutGetWindow();
-
   culooks::Windows[winid].second->initialized = true;
+  culooks::Windows[winid].second->redisplay = true;
 }
 
-void culooks::drawing::idleFunc_master()
+void culooks::drawing::idleFunc()
 {
-  for (int iwin=0; iwin < culooks::Windows.size(); iwin++)
+  int activeWindow = glutGetWindow();
+
+  for (int iwin=0; iwin < culooks::Windows.size(); iwin++) {
     if (!culooks::Windows[iwin].second->initialized)
       initWindow(iwin);
+    if (culooks::Windows[iwin].second->redisplay) {
+      glutSetWindow(culooks::Windows[iwin].first);
+      glutPostRedisplay();
+      culooks::Windows[iwin].second->redisplay = false;
+    }
+  }
+
+  glutSetWindow(activeWindow);
 }
 
-void* culooks::drawing::glutThread(void *leer)
+void* culooks::drawing::glutThread(void *_comArg)
 {
+  comarg *comArg = (comarg*)_comArg;
+  glutInit(comArg->argc, comArg->argv);
   initWindow(0);
-  glutIdleFunc(&idleFunc_master);
   glutMainLoop();
 }