Answer the question
In order to leave comments, you need to log in
Why does this usage throw a null pointer exception?
Main class
public class Cars implements GLEventListener {
static Scene1 scene;
@Override
public void init(GLAutoDrawable drawable) {
...
try {
scene.LoadDrum(drawable);
} catch (IOException ex) {
Logger.getLogger(Cars.class.getName()).log(Level.SEVERE, null, ex);
}
}
public static void main(String[] args) {
scene = new Scene1();
scene.Scene();
Cars r = new Cars();
...
}
}
public class Scene1 {
class Image
{
int IndexTexture;
String Name;
int number;
}
int Scene()
{
image = new Image[CountTexture];
CountIndexTexture = 0;
vectordrum = new Vector<String>();
return 0;
}
int LoadDrum(GLAutoDrawable drawable) throws IOException
{
...
CountIndexTexture++;
image[CountIndexTexture - 1].Name = "auto1";
image[CountIndexTexture - 1].number = CountIndexTexture - 1;
image[CountIndexTexture - 1].IndexTexture = t.getTextureObject(gl);
...
}
}
Answer the question
In order to leave comments, you need to log in
Here is the solution
private Image(int textureObject, String auto1, int i) {
this.IndexTexture = textureObject;
this.Name = auto1;
this.number = i;
}
...
img = new Image(t.getTextureObject(gl),"auto1",CountIndexTexture - 1);
image[CountIndexTexture - 1] = img;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question