Re: [Plib-devel] [PATCH] Patch for ssg water example
Brought to you by:
sjbaker
From: Bram S. <br...@sa...> - 2005-08-26 19:38:08
|
I'll commit this. Mail me your dsp file... the patch fails on dsp. stolk@suske:~/src/plib/examples/src/ssg/water$ patch --dry-run < ~/water.diff patching file Makefile.am patching file water.cxx patching file water.dsp Hunk #1 FAILED at 23. Hunk #2 FAILED at 50. Hunk #3 FAILED at 74. bram Jan Reucker wrote: > Hello! > > I've just experienced another problem, once again with the water example. > This time it's NVIDIA's fault ;-) > > I recently upgraded my NVIDIA drivers, which included new versions of the > OpenGL headers. The new glext.h now conforms to the OpenGL ABI for Linux > (http://oss.sgi.com/projects/ogl-sample/ABI/): It separates the extension > prototypes from the rest of the header file using the GL_GLEXT_PROTOTYPES > define. According to the ABI paper, > > [quote] > "To define prototypes as well as typedefs, the application must #define > GL_GLEXT_PROTOTYPES prior to including gl.h or glx.h." > [/quote] > > The water demo uses extensions for multitexturing, so compilation fails > (glActiveTexture() seems to be undefined although the implementation > conforms to OpenGL > 1.3). > > The attached patch adds the above #define. I don't know if this effects > other platforms as well. Win32 surely is unaffected (always using OpenGL < 1.3 > and therefore using the ARB extension). > > I've also made some more changes to the example: > > - converted from GLUT to PW (I thought it would be nice to have more > "pure" PLIB examples) > - fixed some compiler warnings (float/double issues, Win32 only) > - use an instance of ssgContext instead of using the deprecated context-related > function calls (I noticed that there's no other example which uses this > class) > > Can someone please review this patch and add it to the CVS? > > Kind regards, > Jan R. > > > > ------------------------------------------------------------------------ > > ? .deps > ? Makefile > ? Makefile.in > ? patch.txt > ? water > ? water.diff > ? water.patch > Index: Makefile.am > =================================================================== > RCS file: /cvsroot/plib/plib/examples/src/ssg/water/Makefile.am,v > retrieving revision 1.4 > diff -u -p -r1.4 Makefile.am > --- Makefile.am 1 Sep 2002 05:22:26 -0000 1.4 > +++ Makefile.am 26 Aug 2005 18:27:37 -0000 > @@ -4,7 +4,7 @@ noinst_PROGRAMS = water > > water_SOURCES = water.cxx > > -water_LDADD = -lplibpu -lplibfnt -lplibssgaux -lplibssg -lplibsg -lplibul $(GLUT_LIBS) $(OGL_LIBS) > +water_LDADD = -lplibpw -lplibpu -lplibfnt -lplibssgaux -lplibssg -lplibsg -lplibul $(OGL_LIBS) > > endif > > Index: water.cxx > =================================================================== > RCS file: /cvsroot/plib/plib/examples/src/ssg/water/water.cxx,v > retrieving revision 1.26 > diff -u -p -r1.26 water.cxx > --- water.cxx 29 Dec 2004 07:19:40 -0000 1.26 > +++ water.cxx 26 Aug 2005 18:27:39 -0000 > @@ -21,6 +21,11 @@ > $Id: water.cxx,v 1.26 2004/12/29 07:19:40 sjbaker Exp $ > */ > > +#define PU_USE_PW > + > +#ifndef GL_GLEXT_PROTOTYPES > +#define GL_GLEXT_PROTOTYPES > +#endif > > #include <stdio.h> > #include <stdlib.h> > @@ -32,20 +37,11 @@ > # include <unistd.h> > #endif > #include <math.h> > +#include <plib/pw.h> > #include <plib/ssg.h> > #include <plib/ssgAux.h> > #include <plib/pu.h> > > -#ifdef FREEGLUT_IS_PRESENT > -# include <GL/freeglut.h> > -#else > -# ifdef __APPLE__ > -# include <GLUT/glut.h> > -# else > -# include <GL/glut.h> > -# endif > -#endif > - > #ifndef GL_VERSION_1_3 > // ARB_multitexture > #define GL_TEXTURE0 GL_TEXTURE0_ARB > @@ -53,8 +49,8 @@ > #define glActiveTexture glActiveTextureARB > #endif > > -#define GUI_BASE 80 > -#define VIEW_GUI_BASE 20 > +#define GUI_BASE 90 > +#define VIEW_GUI_BASE 30 > #define FONT_COLOUR 1,1,1,1 > > static puSlider *trainLengthSlider = (puSlider *) NULL ; > @@ -98,6 +94,8 @@ static ssgSimpleState *splash_state > static ssgSimpleState *teapot_state = NULL ; > static ssgSimpleState *plinth_state = NULL ; > > +static ssgContext *context = NULL ; > + > static ssgaWaveTrain trains [ 16 ] ; > > static char *trainNameList[] = > @@ -109,6 +107,8 @@ static char *trainNameList[] = > NULL > } ; > > +static int quit = FALSE; > + > static int curr_train = 0 ; > static int curr_depthfunc = 0 ; > static int wireframe = FALSE ; > @@ -425,8 +425,8 @@ static float stepFunction ( float x, flo > > static float twoBeaches ( float x, float y ) > { > - return fabs ( sin( x / ocean->getSize()[0]) * > - sin(2.0f * y / ocean->getSize()[1]) * 1.5 + 0.5 ) ; > + return (float) fabs ( sin( x / ocean->getSize()[0]) * > + sin(2.0f * y / ocean->getSize()[1]) * 1.5 + 0.5 ) ; > } > > static const ssgaWSDepthCallback depthFuncs [] = > @@ -478,22 +478,23 @@ static void update_motion () > ck . update () ; > > double t = ck . getAbsTime () ; > - float dt = ck . getDeltaTime () ; > + float dt = (float) ck . getDeltaTime () ; > > - ocean -> setWindDirn ( 25.0 * sin ( t / 100.0 ) ) ; > - ocean -> updateAnimation ( t ) ; > + ocean -> setWindDirn ( (float)( 25.0 * sin ( t / 100.0 ) ) ) ; > + ocean -> updateAnimation ( (float) t ) ; > > fountain -> update ( dt ) ; > fire_obj -> update ( dt ) ; > > - dt = ck . getDeltaTime () ; > + dt = (float) ck . getDeltaTime () ; > > sprintf ( s, "CalcTime=%1.1fms", dt * 1000.0 ) ; > timeText->setLabel ( s ) ; > sgCoord tptpos ; > > - sgSetCoord ( & tptpos, 0.0f, 0.0f, 0.6f, t * 60, 0.0f, 0.0f ) ; > - ssgSetCamera ( & campos ) ; > + context -> setCamera ( & campos ) ; > + > + sgSetCoord ( & tptpos, 0.0f, 0.0f, 0.6f, (float)(t * 60), 0.0f, 0.0f ) ; > teapot -> setTransform ( & tptpos ) ; > sgSetCoord ( & tptpos, 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f ) ; > fire -> setTransform ( & tptpos ) ; > @@ -502,7 +503,7 @@ static void update_motion () > > > /* > - The GLUT window reshape event > + The PW window reshape event > */ > > static void reshape ( int w, int h ) > @@ -513,32 +514,28 @@ static void reshape ( int w, int h ) > > > /* > - The GLUT keyboard/mouse events > + The PW keyboard/mouse events > */ > > - > -static void keyboard ( unsigned char key, int, int ) > +static void keyboard ( int key, int updown, int, int ) > { > - if ( ! puKeyboard ( key, PU_DOWN ) ) > + if ( ! puKeyboard ( key, updown ) && ( updown == PU_DOWN ) ) > { > switch ( key ) > { > - case ' ' : displayGUI = ! displayGUI ; break ; > - > - case 0x03 : exit ( 0 ) ; > - > - default : displayGUI = ! displayGUI ; break ; > + case 0x03 : > + case 0x1B : > + case 'q' : > + exit ( 0 ) ; > + > + case ' ' : > + default : > + displayGUI = ! displayGUI ; > + break ; > } > } > } > > - > -static void specialfn ( int key, int x, int y ) > -{ > - puKeyboard ( key + PU_KEY_GLUT_SPECIAL_OFFSET, PU_DOWN ) ; > -} > - > - > static void motionfn ( int x, int y ) > { > if ( displayGUI ) > @@ -554,57 +551,44 @@ static void mousefn ( int button, int up > > > /* > - The GLUT redraw event > + The redraw function > */ > > -static void redraw () > +static void main_loop () > { > - update_motion () ; > - > - glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; > - > - if ( wireframe ) > - glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ; > - else > + while ( !quit ) > + { > + update_motion () ; > + > + glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ; > + > + if ( wireframe ) > + glPolygonMode ( GL_FRONT_AND_BACK, GL_LINE ) ; > + else > + glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ; > + > + ssgCullAndDraw ( scene ) ; > + > glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ; > - > - ssgCullAndDraw ( scene ) ; > - > - glPolygonMode ( GL_FRONT_AND_BACK, GL_FILL ) ; > - > - if ( displayGUI ) > - puDisplay () ; > - > - glutPostRedisplay () ; > - glutSwapBuffers () ; > + > + if ( displayGUI ) > + puDisplay () ; > + > + pwSwapBuffers () ; > + } > + > + pwCleanup () ; > } > > > > static void init_graphics () > { > - int fake_argc = 1 ; > - char *fake_argv[3] ; > - fake_argv[0] = "ssgExample" ; > - fake_argv[1] = "Simple Scene Graph : Example Program." ; > - fake_argv[2] = NULL ; > - > /* > - Initialise GLUT > + Initialise PW > */ > - > - glutInitWindowPosition ( 0, 0 ) ; > - glutInitWindowSize ( 640, 480 ) ; > - glutInit ( &fake_argc, fake_argv ) ; > - glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ) ; > - glutCreateWindow ( fake_argv[1] ) ; > - glutDisplayFunc ( redraw ) ; > - glutReshapeFunc ( reshape ) ; > - glutKeyboardFunc ( keyboard ) ; > - glutSpecialFunc ( specialfn ) ; > - glutMouseFunc ( mousefn ) ; > - glutMotionFunc ( motionfn ) ; > - glutPassiveMotionFunc ( motionfn ) ; > + pwInit ( 50, 50, 640, 480, FALSE, "Simple Scene Graph : Water Example Program.", TRUE, 0) ; > + pwSetCallbacks ( keyboard, mousefn, motionfn, reshape ) ; > > puInit () ; > ssgInit () ; > @@ -619,9 +603,10 @@ static void init_graphics () > /* > Set up the viewing parameters > */ > - > - ssgSetFOV ( 60.0f, 0.0f ) ; > - ssgSetNearFar ( 1.0f, 700.0f ) ; > + context = new ssgContext () ; > + context -> setFOV ( 60.0f, 0.0f ) ; > + context -> setNearFar ( 1.0f, 700.0f ) ; > + context -> makeCurrent () ; > > /* > Set up the Sun. > @@ -866,7 +851,7 @@ static void init_gui () > trainEnableButton->setLabelPlace ( PUPLACE_CENTERED_LEFT ) ; > trainEnableButton->setColour( PUCOL_LABEL, FONT_COLOUR ) ; > > - trainDisableButton = new puOneShot( 450, GUI_BASE+109, > + trainDisableButton = new puOneShot( 450, GUI_BASE+120, > "Disable All WaveTrains" ) ; > trainDisableButton->setCallback ( trainDisableButton_cb ) ; > > @@ -986,7 +971,7 @@ static void init_gui () > > timeText = new puText ( 500, VIEW_GUI_BASE+80 ) ; > timeText->setColour( PUCOL_LABEL, FONT_COLOUR ) ; > - > + > window_group->close () ; > } > > @@ -999,7 +984,7 @@ int main ( int, char ** ) > init_graphics () ; > load_database () ; > init_gui () ; > - glutMainLoop () ; > + main_loop () ; > return 0 ; > } > > Index: water.dsp > =================================================================== > RCS file: /cvsroot/plib/plib/examples/src/ssg/water/water.dsp,v > retrieving revision 1.4 > diff -u -p -r1.4 water.dsp > --- water.dsp 25 Mar 2004 18:26:07 -0000 1.4 > +++ water.dsp 26 Aug 2005 18:27:39 -0000 > @@ -23,6 +23,8 @@ CFG=water - Win32 Debug > > # Begin Project > # PROP AllowPerConfigDependencies 0 > +# PROP Scc_ProjName "" > +# PROP Scc_LocalPath "" > CPP=cl.exe > RSC=rc.exe > > @@ -48,7 +50,7 @@ BSC32=bscmake.exe > # ADD BSC32 /nologo > LINK32=link.exe > # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 > -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui.lib fnt.lib ssgAux.lib ssg.lib sg.lib ul.lib winmm.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /machine:I386 /out:"water.exe" /libpath:"..\..\..\..\..\plib" > +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pw.lib pui.lib fnt.lib ssgAux.lib ssg.lib sg.lib ul.lib winmm.lib opengl32.lib glu32.lib /nologo /subsystem:console /machine:I386 /out:"water.exe" /libpath:"..\..\..\..\..\plib" > > !ELSEIF "$(CFG)" == "water - Win32 Debug" > > @@ -72,7 +74,7 @@ BSC32=bscmake.exe > # ADD BSC32 /nologo > LINK32=link.exe > # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept > -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pui_d.lib fnt_d.lib ssgAux_d.lib ssg_d.lib sg_d.lib ul_d.lib winmm.lib opengl32.lib glu32.lib glut32.lib /nologo /subsystem:console /debug /machine:I386 /out:"water.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib" > +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pw_d.lib pui_d.lib fnt_d.lib ssgAux_d.lib ssg_d.lib sg_d.lib ul_d.lib winmm.lib opengl32.lib glu32.lib /nologo /subsystem:console /debug /machine:I386 /out:"water.exe" /pdbtype:sept /libpath:"..\..\..\..\..\plib" > > !ENDIF > |