iPhone 上的 OpenGL ES 颜色选择

发布于 2024-09-18 02:02:26 字数 331 浏览 6 评论 0原文

我正在研究 iPhone 上的 3D,我已设法在设备上获得 3D 立方体,但希望添加交互性,例如触摸一个面会触发特定事件,而触摸另一面会触发不同的事件。我宁愿避免光线拾取,因为这会增加我的应用程序中不希望出现的额外复杂性。

我已经阅读了相当多的颜色选择教程,但网络上似乎没有任何特定于 iPhone 的教程或示例代码。

我的主要问题是将独特的彩色对象绘制到后台缓冲区,并将纹理对象绘制到前台缓冲区,从不向用户显示独特的彩色对象,而是检测从后台缓冲区触摸的像素的颜色。

所以我的问题是有人能给我指点 Objective-C 教程的方向或者发布一些示例代码吗?

任何帮助或建议将不胜感激。

I'm looking into 3D on the iPhone, I have managed to get a 3D cube on the device but would like to add interactivity such as touching one face fires a specific event and an other face a different event. I'd rather steer clear of ray picking as this adds extra complexity that I do not want in my app.

I've read up on quite a few color picking tutorials, but there doesn't seem to be any iPhone specific tutorials or sample code anywhere on the web.

My main problem is drawing unique colored objects to the back buffer and textured objects to the front buffer, never showing the unique colored objects to the user but detecting the color of the pixel touched from the back buffer.

So my question is can anyone point me in the direction of an Objective-C tutorial or post some sample code?

Any help or advice would be much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

内心旳酸楚 2024-09-25 02:02:26

好的,18 小时后我终于解决了我的问题。在渲染方法中,我所要做的就是在渲染处于 SELECT 模式时阻止 presentRenderbuffer 调用。我现在可以踢自己了!

if (mode == SELECT) {
    glDisable(GL_DITHER);
    glDisable(GL_LIGHTING);
    glDisable(GL_LIGHT0);
}

// Draws the cube object, face by face and adds unique color to each face
[Face1 draw];
[Face2 draw];
[Face3 draw];
[Face4 draw];
[Face5 draw];
[Face6 draw];

if (mode == SELECT) {
    glEnable(GL_DITHER);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
}

// Wrapping presentRenderbuffer with this if statement fixed
// the problem where the unique colors would appear onscreen
if (mode == RENDER) {
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
}

我希望这可以帮助其他人在未来:o)

OK, so after 18 hours I've finally fixed my issue. In the render method all I had to do was prevent the presentRenderbuffer call when the render was in SELECT mode. I could kick myself right now!

if (mode == SELECT) {
    glDisable(GL_DITHER);
    glDisable(GL_LIGHTING);
    glDisable(GL_LIGHT0);
}

// Draws the cube object, face by face and adds unique color to each face
[Face1 draw];
[Face2 draw];
[Face3 draw];
[Face4 draw];
[Face5 draw];
[Face6 draw];

if (mode == SELECT) {
    glEnable(GL_DITHER);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
}

// Wrapping presentRenderbuffer with this if statement fixed
// the problem where the unique colors would appear onscreen
if (mode == RENDER) {
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
}

I hope this may help someone else in future :o)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文