Parameters plane
Specifies which clipping plane is being positioned. Symbolic names of the form GL_CLIP_PLANEi, where i is an integer between 0 and <u>GL_MAX_CLIP_PLANES</u>-1, are accepted.
…
Description
… To determine the maximum number of additional clipping planes, call <u>glGetIntegerv</u> with argument <u>GL_MAX_CLIP_PLANES</u>.
I am pretty sure the correct way to determine the maximum number of supported clipping planes is calling glGetIntegerv(), but I am also sure that meaningful value for “plane” parameter above also varies from GL_CLIP_PLANE0 to GL_CLIP_PLANEn,
where n = glGetIntegerv(GL_MAX_CLIP_PLANES) - 1.
Is it true or not?
Apart from that, what is the correct way to iterate through all supported clipping plane IDs among the two ones below:
a.
for ( int i = 0, n = glGetIntegerv(GL_MAX_CLIP_PLANES); i < n; i++ ) {
int clipPlaneId = GL_CLIP_PLANE0 + i;
// Setup clipPlaneId-th clipping plane
...
}
or
b.
for ( int i = 0, n = GL_MAX_CLIP_PLANES; i < n; i++ ) {
int clipPlaneId = GL_CLIP_PLANE0 + i;
// Setup clipPlaneId-th clipping plane
...
}
Query n with n = glGetIntegerv(GL_MAX_CLIP_PLANES)
Then use GL_CLIP_PLANE0 … GL_CLIP_PLANE(n-1)
Question 2: a
GL_MAX_CLIP_PLANES is an OpenGL enum, it will be something really huge (> 1000 possibly). It has no meaningful value to you, so code b would give you errors or even crash.
a is correct, but i would not query n every time, but once at startup (though you knew that probably already).
I thought that all GL_MAX_xxx enums are not huge. They contain minimum needed count of specific feature (clip plane for example) that is needed to be supported on all OpenGL implementations. For example, GL_MAX_LIGHTS = 8, and so on…
Is that not right?
It seems that glClipPlane() function description in OpenGL docs needs some clarification, indeed.
Currently, the above-mentioned piece of OpenGL documentation with mixed values of GL_MAX_CLIP_PLANES and glGetIntegerv(GL_MAX_CLIP_PLANES) is duplicated in other popular resources (e.g. OpenGL articles in MSDN) and I believe this is not at all good.