iPhone上的OpenGL ES颜色选择 [英] OpenGL ES color picking on the iPhone

查看:142
本文介绍了iPhone上的OpenGL ES颜色选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找iPhone上的3D,我已经设法在设备上获得3D立方体但是想要添加交互性,例如触摸一个面部发射特定事件而另一个面部发生不同事件。我宁愿避开光线拾取,因为这会增加我在我的应用中不需要的额外复杂性。

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.

我已经阅读了很多颜色选择教程,但网上似乎没有任何iPhone专用教程或示例代码。

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.

所以我的问题是任何人都可以点我在Objective-C教程的指导下或发布一些示例代码?

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.

推荐答案

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

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];
}

我希望将来可以帮助其他人:o)

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

这篇关于iPhone上的OpenGL ES颜色选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆