In OpenGL ES, how do I specify what the maximum visibility distance is? I’ve found that when I do:
gl.glTranslatef(0,0,-10f);
everything I draw is invisible because it’s too far away from the camera. How do I specify that it should draw things farther away?
The solution to your problem HappyEngineer is simply tinkering with the static GLU.gluPerspective() method. Here is the code I am using for rendering a simple cube (just the view setup code) in my project (I’m also learning):
So even if you’re new to GL the names of these functions + the parameters should be fairly obvious if you have any background in 3D. For the function of interest, gluPerspective, you’re passing a reference to your GL instance, the angle of the FOV or field of view, aspect ratio and then the far plane or maximum view distance. So that you understand the context in which this code is used, I’m using it inside of a GLWallpaperService (GL LiveWallpaper) within the onSurfaceChanged event. For more nfo on that see the following:
http://mindtherobot.com/blog/376/android-ui-making-a-live-wallpaper-fire-simulation/
http://www.rbgrn.net/content/354-glsurfaceview-adapted-3d-live-wallpapers
Also some nice tutorials for working with glES on droid:
http://blog.jayway.com/2009/12/03/opengl-es-tutorial-for-android-part-i/
http://insanitydesign.com/wp/projects/nehe-android-ports/