Gremlin92
@Gremlin92
Целеустремленный

Почему такое использование выдает null pointer exception?

Основной класс
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);
...
}
}

ошибка выдается при присваивании массиву image значений в поля
  • Вопрос задан
  • 98 просмотров
Решения вопроса 1
Gremlin92
@Gremlin92 Автор вопроса
Целеустремленный
Вот решение
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;
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы