diff options
author | Brian Paul <[email protected]> | 2002-12-03 03:13:17 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2002-12-03 03:13:17 +0000 |
commit | 66fa33e5767ff4fb1f6e689cebe8963083bf29ad (patch) | |
tree | 6c35217427c429b04ac2b2b92b46d19d4af0e7b5 /progs/demos/winpos.c | |
parent | 2a7243481a40dee437d4a95ac39b84e550aa98f6 (diff) |
updated to use ARB extensions
Diffstat (limited to 'progs/demos/winpos.c')
-rw-r--r-- | progs/demos/winpos.c | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c index 2dfa9af6007..f6415263d46 100644 --- a/progs/demos/winpos.c +++ b/progs/demos/winpos.c @@ -1,4 +1,4 @@ -/* $Id: winpos.c,v 1.5 2002/04/22 16:03:37 brianp Exp $ */ +/* $Id: winpos.c,v 1.6 2002/12/03 03:13:17 brianp Exp $ */ /* * Example of how to use the GL_MESA_window_pos extension. @@ -12,7 +12,7 @@ #ifdef _WIN32 #include <windows.h> #endif -#define GL_GLEXT_LEGACY +#define GL_GLEXT_PROTOTYPES #include "GL/glut.h" #include "readtex.c" /* a hack, I know */ @@ -30,18 +30,12 @@ static GLubyte *Image; static int ImgWidth, ImgHeight; static GLenum ImgFormat; +static void (*WindowPosFunc)(GLfloat x, GLfloat y); static void draw( void ) { GLfloat angle; - char *extensions; - - extensions = (char *) glGetString( GL_EXTENSIONS ); - if (strstr( extensions, "GL_MESA_window_pos")==NULL) { - printf("Sorry, GL_MESA_window_pos extension not available.\n"); - return; - } glClear( GL_COLOR_BUFFER_BIT ); @@ -50,16 +44,14 @@ static void draw( void ) GLfloat y = 50.0 + 200.0 * sin( angle * M_PI / 180.0 ); /* Don't need to worry about the modelview or projection matrices!!! */ -#ifdef GL_MESA_window_pos - glWindowPos2fMESA( x, y ); -#endif + (*WindowPosFunc)( x, y ); + glDrawPixels( ImgWidth, ImgHeight, ImgFormat, GL_UNSIGNED_BYTE, Image ); } + glFinish(); } - - static void key( unsigned char key, int x, int y ) { (void) x; @@ -71,7 +63,6 @@ static void key( unsigned char key, int x, int y ) } - /* new window size or exposure */ static void reshape( int width, int height ) { @@ -81,6 +72,24 @@ static void reshape( int width, int height ) static void init( void ) { +#ifdef GL_ARB_window_pos + if (glutExtensionSupported("GL_ARB_window_pos")) { + printf("Using GL_ARB_window_pos\n"); + WindowPosFunc = &glWindowPos2fARB; + } + else +#elif defined(GL_ARB_window_pos) + if (glutExtensionSupported("GL_MESA_window_pos")) { + printf("Using GL_MESA_window_pos\n"); + WindowPosFunc = &glWindowPos2fMESA; + } + else +#endif + { + printf("Sorry, GL_ARB/MESA_window_pos extension not available.\n"); + exit(1); + } + Image = LoadRGBImage( IMAGE_FILE, &ImgWidth, &ImgHeight, &ImgFormat ); if (!Image) { printf("Couldn't read %s\n", IMAGE_FILE); @@ -90,7 +99,6 @@ static void init( void ) } - int main( int argc, char *argv[] ) { glutInitWindowPosition(0, 0); |