Reputation: 7018
I haven't found any example which uses perspective camera in LibGDX(OpenGL ES 2.0). How to initiate it and use it in render method? Any help will be appreciated!
Upvotes: 2
Views: 3877
Reputation: 2220
To some extent you can use a perspective camera as the ortho camera (to set position, look at, up vector). The one big difference is that the viewport size (what you see on screen) is determined by the distance to the object and the field of view angle. There is plenty of theory around the web, but to get started in libgdx you can follow this example
EDIT: Example provided uses GL 1.x I thought you just didn't know how to use a perspective camera. You mixed up two different problems.
To complete my answer, once you updated your camera (cam.update) insted of calling camera.apply(Gdx.gl10);
you give the matrix to your shader - it will depend on your shader, but the simplest case would be something like this:
shader.setUniformMatrix("u_modelviewporj_mat", cam.combined);
Upvotes: 3