The code seams to work properly for this functions.
The code you gave, as it is, will not compile, unless something magical happens within the ellipses
And it’s not so much a question of whether or not it works so much as it’s a question of correctness. The extension string provides the driver developers with a way to advertise specific extensions that are intended for use. While you may be able to get a pointer to a function, this does not imply that it is usable; it means only that it has been exported.
You may want to look at the extension loading package that Obli mentioned. I’ve never used them, so I’ll leave judgement to someone who has. But if you’re determined to do it yourself, consider the following.
Suppose that in a header file, “Extensions.h”, you had something like this:
#ifndef EXT
#define EXT(extension,type,name) extern type name;
#endif
...
// These names are in glext.h
EXT( GL_ARB_window_pos, PFNGLWINDOWPOS2IARBPROC, glWindowPos2iARB )
...
#undef EXT
And in a corresponding source file you had something like this:
...
#define EXT( extension, type, name ) type name = NULL;
#include "Extensions.h"
void initExtensions()
{
#define EXT( extension, type, name )\
if( !isExtensionSupported(#extension) )\
exit(1);\
name = (type)wglGetProcAddress(#name);\
if( name == NULL )\
exit(1);
#include "Extensions.h"
#undef EXT
}
...
Get the idea? This is just a rough example of what’s possible. Chief among benefits of this approach is that we avoid typing the extension names more than once, thus averting a possible source of errors. We also get a fully automated system; we can add extensions to our header file as we see fit, with no additional actions required.
The one hitch to all this is the windowing system specific extensions. The problem is that in order to query the WGL extensions we need the WGL extensions string, which in turn is retrieved through an extension. We must therefore rely on wglGetProcAddress returning NULL if this extension isn’t supported. In fact, it is specified to work in exactly that way:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_extensions_string.txt
Fortunately, this is the only WGL extension we must retrieve in this fashion; the rest may be queried in exactly the same way as before, using the WGL extension string instead of the one return by glGetString. So consider retrieving both strings up front–during context initialization, for example.