[Mesa-dev] How to implement the OpenGL functions

Brian Paul brianp at vmware.com
Thu Feb 7 08:31:23 PST 2013


On 02/07/2013 01:57 AM, Ritvik_Sharma at Dell.com wrote:
> Hi,
>
> If I want to implement some OpesnGL function , say glLoadIdentity.
>
> When I see the function declaration in Mesa or OpenGL its usually
> defined as :
>
> WINGDIAPI void APIENTRY glLoadIdentity (void);
>
> extern PFNGLLOADIDENTITYPROC __gleLoadIdentity;
>
> #define glLoadIdentity __gleLoadIdentity
>
> And on seeing how is this populated in the code I found
>
> __gleLoadIdentity =
> (PFNGLLOADIDENTITYPROC)gleIntGetProcAddress("glLoadIdentity");
>
> Can you guys help me in understanding the function definition of the
> basic openGL functions without having to use GetProcAddress ? Or can
> you suggest an alternative to how can these OpenGL defined?

GLE is an extension "loader" library.  For simple GL apps you don't 
need to use it.

If you're using OpenGL 1.3 or older, all the GL functions should be 
defined in libGL.so and you can just call glLoadIdentity() directly.

When you're using later versions of OpenGL or some OpenGL extensions 
then using an extension helper like GLE or GLEW makes sense because 
you can ignore the GetProcAddress business.  The deal is libGL.so is 
not guaranteed to export those newer/extension functions and the only 
way to access them is through GetProcAddress.

-Brian




More information about the mesa-dev mailing list