问题
What is the difference between glDrawBuffer(GL_NONE) and glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE)
Are both just another way of discarding any draws to color buffers? or there are some differences?
回答1:
First and foremost, glDrawBuffer (...)
applies to the current framebuffer only, it is a per-FBO state.
glColorMask (...)
, on the other hand, is a global state that masks writes from per-fragment operations to all logical framebuffers.
Another problem with glColorMask (...)
is that it indiscriminately applies to all draw buffers, there is a new variant of this function that can mask individual draw buffers called glColorMaski (...)
.
glColorMask (...)
also does not apply to glBlitFramebuffer (...)
, as evidenced below.
OpenGL 4.4 Core Profile Specification - 18.3. Copying Pixels - pp. 485
When values are written to the draw buffers, blit operations bypass most of the fragment pipeline. The only fragment operations which affect a blit are the pixel ownership test, the scissor test, and sRGB conversion (see section 17.3.9). Color, depth, and stencil masks (see section 17.4.2) are ignored.
It would really help if you gave some context, to narrow down the full set of differences. But the bottom line is that these states affect different sets of operations and are also stored in different places.
回答2:
I think the result is the same but conceptually they're different in implementation. I'd be worried that using glColorMask for this wouldn't stop the subsystem from processing all of the incoming colors, only to not actually draw anything.
来源:https://stackoverflow.com/questions/23769518/gldrawbuffergl-none-vs-glcolormask-set-to-all-gl-false