Windows下OpenGL擴充版本的使用

來源:互聯網
上載者:User

API and Extension Header Files

Because extensions vary from platform to platform and driver to driver, OpenGL developers can't expect 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.

 從上面的官方說明可以看出,OpenGL的開發人員不應該指望OpenGL的一些新的介面特性均包含在標準的gl.h等檔案中,比如windows下提供的是opengl 1.1的介面,那麼如何使用OpenGL2.0或OpenGL4.3等版本的介面呢,這個不用擔心,眾所周知,流行各種擴充庫,而這些擴充庫的原理是什麼呢?

由於OpenGL的優良架構,平台支援動態擴充的查詢,這樣就可以得到這些支援的擴充函數的指標,然後就可以調用。需要注意的是,OpenGL32.dll只是一個介面層,最終會轉向到對顯卡上關於OpenGL驅動的調用,所以升級顯卡及顯卡驅動才是從本質上升級OpenGL的版本。

使用OpenGL Extensions Viewer 可以方便的查看顯卡所支援的OpenGL版本,如下支援到OpenGL 4.3的部分功能:

 

 第一步:得到擴充特性的標誌,比如返回的串中有GL_ARB_internalformat_query,說明支援相關的特性或api擴充glGetInternalformativ()   (從最新的官方glext.h查到)

const char * GetExtStrGL( void ){return (const char *)glGetString(GL_EXTENSIONS);}

第二步:知道了擴充後,就可以調用相對應的api串名了wglGetProcAddress("glGetInternalformativ"),返回對應函數的指標。

PROC wglGetProcAddress(  LPCSTR  lpszProc   // name of the extension function);

glGetString(GL_EXTENSIONS);通常不會得到WGL_的標誌位,可以用下面的代碼得到對應的WGL的擴充(wglext.h):

const char *GetExtStrPlat( void ){wglGetExtensionsStringARB = wglGetProcAddress("wglGetExtensionsStringARB");if (wglGetExtensionsStringARB)return (const char *)wglGetExtensionsStringARB(wglGetCurrentDC());}

然後,再用wglGetProcAddress得到擴充函數指標。

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.