O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Panning the Camera Around the Scene

Currently we can only see a very small part of the skybox on our screen. Wouldn’t it be nice if we could pan around and see the rest of the skybox? We can easily do that by listening for touch events and using those touch events to rotate the skybox and scene together.

Open up ParticlesActivity, and add the following code before the call to setContentView:

Skybox/src/com/particles/android/ParticlesActivity.java
 
glSurfaceView.setOnTouchListener(​new​ OnTouchListener() {
 
float​ previousX, previousY;
 
 
@Override
 
public​ ​boolean​ onTouch(​View​ v, MotionEvent event) {
 
if​ (event != null) {
 
if​ (event.getAction() == MotionEvent.ACTION_DOWN) {
 
previousX = event.getX();
 
previousY = event.getY(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required