|
Size: 2115
Comment: update content (w/ Sam); remove 'draft' note
|
Size: 1785
Comment: update content (w/ Sam)
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 18: | Line 18: |
| Returns a pointer to the named OpenGL function, or NULL if the function is not found. The returned pointer should be cast to the type of function you expect. | Returns a pointer to the named OpenGL function, or NULL if the function is not found. The returned pointer should be cast to the appropriate function signature. |
| Line 52: | Line 52: |
| *<<BR>>If the GL library is loaded at runtime with [[SDL_GL_LoadLibrary]](), then all GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL extensions. Note that this function needs an OpenGL context to ,,function,, ^work^ properly, so it should be called after ,,[[SDL_SetVideoMode]]() has been called (with the SDL_OPENGL flag),, ^initializing the video driver^. | If the GL library is loaded at runtime with [[SDL_GL_LoadLibrary]](), then all GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL extensions. Note that this function needs an OpenGL context to work properly, so it should be called after creating the OpenGL context. |
| Line 54: | Line 54: |
| <<Color2(green,Can't find SDL_!SetVideoMode. Has it been replaced? Is the superscript from SDL_!GL_!LoadLibrary the correct replacement for the above?)>> OpenGL function pointers must be declared APIENTRY as in the example code. This will ensure the proper calling convention is followed on platforms where this matters (Win32) thereby avoiding stack corruption. In a Win32 build environment, APIENTRY should be defined as `__stdcall`. <<BR>>* |
OpenGL function pointers must be declared `APIENTRY` as in the example code. This will ensure the proper calling convention is followed on platforms where this matters (Win32) thereby avoiding stack corruption. |
SDL_GL_GetProcAddress
Use this function to get an OpenGL function by name.
Contents
Syntax
void* SDL_GL_GetProcAddress(const char* proc)
Function Parameters
proc |
the name of an OpenGL function |
Return Value
Returns a pointer to the named OpenGL function, or NULL if the function is not found. The returned pointer should be cast to the appropriate function signature.
Code Examples
typedef void (APIENTRY * GL_ActiveTextureARB_Func)(unsigned int);
GL_ActiveTextureARB_Func glActiveTextureARB_ptr = 0;
int has_multitexture=1;
.
.
.
/* Get function pointer */
glActiveTextureARB_ptr=(GL_ActiveTextureARB_Func) SDL_GL_GetProcAddress("glActiveTextureARB");
/* Check for a valid function ptr */
if(!glActiveTextureARB_ptr){
fprintf(stderr, "Multitexture Extensions not present.\n");
has_multitexture=0;
}
.
.
.
.
if(has_multitexture){
glActiveTextureARB_ptr(GL_TEXTURE0_ARB);
.
.
}
else{
.
.
}
Remarks
If the GL library is loaded at runtime with SDL_GL_LoadLibrary(), then all GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL extensions. Note that this function needs an OpenGL context to work properly, so it should be called after creating the OpenGL context.
OpenGL function pointers must be declared APIENTRY as in the example code. This will ensure the proper calling convention is followed on platforms where this matters (Win32) thereby avoiding stack corruption.
