Hey,
I’m trying to create an image of a space ship that consist of different parts,
but I’m getting a NullPointerException at the Image(int, int) constructor.
[quote]Exception in thread “Client” java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glGenTextures(GL11.java:1372)
at org.newdawn.slick.opengl.InternalTextureLoader.createTextureID(InternalTextureLoader.java:106)
at org.newdawn.slick.opengl.InternalTextureLoader.getTexture(InternalTextureLoader.java:359)
at org.newdawn.slick.opengl.InternalTextureLoader.createTexture(InternalTextureLoader.java:343)
at org.newdawn.slick.opengl.InternalTextureLoader.createTexture(InternalTextureLoader.java:329)
at org.newdawn.slick.Image.(Image.java:238)
at net.aichix3.devrays.Ship.getSprite(Ship.java:32)
at net.aichix3.devrays.Shipslot.(Shipslot.java:29)
at net.aichix3.devrays.Network$1.received(Network.java:74)
at com.esotericsoftware.kryonet.Connection.notifyReceived(Connection.java:270)
at com.esotericsoftware.kryonet.Client.update(Client.java:296)
at com.esotericsoftware.kryonet.Client.run(Client.java:332)
at java.lang.Thread.run(Unknown Source)
[/quote]
static Image getSprite(ShipAspect a) {
try {
Image s = new Image(Game.i.get("ship" + a.id).getWidth() + 200, Game.i.get("ship" + a.id).getHeight() + 200); // Ship.java:32 // a.id == 3 // Game.i.get("ship3") != null
// new Image(200, 200) does not work too
Graphics sg = s.getGraphics();
sg.drawImage(Game.i.get("ship" + a.id), 100, 100);
sg.drawImage(Game.i.get("w1"), WEAPONS[1].x, WEAPONS[1].y);
sg.flush();
return s;
} catch (SlickException e) {
e.printStackTrace();
return null;
}
}
What’s wrong with the code? =/