[Plib-devel] PUI 1.3.0 in Multiple Windows
Brought to you by:
sjbaker
From: <fa...@tc...> - 2000-07-17 20:28:28
|
ssg animationThe following source code changes will allow the PUI in PLIB 1.3.0 to operate in multiple windows. I developed this using MSVC 6 on a Windows 98 computer, but it isn't very exotic and should be easily portable. (1) pu.h, line 461: add a variable "int window ;" to the definition of a "puObject". This variable will contain the GLUT window containing the PUI widget. (2) pu.h, line 469: add the test "&& window == glutGetWindow()" to the "isHit" function. This way a widget will be hit only if it is in the active window. (3) pu.h, lines 612-623: add the methods "getWindow()" and "setWindow(int w)" to the definition of a "puObject". The contents of the methods should be self-explanatory. I haven't actually used the methods, but I think they should be there in case someone wants them. (4) (optional) pu.h, line 309: prototype the function "void puDisplay ( int window_number ) ;" pu.cxx, line 216: add the function "void puDisplay ( int window_number )": void puDisplay ( int window_number ) /* Redraw only the current window */ { puSetOpenGLState () ; puInterface *base_interface = puGetUltimateLiveInterface () ; puObject *ob = base_interface -> getFirstChild () ; while ( ob ) { if ( ob -> getWindow () == window_number ) { ob -> draw ( 0, 0 ) ; break ; } ob = ob -> getNextObject () ; } int h = puGetWindowHeight () ; if ( _puCursor_enable ) puDrawCursor ( _puCursor_x, h - _puCursor_y ) ; puRestoreOpenGLState () ; } This function assumes that all the widgets in the given window are listed under a "puGroup" widget in that window which is listed directly under the ultimate live interface. I added this function to try to speed up execution some, figuring that the program shouldn't have to redraw the widgets in an inactive window. It is not necessary for the multiple window capability. (5) (multiple places): At the start of each "draw" function (except "puGroup" and "puInterface"), add the following test: if ( window != glutGetWindow () ) return ; /* check for the correct window */ (6) (multiple places): At the start of each "checkKey" function (except "puGroup" and "puInterface"), add the following test: if ( window != glutGetWindow () ) return FALSE ; /* Check for the correct window */ The exceptions in (5) and (6) (not testing the window in "puGroup" and "puInterface") allow the user to put widgets in windows in any order at all. This is more general than the arrangement supported by (4). I'm not sure which is better, the general case or the more restricted case. I generated these changes as an upgrade from my previous version of PUI, which I customized to use multiple windows. I've checked the changes out somewhat, but only on my system and only with a small modification to the "complex.cxx" program. (Anybody who wants a copy of the modified "complex.cxx" can e-mail me and I will send it to him.) There is one problem that I found, which is that a PUI-defined cursor is drawn in every window all the time. If someone knows why this would happen and how to fix it I would greatly appreciate hearing about it. John F. Fay joh...@eg... |