Make a wgl/glXGetProcAddress abstraction available internally. We will need this

to get the new context creation function.


git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@747 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
spanne 2008-11-02 19:38:05 +00:00
parent 097aea69d4
commit 9e30ae3bc0
2 changed files with 18 additions and 14 deletions

View File

@ -29,7 +29,7 @@
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "freeglut_internal.h" #include "freeglut_internal.h"
static GLUTproc fghGetProcAddress( const char* procName ) static GLUTproc fghGetGLUTProcAddress( const char* procName )
{ {
/* optimization: quick initial check */ /* optimization: quick initial check */
if( strncmp( procName, "glut", 4 ) != 0 ) if( strncmp( procName, "glut", 4 ) != 0 )
@ -199,23 +199,25 @@ static GLUTproc fghGetProcAddress( const char* procName )
} }
SFG_Proc fghGetProcAddress( const char *procName )
{
#if TARGET_HOST_MS_WINDOWS
return (SFG_Proc)wglGetProcAddress( ( LPCSTR )procName );
#elif TARGET_HOST_POSIX_X11 && defined( GLX_ARB_get_proc_address )
return (SFG_Proc)glXGetProcAddressARB( ( const GLubyte * )procName );
#else
return NULL;
#endif
}
GLUTproc FGAPIENTRY GLUTproc FGAPIENTRY
glutGetProcAddress( const char *procName ) glutGetProcAddress( const char *procName )
{ {
GLUTproc p; GLUTproc p;
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" ); FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutGetProcAddress" );
/* Try GLUT functions first */ /* Try GLUT functions first, then core GL functions */
p = fghGetProcAddress( procName ); p = fghGetGLUTProcAddress( procName );
if( p != NULL ) return ( p != NULL ) ? p : fghGetProcAddress( procName );
return p;
/* Try core GL functions */
#if TARGET_HOST_MS_WINDOWS
return(GLUTproc)wglGetProcAddress( ( LPCSTR )procName );
#elif TARGET_HOST_POSIX_X11 && defined( GLX_ARB_get_proc_address )
return(GLUTproc)glXGetProcAddressARB( ( const GLubyte * )procName );
#else
return NULL;
#endif
} }

View File

@ -909,6 +909,8 @@ void fgWarning( const char *fmt, ... );
int fgHintPresent(Window window, Atom property, Atom hint); int fgHintPresent(Window window, Atom property, Atom hint);
#endif #endif
SFG_Proc fghGetProcAddress( const char *procName );
#endif /* FREEGLUT_INTERNAL_H */ #endif /* FREEGLUT_INTERNAL_H */
/*** END OF FILE ***/ /*** END OF FILE ***/