Attached is the second draft of the spec for GL_EXT_get_proc_address.
It incorporates everything I've been able to gather from today's
discussion (so far). I think I've learned a lot today!
This file is under revision control in the Mesa CVS repository in
the docs/ directory, BTW.
-Brian
Name
EXT_get_proc_address
Name Strings
GL_EXT_get_proc_address
Contact
Brian Paul, (brian_paul 'at' mesa3d.org)
Status
Planned for Mesa 3.1 and other OpenGL implementations.
Version
$Id: EXT_get_proc_address.spec,v 1.2 1999/09/09 22:46:38 brianp Exp $
Number
???
Dependencies
The extension is written against the OpenGL 1.2 Specification.
Overview
This extension adds a function (GetProcAddressEXT) which returns
the address of extension functions, given the function name. Since
the availability of extensions (and their functions) cannot be
determined until runtime, the address of extension functions
should be queried at runtime. This function provides a simple,
portable way to do so.
Issues
* Is this extension properly named?
Yes. EXT_get_func_address would be another option though.
* Is void * the appropriate return type?
No, return void (*)()
However, none of these compiles:
extern void (*)() glGetProcAddressEXT( const GLubyte *procName );
extern (void (*))() glGetProcAddressEXT( const GLubyte *procName );
extern (void (*)()) glGetProcAddressEXT( const GLubyte *procName );
etc.
C type declarations- ugh!
This works though:
typedef void (*GLfunction)();
extern GLfunction glGetProcAddressEXT( const GLubyte *procName );
* Should GetProcAddressEXT allow querying of itself?
Yes, for sake of completeness.
* There's a recursion problem with this feature. The purpose of
GetProcAddressEXT is to return pointers to extension functions
and GetProcAddressEXT is itself such a function! This presents
a puzzle to the application developer.
A Linux/OpenGL Standard Base-compliant OpenGL library will
always have GetProcAddressEXT.
* Should extension functions in GLU, GLX, WGL, etc. be queryable through
this extension?
No, the companion functions gluGetProcAddressEXT,
glXGetProcAddressEXT, etc. should be used instead.
Otherwise, all sorts of module abstraction violations have
to be dealt with.
* Should the core functions added in OpenGL 1.1 and 1.2 also be queryable?
Yes. This will allow maximum portability of applications across
OpenGL 1.0, 1.1 and 1.2 library implementations.
* Can a function pointer returned while context A is current be usable
when context B is current (A != B)?
No. Extension entry points can be dependand on the GL context.
New Procedures and Functions
void *GetProcAddressEXT(const ubyte *procName)
New Tokens
None.
Additions to Chapter 2 of the OpenGL 1.2 Specification (OpenGL Operation)
None
Additions to Chapter 3 of the OpenGL 1.2.1 Specification (Rasterization)
None
Additions to Chapter 4 of the OpenGL 1.2.1 Specification (Per-Fragment
Operations and the Frame Buffer)
None
Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special
Functions)
None
Additions to Chapter 6 of the OpenGL 1.2 Specification (State and State
Requests)
Add a new section numbered 6.1.13:
6.1.13 Obtaining Extension Function Pointers
The GL extensions which are available to a client application can
only be determined at runtime. Therefore, the address of extension
functions should be queried at runtime.
The function
void (*)() GetProcAddressEXT(const ubyte *procName);
returns the address of the extension function named by procName.
NULL is returned if the named function is not available in the
currently bound context.
The pointer returned by GetProcAddressEXT should be cast to a
function type which matches the extension function's definition.
If GetProcAddressEXT returns a non-NULL pointer it is not guaranteed
that the particular extension is available. The client application
must also query GetString(EXTENSIONS) to determine if the extension
is present.
The address returned by GetProcAddressEXT can be dependant on the
currently bound context. Therefore, GetProcAddressEXT should be
called for each context in which the extension is to be used.
GetProcAddressEXT can only be used to query functions inside the
main GL library. Specifically, extension functions in GLU, GLX, WGL,
etc. are not obtainable with this function.
Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance)
None
Additions to the GLX / WGL / AGL Specifications
None
GLX Protocol
???
Errors
INVALID_OPERATION is generated if GetProcAddressEXT is called
between Begin and End.
New State
None
Revision History
* Revision 1.1 - initial draft (8 Sep 1999)
* Revision 1.2 - don't allow querying of GLU, GLX, WGL functions
- changed return type to void (*)()
- allow querying of all core functions except those
defined since version 1.0
- clarification of GetProcAddressEXT behaviour with
respect to GL contexts
- updated the Issues section