@Override public void onDrawFrame(GL10 gl) { gl.glClearColor(offset, 0.4f, 0.2f, 1f); gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); gl.glColor4f(1f, 1f, 1f, 1f); for (Quad quad : layers) { quad.setX(offset * (width - quad.getWidth())); quad.draw(gl); } }
public void resizeLayers() { for (Quad quad : layers) { int bitmapHeight = quad.getTexture().getBitmapHeight(); // Log.d(TAG, "Scaling quad with texture " + quad.getTexture()); float ratio = (float) height / bitmapHeight; // Log.d(TAG, "Scale ratio " + ratio + " so that width is " + // (quad.getTexture().getBitmapWidth() * ratio)); quad.setHeight(height); quad.setWidth(quad.getTexture().getBitmapWidth() * ratio); } }
public void reloadLayers() throws IOException { if (gl != null) { layers.clear(); textureLoader.clear(gl); for (String bitmapPath : layerFiles) { Quad quad = new Quad(); Texture tex = textureLoader.loadTextureFromFile(gl, bitmapPath); Log.i(TAG, "Loaded texture " + tex.id); quad.setTexture(tex); layers.add(0, quad); } } }