An Issue Has Arisen:
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.PoseidonTechnologies.caveworld.level.WoRe.<init>(WoRe.java:46)
at com.PoseidonTechnologies.caveworld.CaveWorld.start(CaveWorld.java:80)
at com.PoseidonTechnologies.caveworld.CaveWorld.main(CaveWorld.java:303)
Caused by: java.lang.RuntimeException: !!
at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:61)
at com.PoseidonTechnologies.caveworld.level.Ch.<clinit>(Ch.java:20)
... 3 more
The Problematic Code Fragment Is Shown Below:
@SuppressWarnings({ "unchecked", "rawtypes" })
private static HashMap<String, Integer> iM = new HashMap();
private static int lId = -9999999;
public static int loT(String path, int m) {
File file = new File(path);
try {
if (iM.containsKey(file)) {
return ((Integer)iM.get(file)).intValue();
}
IntBuffer ib = BufferUtils.createIntBuffer(1);
GL11.glGenTextures(ib);
int id = ib.get(0);
bind(id);
GL11.glTexParameteri(3553, 10241, m);
GL11.glTexParameteri(3553, 10240, m);
BufferedImage bi = ImageIO.read(file);
int w = bi.getWidth();
int h = bi.getHeight();
ByteBuffer ppi = BufferUtils.createByteBuffer(w * h * 4);
int[] rPs = new int[w * h];
bi.getRGB(0, 0, w, h, rPs, 0, w);
for (int i = 0; i < rPs.length; i++)
{
int a = rPs[i] >> 24 & 0xFF;
int r = rPs[i] >> 16 & 0xFF;
int g = rPs[i] >> 8 & 0xFF;
int b = rPs[i] & 0xFF;
rPs[i] = (a << 24 | b << 16 | g << 8 | r);
}
ppi.asIntBuffer().put(rPs);
GLU.gluBuild2DMipmaps(3553, 6408, w, h, 6408, 5121, ppi);
return id;
}
catch (IOException e)
{
throw new RuntimeException("!!");
}
}
In Particular, Focus on These Lines;
catch (IOException e)
{
throw new RuntimeException("!!");
}
I Have Attempted to Eliminate the throw new RuntimeException
line, but then Eclipse prompts me with a missing return statement error. However, keeping this code results in the aforementioned error and program crashing.
LWJGL is being used within Eclipse. This section of code aims to load a texture file for specific assignments.
Any insight into the issue, its causes, possible fixes, or clarifications are greatly appreciated. Instead of downvoting, please leave a comment if something needs further explanation.
Thank you!
EDIT: Credit to @RobHruska and @dhamibirendra for suggesting using e.printStackTrace().
Updated Error Log Provided Below:
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:38)
at com.PoseidonTechnologies.caveworld.level.Ch.<clinit>(Ch.java:20)
at com.PoseidonTechnologies.caveworld.level.WoRe.<init>(WoRe.java:46)
at com.PoseidonTechnologies.caveworld.CaveWorld.start(CaveWorld.java:80)
at com.PoseidonTechnologies.caveworld.CaveWorld.main(CaveWorld.java:303)
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.PoseidonTechnologies.caveworld.level.WoRe.<init>(WoRe.java:46)
at com.PoseidonTechnologies.caveworld.CaveWorld.start(CaveWorld.java:80)
at com.PoseidonTechnologies.caveworld.CaveWorld.main(CaveWorld.java:303)
Caused by: java.lang.RuntimeException: javax.imageio.IIOException: Can't read input file!
at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:62)
at com.PoseidonTechnologies.caveworld.level.Ch.<clinit>(Ch.java:20)
... 3 more
Caused by: javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at com.PoseidonTechnologies.caveworld.Tea.loT(Tea.java:38)
... 4 more
It seems there's an issue reading the picture file.
This Line Appears to be Requesting it (I believe):
private void rebuild(int l) {
if (rTF == 2) {
return;
}
this.m = false;
u += 1;
rTF += 1;
GL11.glNewList(this.l + l, 4864);
GL11.glEnable(3553);
GL11.glBindTexture(3553, tex);
teb.init();
@SuppressWarnings("unused")
int tiles = 0;
for (int x = this.x0; x < this.x1; x++) {
for (int y = this.y0; y < this.y1; y++) {
for (int z = this.z0; z < this.z1; z++) {
if (this.wo.isT(x, y, z)) {
int tex = y == this.wo.d * 2 / 3 ? 0 : 1;
tiles++;
if (tex == 0) {
Ti.stone.render(teb, this.wo, l, x, y, z);
}else{
Ti.grass.render(teb, this.wo, l, x, y, z);
}
}
}
}
}
teb.flush();
GL11.glDisable(3553);
GL11.glEndList();
}
The integer "tex" is defined as follows:
private static int tex = Tea.loT("groundtex.png", 9728);