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(); ...

Get OpenGL ES 2 for Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.