Jose's Read Only Forum 2023

IT-Consultant: José Roca (PBWIN 10+/PBCC 6+) (Archive only) => Discussion => Topic started by: Petr Schreiber on August 24, 2011, 09:15:14 PM

Title: WGL extensions: How to get them all?
Post by: Petr Schreiber on August 24, 2011, 09:15:14 PM
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
Title: Re: WGL extensions: How to get them all?
Post by: José Roca on August 24, 2011, 09:56:38 PM
 
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
   ' =====================================================================================


Title: Re: WGL extensions: How to get them all?
Post by: Petr Schreiber on August 25, 2011, 08:10:11 AM
Thanks José,

I did not notice this class, very useful!


Petr