Hey everybody,
I just started on a new game. This time, I’m trying to use LWJGL and Slick2D instead of just the java native libraries.
I’ve got the basic framework down, but when I try to make a grid of grass, the grass has black borders and don’t line up. This is what I’ve come up with.
try {
grass = TextureLoader.getTexture("PNG",
ResourceLoader.getResourceAsStream("res/grass.png"));
} catch (IOException e) {
e.printStackTrace();
}
// Clearing the screen and the depth
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
grassWidth = grass.getImageWidth(); // I've also tried using grass.getTextureWidth(), and grass.getWidth()
grassHeight = grass.getImageHeight();
grass.bind();
// Drawing the background
for (int i = 0; i < Display.getWidth() / grassWidth; i++) {
for (int b = 0; b < Display.getHeight() / grassHeight; b++) {
glPushMatrix();
glBegin(GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(i * grassWidth,b * grassHeight);
GL11.glTexCoord2f(0.99f, 0);
GL11.glVertex2f(i * grassWidth + grassWidth, b* grassHeight);
GL11.glTexCoord2f(0.99f, 0.99f);
GL11.glVertex2f(i * grassWidth + grassWidth,b * grassHeight + grassHeight);
GL11.glTexCoord2f(0, 0.99f);
GL11.glVertex2f(i * grassWidth,b * grassHeight + grassHeight);
glEnd();
glPopMatrix();
}
}
This is my problem I believe:
grassWidth = grass.getImageWidth(); // I've also tried using grass.getTextureWidth(), and grass.getWidth()
I think I’m just getting the wrong sizes and so that is why the images are having a black border.
If you could reply back, that would be great!
Thanks,
Longarmx