ios 我在哪里可以找到响应触摸的 iPhone OpenGL ES 示例?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1039481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where can I find an iPhone OpenGL ES Example that responds to touch?
提问by Jamey McElveen
I would like to find an iPhone OpenGL ES Example that responds to touch. Ideally it would meet these requirements:
我想找到一个响应触摸的 iPhone OpenGL ES 示例。理想情况下,它将满足以下要求:
- Displays a 3D object in the center of the screen like a cube
- Maps a texture to the cube surfaces
- Should move the camera around the cube as you drag your finger
- Should zoom the camera in and out on the cube by pinching
- Optionally has a background behind the cube that wraps around the back of the camera.(for example this could create the effect of the cube being in space)
- 在屏幕中央显示一个 3D 对象,就像一个立方体
- 将纹理映射到立方体表面
- 拖动手指时应该围绕立方体移动相机
- 应该通过捏合来放大和缩小立方体上的相机
- 可选地在立方体后面有一个背景,环绕在相机的背面。(例如,这可以创建立方体在空间中的效果)
Has anyone seen one or more examples that can do these or at least render the cube with the texture?
有没有人见过一个或多个可以做这些或至少用纹理渲染立方体的例子?
回答by Brad Larson
My iPhone application Moleculeshas its source code availablevia a BSD license. It uses OpenGL ES to render a molecular structure, using single touches to rotate the structure, a pinch gesture for zooming, and simultaneous movement of two fingers for panning across the molecule. Unfortunately, it does not yet use textures for any of the rendering it does.
我的 iPhone 应用程序Molecules的源代码可通过 BSD 许可证获得。它使用 OpenGL ES 来渲染分子结构,使用单点触摸来旋转结构,使用捏合手势进行缩放,以及两根手指同时移动以平移分子。不幸的是,它还没有为它所做的任何渲染使用纹理。
I document some of the things I've learned about OpenGL ES from it hereand here.
回答by Rhythmic Fistman
Sounds like you're looking for more than one example:
听起来您正在寻找多个示例:
- The XCode template "OpenGL ES Application" does this.
- This NeHe for iPhonetutorial texture maps a cube.
- For this you need the arcball algorithm. Thanks, NeHe.
- Why not place your scene inside a texture mapped cylinder?
Once again, NeHeto the rescue. Does that guy ever sleep!?!
- XCode 模板“OpenGL ES 应用程序”就是这样做的。
- 这个NeHe for iPhone教程纹理映射一个立方体。
- 为此,您需要arcball 算法。谢谢,尼赫。
- 为什么不将场景放置在纹理映射圆柱体中?
再一次,NeHe来救援。那家伙睡过吗!?!
You're welcome!
别客气!
回答by Mark
回答by schnaader
I haven't found example code for this exact task, but here's a tutorial about the iPhone touch API. Using the code from there, you should be able to react on touch events. For the graphics, look at this sitethat contains various OpenGL ES examples.
我还没有找到这个确切任务的示例代码,但这里有一个关于iPhone touch API的教程。使用那里的代码,您应该能够对触摸事件做出反应。对于图形,请查看包含各种 OpenGL ES 示例的站点。
回答by xaxxon
Looks like you're going to need to implement the UIResponder interface:
看起来您将需要实现 UIResponder 接口: