Hello to anyone reading this, I hope your day is going well so far.
I am what some would call a “n00b” trying to get my feet wet in Java programming for the first time at age 26 and was looking to the community for help with an error I have not been able to work around. I should say I have programming experience in lesser languages (BASIC, Visual Basic. HTML) but i haven’t done much in a long time so I am a bit rusty. ( I don’t think that really helps much in this case anyway)
I downloaded a project from GitHub at: Git Repo used called World of Voxel and have basically been backwards engineering it to work properly in the JDK. I chose this project not to make a Minecraft clone but because I feel the type of mechanics used will be a great way to learn a lot of different things without worrying about a model heavy application. Once I am done learning I can start my own projects.
I am not 100% sure if this code is fully compatible with JMonkey which is kind of where the pro’s come in so if you could either take a look at the link or I can paste any of the code on this forum to show you what has been done so far. In this project I am not calling upon SimpleApplication at all and the only libraries I am using are included with the file, lwjgl.jar and lwjgl_util.jar. After looking at it I think the issue has to do with ‘image’ never being defined but I can’t tell for sure. Here is the first function know has an issue:
[java]public static int createTexture(BufferedImage image){
int[] pixels = new int[image.getHeight() * image.getWidth()];
image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());
ByteBuffer buffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * BYTES_PER_PIXEL);
for(int y = 0; y 16) & 0xFF)); // Red component
buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component
buffer.put((byte) (pixel & 0xFF)); // Blue component
buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component. Only for RGBA
}
}
buffer.flip();
int textureID = glGenTextures();
glBindTexture(GL_TEXTURE_2D, textureID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
glBindTexture(GL_TEXTURE_2D, 0);
return textureID;
}
}[/java]
The line that starts int[] seems to error out specifically.
I appreciate any information to help me figure this out and I’ll do my best to keep up with your answer.