gpt4 book ai didi

iphone - 使用深度缓冲区而不是模板缓冲区进行裁剪

转载 作者:行者123 更新时间:2023-11-28 18:44:48 25 4
gpt4 key购买 nike

在旧的 iOS 设备上,模板缓冲区不可用。剪刀也只适用于简单的矩形。对于更一般的裁剪,我们可以使用深度缓冲区吗?为简单起见,假设我们仅在二维中绘图。

此外,我的具体要求是能够旋转裁剪矩形。

最佳答案

是的,绝对是。例如。 (在我输入时编码):

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 */

因此,主要特点是:

  • 深度测试可以设置为始终通过
  • 即使设置了其他缓冲区值也可以禁用颜色绘图

关于iphone - 使用深度缓冲区而不是模板缓冲区进行裁剪,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5809585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com