From: StApostol <sta...@gm...> - 2008-09-27 22:04:41
|
> Windows defines its function entrypoints for the > stuff in gl.h, not as function pointers, but as live functions. I doubt > that wglGetExtension will work for them. So I'm not entirely sure how to > go about handling this part. Any suggestions? You are right regarding wglGetExtension not working with these functions (or at least not consistently). To make matters worse, different platforms expose different subsets dynamically, making things tricky. Solution: 0. Define all signatures. Define static imports for all core functions (i.e. versions 1.0-3.0). These are not exposed to the user. 1. Define all functions as function pointers. This is the public API. 2. Load each function dynamically (wgl/glx/aglGetAddress). If the function pointer is *not* -1, 0, 1, 2 or 3 use it. If it is and the function is core, use the relevant static export instead. Otherwise "arm" the pointer with NULL. I am using this method in Tao/OpenTK with success. It works on all platforms and is reliable. Notes: a. Some nvidia drivers return invalid function pointers (-1, 1, 2, 3), so you have to take this into account. b. On windows, different contexts may return different function pointers. This is normally not an issue, as it only happens between different renderers (e.g. microsoft GDI and an accelerated context). Still, I prefer to provide a "reload" function to the user in case it's needed. |