Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the point of querying OpenGL extensions before attempting to load them?

Tags:

opengl

For whatever reason, I'm messing around with manual OpenGL extension loading.

Every tutorial I've found recommends first querying the extension string, then parsing it into a list of extensions, and then finally loading the function pointers for supported extensions. It seems to me that this whole process could be reduced to just getting the function pointers and then checking for any NULLs returned by wglGetProcAddress or equivalent.

My question is: What purpose does the intermediate query step serve? Is it possible for a function to be unsupported but for *GetProcAddress to return a non-NULL pointer?

like image 212
Michael Avatar asked Jan 30 '26 11:01

Michael


1 Answers

The extension string is the correct way for a GL implementation to tell you about what extensions it supports. Querying pointers for functions which are not implied to be present by the extension string is undefined behavior, as far as the GL is concerned.

In practice, the situation might actually arise. One often has the same GL client side dll for different backends, as it is the case with mesa. The fact that the function is there does not imply that it is implemented for all backend drivers.

like image 154
derhass Avatar answered Feb 01 '26 00:02

derhass



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!