[Openal] Initializing effects extension
Chris Robinson
chris.kcat at gmail.com
Thu Apr 9 14:26:54 PDT 2009
On Thursday 09 April 2009 12:36:50 pm Margin Marh wrote:
> You was right it fixed the error but before i go to tutorial 2 i don't
>
> understand 2 parts in the code...What does this part means :
> > alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects");
> > alDeleteEffects =
> > (LPALDELETEEFFECTS)alGetProcAddress("alDeleteEffects");
> > alIsEffect = (LPALISEFFECT)alGetProcAddress("alIsEffect");
>
> I dont understand that part very well so some explanation would be welcomed
>
> :)
alGenEffects (and alDeleteEffects and the others) are pointers to the
functions you want to use. alGetProcAddress will return the pointer to the
named function as a void*. By itself, just
alGenEffects = alGetProcAddress("alGenEffects");
would be sufficient, except most C/C++ compilers won't let that work without
warnings or errors (they don't like implicitly casting void* to function
pointer types).
So, you have to explicitly cast the void* to the function pointer type when
assigning it. LPALGENEFFECTS is a typedef defined by efx.h as a pointer type
to the alGenEffects function.
alGenEffects = (LPALGENEFFECTS)alGetProcAddress("alGenEffects");
^ ^ ^ ^ ^ ^ ^ ^ ^ ^
func pointer cast to func pointer returns func pointer as void*
So alGetProcAddress returns the pointer to alGenEffects as a void*, which is
then cast to the LPALGENEFFECTS type, and then assigned to your function
pointer.
Hope that clarifies. :)
More information about the Openal
mailing list