How do I read OpenGL dependencies?
I have a question about OpenGL dependencies. For example, for ARB_shader_atomic_counters, the dependency section says this:
Dependencies
This extension is written against the OpenGL 4.1 (core) specification and the GLSL 4.10.6 specification.
OpenGL 3.0 is required.
How do I read this information? Does the graphics card and/or driver need to support OpenGL 4.1 or OpenGL 3.0?
The official docs say:
Extensions may be written against a particular specification version, but it is possible to implement them that extension on older OpenGL versions. Some extensions can be implemented even on OpenGL 1.1, while others have a higher base version. The minimum version that the extension can appear in is specified with the text "X are required"
Is this just a theoretical possibility, and few (if any) drivers will implement it? Or would some drivers provide this function on OpenGL 3 hardware? How can I find out whether it is implemented?
You really should not read too much into those if you can help it. That information is not particularly helpful to the average developer. You will likely never encounter a GL 3.0 implementation that implements this extension because it was designed around a Shader Model 5.0 (DX 11) hardware feature. In theory there is nothing preventing it from being implemented in 3.0, but in practice no hardware/driver combination that implements this extension is going to limit itself to 3.0.
If you were going to implement the extension or devise some alternative solution, then it would be tremendously helpful to know the absolute minimum API version necessary.
When it says it is written against a certain version of a specification, what that means is that anytime the extension specification says something to the effect of "Add the following language to section X, paragraph Y, ...", you will find the original unextended text in that specific spec. version. It also means that the extension makes certain assumptions about how things behave.
For example, if version X says that points are rasterized as hexagons and version Y says they are rasterized as circles, and an extension is written against version Y, then the extension is free to assume that points are rasterized as circles. If this assumption becomes a point of controversy, you will find a blurb about it in the "Issues" section.
As for determining whether the extension is implemented (which is the most important point from your perspective), that is what the GL_EXTENSIONS
string is for. Be aware, however, that the way you query this string has changed over the years:
In a compatibility profile context or GL 3.1 or older:
// Returns a massive null terminated string containing every extension the
// implementation supports.
//
// ... do a string search to find your extension.
const GLchar* exts = glGetString (GL_EXTENSIONS);
In a core profile context:
GLint num_exts;
glGetIntegerv (GL_NUM_EXTENSIONS, &num_exts);
for (int i = 0; i < num_exts; i++) {
// Returns a null terminated string containing only one extension
const GLchar* ext = glGetStringi (GL_EXTENSIONS, i);
}
If you try to do the former in a core profile, GL will generate a GL_INVALID_ENUM
error and do nothing else. This is the reason glewExperimental = GL_TRUE
is necessary before calling glewInit (...)
if you use GLEW in a core profile.
下一篇: 我如何读取OpenGL依赖关系?