API and extension header files
Because extensions vary from platform to platform and driver to driver, OpenGL developers can't perform CT interfaces for all extensions to be defined in the standard GL. h, Glx. h, and WGL. h header files. additional header files-glext. h, glxext. h, and wglext. h
-Are provided here.
These headers define interfaces (enumerants, prototypes, and for platforms supporting dynamic runtime extension queries, such as Linux and Microsoft Windows, function pointer typedefs) for all registered extensions.
From the official notes above, we can see that OpenGL developers should not expect some new interface features of OpenGL to be included in the standard GL. H and other files. For example, if the OpenGL 1.1 interface is provided in windows, do not worry about how to use interfaces of opengl2.0 or opengl4.3. As we all know, various extension libraries are popular, what are the principles of these extended libraries?
Thanks to the excellent architecture of OpenGL, the platform supports dynamic extended queries. In this way, you can obtain the pointers of these extended functions and then call them. It should be noted that opengl32.dll is only an interface layer and will eventually be switched to calling OpenGL driver on the graphics card. Therefore, upgrading the graphics card and graphics card driver is essentially an OpenGL version.
OpenGL extensions Viewer allows you to conveniently view the OpenGL versions supported by the video card. The following are some functions supported by OpenGL 4.3:
Step 1: Get the extension feature flag. For example, the returned string contains gl_arb_internalformat_query, which indicates support for the related features or API extension glgetinternalformativ () (from the latest official glext. h)
const char * GetExtStrGL( void ){return (const char *)glGetString(GL_EXTENSIONS);}
Step 2: after knowing the extension, you can call the corresponding API string named wglgetprocaddress ("glgetinternalformativ") and return the pointer of the corresponding function.
PROC wglGetProcAddress( LPCSTR lpszProc // name of the extension function);
Glgetstring (gl_extensions); Generally, WGL _ is not obtained. You can use the following code to obtain the corresponding WGL extension (wglext. h ):
const char *GetExtStrPlat( void ){wglGetExtensionsStringARB = wglGetProcAddress("wglGetExtensionsStringARB");if (wglGetExtensionsStringARB)return (const char *)wglGetExtensionsStringARB(wglGetCurrentDC());}
Then, use wglgetprocaddress to get the extension function pointer.