Und weiter geht die Fragerei
Ich bekomm im Moment einen Nullpointer den ich mir leider nicht erklären kann!? Hoffe ihr habt abermals Hilfe für micht ![]()
Hier der StackTrace
Code
03-24 14:42:38.460: ERROR/AndroidRuntime(217): Uncaught handler: thread GLThread 8 exiting due to uncaught exception
03-24 14:42:38.505: ERROR/AndroidRuntime(217): java.lang.NullPointerException
03-24 14:42:38.505: ERROR/AndroidRuntime(217): at awesome.project1.view.render.SpriteList.add(SpriteList.java:30)
03-24 14:42:38.505: ERROR/AndroidRuntime(217): at awesome.project1.test.TextPrinter.print(TextPrinter.java:56)
03-24 14:42:38.505: ERROR/AndroidRuntime(217): at awesome.project1.view.render.FRenderer.onSurfaceCreated(FRenderer.java:66)
03-24 14:42:38.505: ERROR/AndroidRuntime(217): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1112)
03-24 14:42:38.505: ERROR/AndroidRuntime(217): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:975)
Und hier die betreffende Klasse "SpriteList"
Java
package awesome.project1.view.render;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedList;
import javax.microedition.khronos.opengles.GL10;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.opengl.GLUtils;
import android.util.Log;
public class SpriteList extends LinkedList<Sprite> {
private AssetManager _mngr = null;
private int[] _texIndices = null;
private GL10 _gl = null;
public SpriteList (AssetManager mngr, int[] texIndices, GL10 gl) {
_mngr = mngr;
_texIndices = texIndices;
_gl = gl;
}
public void add(String path, float x, float y, float width, float height, float[] texCoord) throws IOException {
String id = loadGlTexture(path);
if (id != null) {
Sprite s = new Sprite(x, y, width, height, Integer.getInteger(id), path, texCoord);
this.add(s);
}
else
Log.e("SPRITE", "No usable Tex Id \""+path+"\"");
}
private String loadGlTexture(String path) throws IOException {
String check = checkGlTexture(path);
if (check.equals("true")) {
Bitmap image = BitmapFactory.decodeStream(_mngr.open(path));
_gl.glGenTextures(1, _texIndices, 0);
int id = _texIndices[0];
_gl.glBindTexture(GL10.GL_TEXTURE_2D, id);
_gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MIN_FILTER,
GL10.GL_LINEAR);
_gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_MAG_FILTER,
GL10.GL_LINEAR);
_gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_WRAP_S,
GL10.GL_REPEAT);
_gl.glTexParameterf(GL10.GL_TEXTURE_2D,
GL10.GL_TEXTURE_WRAP_T,
GL10.GL_REPEAT);
GLUtils.texImage2D(GL10.GL_TEXTURE_2D,
0, image, 0);
return Integer.toString(id);
}
else
return check;
}
private String checkGlTexture (String path) {
for (Sprite s : this){
if(s.getTexString().equals(path))
return Integer.toString(s.getTexId());
else
return "true";
}
return "true";
}
}
Alles anzeigen
Ich hab alle Variablen mit dem Debugger geprüft und keine, weder die globalen noch diejenigen, die der Methode übergeben werden sind NULL. Ich verzweifle grad einfach ![]()
Danke schonmal im Vorraus, Kai