This question has come up a few times and the best thread can be found here :<br>
has a the
http://www. opengl. org/discussion_boards/ubb/ultimatebb.php?ubb= get_topic;f= 11;t= 001090< br>
note : The link does not work since the forum software has changed< br>
here . .
Short explanation below:< br>
If you can detect GL_NV_vertex_program3, then you have a SM 3.0 GPU< br>
GL_NV_fragment_program2 would do as well.< br>
<>The <><><>, <><> <>.<>
This works for nVidia GPUs< br>
ATI 3. 0 GPUs advertize GL_ATI_shader_texture_lod< br>
..0. 1. and version 4
If those extensions are not present and if your GL version 2. 0, then you have a SM 2.0 GPU. <br>
In glhlib 1. 60,<br>
1.to and . , the the
int params[ 2] ;
params[ 0] will get the major version (2, 3, 4 )<br>
and params[1 ] will get the minor version (always 0)<br>
Another method is to write some specific shaders and see if they compile. <br>
If they do compile, check the info log for the presence of the word "software"<br>
= Update ===
GPUs came out so how to detect these ones?<br>
The most surefire way is to look for the following extension : GL_NV_gpu_program4, GL_NV_geometry_program4, GL_NV_vertex_program4, GL_NV_fragment_program4<br>
and soon after, GL_EXT_gpu_shader4, GL_EXT_geometry_shader4, and some others. <br>
OpenGL does not follow the Direct3D Shader Model format; it has its own way to expose specific sets of functionality to the user. The OpenGL version number and the presence of extensions is a better test for what features are available on the hardware.
However, if you must equate GL functionality with Direct3D Shader Model versions, here is how to do so. It differs for different shading languages.
OpenGL Shading Language
Query the version of with
glGetString(GL_SHADING_LANGUAGE_VERSION). The version is formatted as
<version number><space><vendor-specific information>, where
<version number> is a
MAJOR.MINOR format, with an optional release number.
Shading language versions 1.3 is equivalent to much of Shader Model 4.0. Version 1.4 introduces uniform buffers and a few other features. Version 1.5 introduces geometry shaders; this version could be said to be feature-identical to Shader Model 4.
All versions less than 1.3 are equivalent to Shader Models 2 and 3. Because GLSL is a high-level language, many of the differences between SM 2 and 3 are not exposed to the user.
ARB Assembly Language
These are done through testing the presence of extensions. You should test them in this order:
- GL_NV_gpu_program4: SM 4.0 or better.
- GL_NV_vertex_program3: SM 3.0 or better.
- GL_ARB_fragment_program: SM 2.0 or better.
ATI does not support higher than SM 2.0 functionality in assembly shaders.