开发者

openGL and buttons on iPhone

开发者 https://www.devze.com 2022-12-20 16:08 出处:网络
开发者_高级运维I\'d like to make a \"video wall\" type application, where multiple images are mapped onto a cylinder, I\'d like to then enable each of these images as buttons.
开发者_高级运维

I'd like to make a "video wall" type application, where multiple images are mapped onto a cylinder, I'd like to then enable each of these images as buttons.

Is this possible? I'm not sure if objects in an openGL space can act as buttons.


sure, it's possible. When the user clicks the opengl context you should be able to get back a x, y location where they clicked. It's then a matter of just doing your projection math backwards to find out what part of the scene they clicked.

You can also render the entire scene to a back buffer with each button set as a different color, then do a glReadPixels from this back buffer at the location of the click. The color value returned is the button they clicked.

And here's an example with a even faster method: http://www.lighthouse3d.com/opengl/picking/

There you only draw the picking buffer when the user clicks the mouse, and only for the single pixel they clicked.

Note: not all of these methods may work with OpenGL ES....so you'll have to pick the one that's right for you.

As a side note, this is also how many FPS games accomplish hit detection.

0

精彩评论

暂无评论...
验证码 换一张
取 消