Wiki Page Content

Differences between revisions 1 and 2
Revision 1 as of 2010-01-17 22:12:46
Size: 768
Editor: SheenaSmith
Comment: create page, add content
Revision 2 as of 2010-08-04 01:11:24
Size: 2122
Editor: SheenaSmith
Comment: update content (old wiki)
Deletions are marked like this. Additions are marked like this.
Line 19: Line 19:
*Is there a RV for void*? The OpenGL function is passed to the callback function.???* *<<BR>>Returns the address of the GL function proc, or NULL if the function is not found.<<BR>>*

<<Color2(green,
Is there a RV for void*? The OpenGL function is passed to the callback function.???)>>
Line 22: Line 24:
*<<BR>>
Line 23: Line 26:
You can add your code example here 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{
  .
  .
}
Line 25: Line 54:
<<BR>>*
Line 27: Line 57:
''You can add useful comments here'' *<<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).

<<Color2(green,Can't find SDL_!SetVideoMode. Has it been replaced?)>>

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>>*

DRAFT

SDL_GL_GetProcAddress

Use this function to get the address of an OpenGL function.

Syntax

void* SDL_GL_GetProcAddress(const char* proc)

Function Parameters

proc

a pointer to an OpenGL function

Return Value

*
Returns the address of the GL function proc, or NULL if the function is not found.
*

green

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 function work properly, so it should be called after SDL_SetVideoMode() has been called (with the SDL_OPENGL flag).

green

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.
*


CategoryAPI, CategoryVideo

None: SDL_GL_GetProcAddress (last edited 2015-04-26 19:19:12 by PhilippWiesemann)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit