X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/d65d20475798a9e7614e61c46c68a2b77760d4c2..f9812559e766a409abfbd2d3bae519298339ab65:/culooks_drawing.cpp diff --git a/culooks_drawing.cpp b/culooks_drawing.cpp index fb5773c..61dc30a 100644 --- a/culooks_drawing.cpp +++ b/culooks_drawing.cpp @@ -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,51 @@ void culooks::drawing::displayFunc() void culooks::drawing::initWindow(int winid) { + + glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|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); + glEnable(GL_BLEND); + 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(); }