Opengl Es png输入识别
我们正在为 iPad 开发一款游戏。在游戏中,当用户触摸 png 内部时,程序应该接受输入并理解用户触摸的是哪个 png。我的意思是 png 应该像一个按钮一样。我们如何在 opengl es 中做到这一点?
we are developing a game for iPad. in the game when a user touches inside a png, the program should take the input and understands which png that the user touched in. I mean the png should act like a button. how can we do it in opengl es?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在寻找的是“挑选和选择”请看一下本教程:http://www.lighthouse3d.com/opengl/picking/" rel="nofollow">http://www.lighthouse3d.com lighthouse3d.com/opengl/picking/ 和 OpenGL 文档:http: //www.opengl.org/resources/faq/technical/selection.htm 。您基本上渲染了与您按下屏幕的位置相关的场景部分。然后,您将名称/标识符添加到渲染的对象中,然后可以将其映射回鼠标位置。
或者,您可以在后台缓冲区中以唯一的颜色渲染每个对象,并选择在按下的位置下渲染的颜色。将该颜色值映射回您渲染的对象,然后您就可以进行选择。
What you are looking for is 'Picking and selection' Take a look at this tutorial: http://www.lighthouse3d.com/opengl/picking/ and the OpenGL documentation: http://www.opengl.org/resources/faq/technical/selection.htm . You basically render a part of the scene that is relevant to where you were pressing the screen. You then add names/identifiers to the objects that are rendered which can then be mapped back to the mouse-position.
Alternatively you can render each object in a unique color in a back-buffer and pick the color that is rendered under the pressed location. Map that color value back to the object that you rendered and you have your selection.