[Plib-cvs] plib/src/pw pw.h,1.2,1.3 pwWindows.cxx,1.2,1.3 pwX11.cxx,1.2,1.3
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2004-02-24 01:58:10
|
Update of /cvsroot/plib/plib/src/pw In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16914/plib/src/pw Modified Files: pw.h pwWindows.cxx pwX11.cxx Log Message: Added pwOpenWindow to avoid some nasty race conditions. Index: pw.h =================================================================== RCS file: /cvsroot/plib/plib/src/pw/pw.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pw.h 17 Feb 2004 01:43:21 -0000 1.2 +++ pw.h 24 Feb 2004 01:52:06 -0000 1.3 @@ -9,16 +9,15 @@ typedef void pwMouseFunc ( int key, int updown, int x, int y ) ; typedef void pwMousePosFunc ( int x, int y ) ; -void pwInit ( int multisample, int num_samples, - pwKeybdFunc *kb, pwMouseFunc *ms, pwMousePosFunc *mp, - pwResizeCB *rcb = NULL, pwExitCB *ecb = NULL ) ; +void pwInit ( int multisample, int num_samples ) ; void pwInit ( int x, int y, int w, int h, int multisample, - char *title, int border, int num_samples, - pwKeybdFunc *kb, pwMouseFunc *ms, pwMousePosFunc *mp, - pwResizeCB *rcb = NULL, pwExitCB *ecb = NULL ) ; + char *title, int border, int num_samples ) ; +void pwOpenWindow ( pwKeybdFunc *kb = NULL, pwMouseFunc *ms = NULL, + pwMousePosFunc *mp = NULL, pwResizeCB *rcb = NULL, + pwExitCB *ecb = NULL ) ; int pwGetModifiers () ; void pwSwapBuffers () ; Index: pwWindows.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pw/pwWindows.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pwWindows.cxx 23 Feb 2004 11:43:36 -0000 1.2 +++ pwWindows.cxx 24 Feb 2004 01:52:06 -0000 1.3 @@ -11,6 +11,8 @@ #include "pw.h" +static int initialised = 0 ; + static int origin [2] = { 0, 0 } ; static int size [2] = { 640, 480 } ; @@ -133,19 +135,36 @@ } -void pwInit ( int multisample, int num_samples, - pwKeybdFunc *kb, pwMouseFunc *ms, pwMousePosFunc *mp, - pwResizeCB *rcb, pwExitCB *ecb ) +void pwOpenWindow ( pwKeybdFunc *kb, pwMouseFunc *ms, + pwMousePosFunc *mp, pwResizeCB *rcb, pwExitCB *ecb ) +{ + if ( ! initialised ) + { + fprintf ( stderr, "PW: You must not call pwOpenWindow before pwInit.\n" ) ; + exit ( 1 ) ; + } + + kbCB = kb ; + msCB = ms ; + mpCB = mp ; + resizeCB = rcb ; + exitCB = ecb ? ecb : defaultExitFunc ; + + glClear ( GL_COLOR_BUFFER_BIT ) ; + pwSwapBuffers () ; + glClear ( GL_COLOR_BUFFER_BIT ) ; + pwSwapBuffers () ; +} + + +void pwInit ( int multisample, int num_samples ) { pwInit ( 0, 0, -1, -1, multisample, "NoName", FALSE, num_samples, - kb, ms, mp, rcb, ecb ) ; } void pwInit ( int x, int y, int w, int h, int multisample, - char *title, int border, int num_samples, - pwKeybdFunc *kb, pwMouseFunc *ms, pwMousePosFunc *mp, - pwResizeCB *rcb, pwExitCB *ecb ) + char *title, int border, int num_samples ) { currInstance = GetModuleHandleA( NULL ) ; @@ -266,16 +285,12 @@ exit ( 1 ) ; } - kbCB = kb ; - msCB = ms ; - mpCB = mp ; - resizeCB = rcb ; - exitCB = ecb ? ecb : defaultExitFunc ; - - glClear ( GL_COLOR_BUFFER_BIT ) ; - pwSwapBuffers () ; - glClear ( GL_COLOR_BUFFER_BIT ) ; - pwSwapBuffers () ; + kbCB = NULL ; + msCB = NULL ; + mpCB = NULL ; + resizeCB = NULL ; + exitCB = defaultExitFunc ; + initialised = 1 ; } Index: pwX11.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/pw/pwX11.cxx,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- pwX11.cxx 18 Feb 2004 00:28:58 -0000 1.2 +++ pwX11.cxx 24 Feb 2004 01:52:06 -0000 1.3 @@ -74,13 +74,13 @@ #endif - -static int modifiers = 0 ; -static int origin [2] = { 0, 0 } ; -static int size [2] = { 640, 480 } ; -static int currScreen = 0 ; -static int currConnect = 0 ; -static int currCursor = PW_CURSOR_LEFT ; +static int initialised = 0 ; [...69 lines suppressed...] - kbCB = kb ; - msCB = ms ; - mpCB = mp ; - resizeCB = rcb ; - exitCB = ecb ? ecb : defaultExitFunc ; + kbCB = NULL ; + msCB = NULL ; + mpCB = NULL ; + resizeCB = NULL ; + exitCB = defaultExitFunc ; - glClear ( GL_COLOR_BUFFER_BIT ) ; - pwSwapBuffers () ; - glClear ( GL_COLOR_BUFFER_BIT ) ; - pwSwapBuffers () ; + initialised = 1 ; } |