I'm using the processing.core.PApplet
library in a simple Java Project.
I load multiple images in the setting
function and I tried to draw them in the draw
function but oddly the textures doesn't appear ?
There is the code I use to load them :
public void init() throws FileNotFoundException { // this get executed in the 'setting' function of my sketch
Registry.register(getImage("void"), "void");
}
public processing.core.PImage getImage(String name) throws FileNotFoundException {
String path = "src\\main\\resources\\blocks\\textures\\" + name + ".png";
File file = new File(path);
if(file.exists()) {
Logger.info("Texture " + file.getAbsolutePath() + " found.", "TextureMapping");
return sketch.loadImage(path);
} else {
throw new FileNotFoundException("File " + file.getAbsolutePath() + " not found." );
}
}
And the code I use to draw one of them :
// I create and draw a new cube in the 'draw' function of my sketch
// But it appears without any texture
public Cube(processing.core.PApplet sketch, BlockPos pos, @NotNull Block block) {
this.sketch = sketch;
this.block = block;
position = pos;
texture = Registry.getTextures().get("minecraft:void");
texture.loadPixels();
}
public void draw() {
sketch.pushMatrix();
sketch.translate(position.getX(), position.getY(), position.getZ());
sketch.box(10);
sketch.texture(texture); // Doin' nothing
sketch.popMatrix();
}
And the file are there, my Logger
say that they are found, I get no error, and yet the texture has all the properties of an PImage ?
And second oddly thing :
Before the draw
method, I do this in the draw
function :
sketch.image(Registry.getTextures().get("minecraft:void"), 10, 10);
And there, the image loads perfectly ???
yes I'm doin' a Minecraft clone