Query OpenGL Support


is there any possibility to detect if there is an opengl implementation on a system, i.e. how can i check if openGL is supported (an opengGL driver is installed) before i try to set up the rendering context?




Just do a glGetString(GL_VENDOR), and if the Result is Microsoft then you’re most likely running on a software-implementation. Another way would be to query the versionstring (glGetString(GL_VERSION) and if that’s 1.1 or even below, you’re either on an very old implementation or again on software.

Originally posted by PanzerSchreck:
Just do a glGetString(GL_VENDOR), and if the Result is Microsoft then you’re most likely running on a software-implementation.

Hmm… I don’t think it’s particularly safe to call glGetString (or any GL function) before setting up the rendering context. It’d probably work, but I don’t think you should rely on it.

Also, the MS software implementation IS an OpenGL implementation - Tombernick, would you consider it as such for your purposes? The most paranoid approach would be to link at runtime instead of statically with an import library - if there’s no OpenGL DLL, you’l know because LoadLibrary will fail.

If you’re not that paranoid, I’m not too clear what your aim is here - wglCreateContext will return null if it can’t set up GL, why isn’t that good enough?

This question should probably have been posted on one of the platform-specific fora, BTW.

Enumarate pixel formats and check for PFD_GENERIC_ACCELERATED.


I recommend creating a fake, invisible window, and creating a context in that window. You can use this to test what the vendor is, test what extensions are available, getting the real pixel format extension functions (for pbuffers etc), and other useful things.

Then destroy this window and create your real context.

MS OpenGL uses the Installable Client Driver system.
There will always be an opengl32.dll, even if no vendor specific drivers are installed, so dynamically loading one isn’t going to help, you have to go through the MS system of doing things. OpenGL32.dll chooses a vendor specific opengl implementation when you call wglCreateContext based on the DC’s pixel format and a registry setting which contains the name of the real opengl dll to use with that pixel format on that device.
This is to the extent of my knowledge of such things. Take it with a smidgen of salt.

First thanks to all for your replies.

I think the best way is to create a rendering context and check if it fails like MikeC and jwatte suggested. This should also work on other platforms than windows.

I thought there could maybe another possibility to check this without the expense of creating a window and a rendering context.

By the way I found an older but interesting article about the ICD model if someone wants to know more about this topic.