Hello!
I am making a simple 2d game. I load the textures into the game using slick-util . But when the textures are loaded, I get this:
This is my draw function:
public static void draw() {
glLoadIdentity();
glTranslatef(blockX[count], blockY[count], 0);
stone.bind();
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(0, 0);
glTexCoord2f(0, 1);
glVertex2f(0, 50);
glTexCoord2f(1, 1);
glVertex2f(50, 50);
glTexCoord2f(1, 0);
glVertex2f(50, 0);
glEnd();
count++;
if (count == 9) {
Textures.isDrawn = true;
}
And this is my initGL function:
public static void initGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, 0, height, -1, 1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
}
And this is the texture loader:
public static void loadTextures() {
try {
stone = TextureLoader.getTexture("PNG", new FileInputStream(new File("res/stone.png")));
} catch (IOException ex) {
Logger.getLogger(textureLoader.class.getName()).log(Level.SEVERE, null, ex);
}
}
Please Help!
Thanks!
Peter