X-Git-Url: http://git.treefish.org/~alex/phys/latlib.git/blobdiff_plain/0f815d3fea69adf1ee22cff3a728a4c22cf6e466..2c7e8d0d8fdb233087376cc62752fdc45646c8c8:/culooks_drawing.cpp?ds=inline diff --git a/culooks_drawing.cpp b/culooks_drawing.cpp index fb5773c..65c7644 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,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(); }