From f792eca1e7b630611b569e431bc05a18bed2fe42 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Sun, 21 Apr 2013 00:36:33 +0000 Subject: [PATCH] Reorder Cards methods --- src/org/pileus/spades/Cards.java | 102 +++++++++++++++---------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/src/org/pileus/spades/Cards.java b/src/org/pileus/spades/Cards.java index 4149b9d..1143daa 100644 --- a/src/org/pileus/spades/Cards.java +++ b/src/org/pileus/spades/Cards.java @@ -94,57 +94,6 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer private int red; // red card back private int blue; // blue card back - /* Private methods */ - private int loadShader(int type, String code) - { - Os.debug("Cards: loadShader"); - - int shader = GLES20.glCreateShader(type); - GLES20.glShaderSource(shader, code); - GLES20.glCompileShader(shader); - return shader; - } - - private int loadTexture(String name) - { - Os.debug("Cards: loadTexture - " + name); - - final int[] tex = new int[1]; - - /* Lookup the resource ID */ - int id = 0; - try { - id = R.drawable.class.getField(name).getInt(null); - } catch(Exception e) { - Os.debug("Cards: lookup failed for '" + name + "'", e); - return 0; - } - - /* Load the bitmap */ - Bitmap bitmap = BitmapFactory.decodeResource(this.res, id); - - /* Copy into OpenGL */ - GLES20.glGenTextures(1, tex, 0); - GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex[0]); - GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0); - GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); - GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); - - return tex[0]; - } - - private FloatBuffer loadBuffer(float[] data) - { - ByteBuffer bytes = ByteBuffer.allocateDirect(data.length * 4); - bytes.order(ByteOrder.nativeOrder()); - - FloatBuffer buf = bytes.asFloatBuffer(); - buf.put(data); - buf.position(0); - - return buf; - } - /* GLSurfaceView Methods */ public Cards(Context context) { @@ -270,4 +219,55 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer Matrix.translateM(this.model, 0, 0, 0, 1.5f); } + + /* Private methods */ + private int loadShader(int type, String code) + { + Os.debug("Cards: loadShader"); + + int shader = GLES20.glCreateShader(type); + GLES20.glShaderSource(shader, code); + GLES20.glCompileShader(shader); + return shader; + } + + private int loadTexture(String name) + { + Os.debug("Cards: loadTexture - " + name); + + final int[] tex = new int[1]; + + /* Lookup the resource ID */ + int id = 0; + try { + id = R.drawable.class.getField(name).getInt(null); + } catch(Exception e) { + Os.debug("Cards: lookup failed for '" + name + "'", e); + return 0; + } + + /* Load the bitmap */ + Bitmap bitmap = BitmapFactory.decodeResource(this.res, id); + + /* Copy into OpenGL */ + GLES20.glGenTextures(1, tex, 0); + GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex[0]); + GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0); + GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_NEAREST); + GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST); + + return tex[0]; + } + + private FloatBuffer loadBuffer(float[] data) + { + ByteBuffer bytes = ByteBuffer.allocateDirect(data.length * 4); + bytes.order(ByteOrder.nativeOrder()); + + FloatBuffer buf = bytes.asFloatBuffer(); + buf.put(data); + buf.position(0); + + return buf; + } } -- 2.43.2