jakesee's picture

How to check if graphics card support a certain feature, like in GLEW?

How can I check for features is if in C++ / GLEW

bool haveHardwareOcclusionQueries() {
            return GLEW_ARB_occlusion_query || GLEW_NV_occlusion_query;

In this particular case, I am looking for OcclusionQuries.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mOfl's picture

It's best to create a static hashmap with all available extensions at startup:

HashSet<string> allExtensions = new HashSet<string>(GL.GetString(StringName.Extensions).Split(new char[] { ' ' }));

Then you can query for extensions:

public static bool IsSupported(string extensionName) {
    return allExtensions.Contains(extensionName)

So to check if occlusion queries are supported, you would check for (IsSupported("GL_ARB_occlusion_query") || (IsSupported("GL_NV_occlusion_query"))).

jakesee's picture

Thank you very much!