Plu*_*tor 0 iphone opengl-es ios
在较旧的iOS设备上,模板缓冲区不可用.剪刀也适用于简单的矩形.对于更一般的剪裁,我们可以使用深度缓冲区吗?为简单起见,我们假设我们只绘制2D.
另外,我的具体要求是能够旋转剪裁矩形.
是的,一点没错.例如(编码为I类型):
glEnable(GL_DEPTH_TEST); // to enable writing to the depth buffer
glDepthFunc(GL_ALWAYS); // to ensure everything you draw passes
glDepthMask(GL_TRUE); // to allow writes to the depth buffer
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// so that whatever we draw isn't actually visible
glClear(GL_DEPTH_BUFFER_BIT); // for a fresh start
/* here: draw geometry to clip to the inside of, e.g. at z = -2 */
glDepthFunc(GL_GREATER); // so that the z test will actually be applied
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
// so that pixels are painted again...
glDepthMask(GL_FALSE); // ... but don't change the clip area
/* here: draw the geometry to clip inside the old shape at a z further than -2 */
Run Code Online (Sandbox Code Playgroud)
因此,主要功能是: