Use of OpenGL extension in Windows

Source: Internet
Author: User

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.

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.