I'm having a problem loading a JPEG onto a sphere. Currently, the only way I have gotten this to work is to have the image in the same package as the class loading it. The problem is, I don't want to have 500+ textures all under one package mixed with classes. I would rather have them in folders and sub-folders for organizational reasons.
If the texture is in the same package, this works:
InputStream iStream = null;
try
{
iStream = getClass().getResourceAsStream(imageFile);
TextureData data = TextureIO.newTextureData(iStream, false, null);
testTex[i] = TextureIO.newTexture(data);
testTex[i].getImageTexCoords();
testTex[i].setTexParameteri(GL2.GL_TEXTURE_MAG_FILTER, GL2.GL_LINEAR);
testTex[i].setTexParameteri(GL2.GL_TEXTURE_MIN_FILTER, GL2.GL_NEAREST);
iStream.close();
...
The method that takes an image takes it in the form of:
String[] texture = { "bar1.jpg", "bar2.jpg" }; // imageFile is whichever is called
As the above code works perfectly, again, the drawback is that every texture will have to be stored within the same package as the class that is calling for the texture. But I want to call the texture like this from a folder within my project:
String[] texture = { "res/foo/bar2.jpg", "res/foo/bar2.jpg" };
How would I modify the above code to look for textures within a folder within the project?