ApiDemos Clean up

- Add missing @Override
- Remove (some) unused imports
- Add some missing headers

BUG: 2031807
This commit is contained in:
Xavier Ducrohet
2009-08-03 18:54:52 -07:00
parent 8ebbef7eff
commit 66f17e50db
23 changed files with 177 additions and 143 deletions

View File

@@ -16,7 +16,6 @@
package com.example.android.apis.graphics;
import android.R;
import android.os.Bundle;
import android.app.Dialog;
import android.content.Context;
@@ -218,7 +217,7 @@ public class ColorPickerDialog extends Dialog {
mInitialColor = initialColor;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
OnColorChangedListener l = new OnColorChangedListener() {

View File

@@ -18,31 +18,34 @@ package com.example.android.apis.graphics.kube;
public class GLColor {
public final int red;
public final int green;
public final int blue;
public final int alpha;
public GLColor(int red, int green, int blue, int alpha) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
public final int red;
public final int green;
public final int blue;
public final int alpha;
public GLColor(int red, int green, int blue) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = 0x10000;
}
public boolean equals(Object other) {
if (other instanceof GLColor) {
GLColor color = (GLColor)other;
return (red == color.red && green == color.green &&
blue == color.blue && alpha == color.alpha);
}
return false;
}
public GLColor(int red, int green, int blue, int alpha) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
public GLColor(int red, int green, int blue) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = 0x10000;
}
@Override
public boolean equals(Object other) {
if (other instanceof GLColor) {
GLColor color = (GLColor)other;
return (red == color.red &&
green == color.green &&
blue == color.blue &&
alpha == color.alpha);
}
return false;
}
}

View File

@@ -19,70 +19,71 @@ package com.example.android.apis.graphics.kube;
import java.nio.IntBuffer;
public class GLVertex {
public float x;
public float y;
public float z;
final short index; // index in vertex table
GLColor color;
GLVertex() {
this.x = 0;
this.y = 0;
this.z = 0;
this.index = -1;
}
GLVertex(float x, float y, float z, int index) {
this.x = x;
this.y = y;
this.z = z;
this.index = (short)index;
}
public float x;
public float y;
public float z;
final short index; // index in vertex table
GLColor color;
public boolean equals(Object other) {
if (other instanceof GLVertex) {
GLVertex v = (GLVertex)other;
return (x == v.x && y == v.y && z == v.z);
}
return false;
}
static public int toFixed(float x) {
return (int)(x*65536.0f);
GLVertex() {
this.x = 0;
this.y = 0;
this.z = 0;
this.index = -1;
}
public void put(IntBuffer vertexBuffer, IntBuffer colorBuffer) {
vertexBuffer.put(toFixed(x));
vertexBuffer.put(toFixed(y));
vertexBuffer.put(toFixed(z));
if (color == null) {
colorBuffer.put(0);
colorBuffer.put(0);
colorBuffer.put(0);
colorBuffer.put(0);
} else {
colorBuffer.put(color.red);
colorBuffer.put(color.green);
colorBuffer.put(color.blue);
colorBuffer.put(color.alpha);
}
}
public void update(IntBuffer vertexBuffer, M4 transform) {
// skip to location of vertex in mVertex buffer
vertexBuffer.position(index * 3);
if (transform == null) {
vertexBuffer.put(toFixed(x));
vertexBuffer.put(toFixed(y));
vertexBuffer.put(toFixed(z));
} else {
GLVertex temp = new GLVertex();
transform.multiply(this, temp);
vertexBuffer.put(toFixed(temp.x));
vertexBuffer.put(toFixed(temp.y));
vertexBuffer.put(toFixed(temp.z));
}
}
GLVertex(float x, float y, float z, int index) {
this.x = x;
this.y = y;
this.z = z;
this.index = (short)index;
}
@Override
public boolean equals(Object other) {
if (other instanceof GLVertex) {
GLVertex v = (GLVertex)other;
return (x == v.x && y == v.y && z == v.z);
}
return false;
}
static public int toFixed(float x) {
return (int)(x * 65536.0f);
}
public void put(IntBuffer vertexBuffer, IntBuffer colorBuffer) {
vertexBuffer.put(toFixed(x));
vertexBuffer.put(toFixed(y));
vertexBuffer.put(toFixed(z));
if (color == null) {
colorBuffer.put(0);
colorBuffer.put(0);
colorBuffer.put(0);
colorBuffer.put(0);
} else {
colorBuffer.put(color.red);
colorBuffer.put(color.green);
colorBuffer.put(color.blue);
colorBuffer.put(color.alpha);
}
}
public void update(IntBuffer vertexBuffer, M4 transform) {
// skip to location of vertex in mVertex buffer
vertexBuffer.position(index * 3);
if (transform == null) {
vertexBuffer.put(toFixed(x));
vertexBuffer.put(toFixed(y));
vertexBuffer.put(toFixed(z));
} else {
GLVertex temp = new GLVertex();
transform.multiply(this, temp);
vertexBuffer.put(toFixed(temp.x));
vertexBuffer.put(toFixed(temp.y));
vertexBuffer.put(toFixed(temp.z));
}
}
}

View File

@@ -18,7 +18,6 @@ package com.example.android.apis.graphics.kube;
import android.opengl.GLSurfaceView;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;