• Welcome to Jose's Read Only Forum 2023.
 

WGL extensions: How to get them all?

Started by Petr Schreiber, August 24, 2011, 09:15:14 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Petr Schreiber

I found it interesting that glGetString(GL_EXTENSIONS) returns just one WGL extension. The reason is unknown :), but if you need to query WGL extensions, it is much better idea to use wglGetExtensionStringARB.

The following code snippet does it for you:

DECLARE FUNCTION wglGetExtensionStringARB_Prototype(BYVAL hDc AS DWORD) AS DWORD

...

LOCAL WGLInfoPTR AS ASCIIZ PTR
LOCAL WGLExtensions AS STRING

DIM wglGetExtensionStringARB_Address AS DWORD
wglGetExtensionStringARB_Address = wglGetProcAddress("wglGetExtensionsStringARB")

IF wglGetExtensionStringARB_Address THEN
  CALL DWORD wglGetExtensionStringARB_Address USING wglGetExtensionStringARB_Prototype(hDC) TO WGLInfoPTR
  WGLExtensions = UCASE$(@WGLInfoPTR)+" "
END IF


Maybe this could be useful addition to the headers, as WGL extensions have big power (query of each GPU memory on ATi hardware and so on).


Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

José Roca

 
The headers include the CWGLEXT class (in CWGLEXT.inc), that wraps all the GWLEXT functions. The prototypes for the functions are in WGLEXT.inc.

You create an instance of the class with:


LOCAL pWglExt AS IWGLEXT
pWglExt = CLASS "CWGLEXT"


Then you call the method that has the same name and parameters that the WGLEXT functions, e.g.


LOCAL WGLExtensions AS STRING
WGLExtensions = pWglExt.wglGetExtensionsStringARB(hdc)


If the address of the WGL function isn't found, OBJRESULT returns the error &H8007007F&, which is the HRESULT equivalent to the system error code ERROR_PROC_NOT_FOUND.

The code of the method for wglGetExtensionsStringARB is as follows:


   ' =====================================================================================
   ' const char * wglGetExtensionsStringARB (HDC hdc);
   ' =====================================================================================
   METHOD wglGetExtensionsStringARB (BYVAL hdc AS DWORD) AS STRING
      LOCAL pRes AS ASCIIZ PTR
      LOCAL pProc AS DWORD
      pProc = wglGetProcAddress("wglGetExtensionsStringARB")
      IF pProc = 0 THEN METHOD OBJRESULT = &H8007007F& : EXIT METHOD
      CALL DWORD pProc USING wglGetExtensionsStringARB(hdc) TO pRes
      IF pRes THEN METHOD = @pRes
   END METHOD
   ' =====================================================================================



Petr Schreiber

Thanks José,

I did not notice this class, very useful!


Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com