How do I add a map view to an OpenGL ES view?
I am making a 3-D iOS application using OpenGL ES. 开发者_如何学Go I have created a square frame that gets rendered to my OpenGL ES context.
How do I add a map view to this square frame? I'd like to be able to apply a 3-D effect to this map.
I tried adding the map as a subview of the OpenGL ES hosting view, but didn't see any 3-D effect applied to it. What am I doing wrong?
I think you might be going about this the wrong way. First, all OpenGL ES rendering is self-contained within your CAEAGLLayer, so you can't just add a subview and expect it to be part of your scene. The OpenGL ES content will render within a flat layer, and anything added on top of it will just be stacked on that layer.
You could grab an image of the map view, convert that to a texture, and then upload that texture into your OpenGL scene, but that would probably have terrible performance and I don't think you'd be able to maintain user interaction with the map.
If you are just attempting to provide a perspective effect to your map, you could use a Core Animation CATransform3D to rotate the map view in 3-D and apply perspective to it. See my answer here for an example of how that could be achieved. Using Core Animation for this would require far less code than OpenGL ES.
精彩评论