Hello everyone, this is my first post so bear with me. I have been teaching my self Java and Game development for the past few months. I messed with Java Awt library a bit but I have now started to learn LWJGL ;D. However I am having some trouble with the code below. It does what I want, which is drawing the texture onto the Quad but it has a weird green overlay. I noticed that this was caused when I added the following statement to the initialization code. I am using Slick2Ds Texture and TextureLoader class, here is my code below…
Line that adds the green Overlay
glEnable(GL_TEXTURE_2D);
Initialization code which is called in Main.java
public void initGL() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 0, 500, 1, -1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
}
Testing drawing textures on Quads, called in my Level Entity class
public void drawLevel(int zoom) {
int w = 8*zoom;
// for(int x = 0; x < 800; x+=w) {
// for(int y = 0; y < 500; y+=w) {
//
// glColor3f(256, 256, 256);
// glPushMatrix();
// glBegin(GL11.GL_QUADS);
// glVertex2f(x-4,y-4);
// glVertex2f(x+4,y-4);
// glVertex2f(x+4,y+4);
// glVertex2f(x-4,y+4);
// glEnd();
// glPopMatrix();
// }
// }
int x;
int y;
glClear(GL_COLOR_BUFFER_BIT);
grass.bind();
x = 40;
y = 64;
glPushMatrix();
glBegin(GL11.GL_QUADS);
glTexCoord2f(1,1);
glVertex2f(x-32,y-32);
glTexCoord2f(0,1);
glVertex2f(x+32,y-32);
glTexCoord2f(0,0);
glVertex2f(x+32,y+32);
glTexCoord2f(1,0);
glVertex2f(x-32,y+32);
glEnd();
glPopMatrix();
dirt.bind();
x += 64;
glBegin(GL_QUADS);
glTexCoord2f(1,1);
glVertex2f(x-32,y-32);
glTexCoord2f(0,1);
glVertex2f(x+32,y-32);
glTexCoord2f(0,0);
glVertex2f(x+32,y+32);
glTexCoord2f(1,0);
glVertex2f(x-32,y+32);
glEnd();
dirt2.bind();
x += 64;
glBegin(GL_QUADS);
glTexCoord2f(1,1);
glVertex2f(x-32,y-32);
glTexCoord2f(0,1);
glVertex2f(x+32,y-32);
glTexCoord2f(0,0);
glVertex2f(x+32,y+32);
glTexCoord2f(1,0);
glVertex2f(x-32,y+32);
glEnd();
brick.bind();
x += 64;
glBegin(GL_QUADS);
glTexCoord2f(1,1);
glVertex2f(x-32,y-32);
glTexCoord2f(0,1);
glVertex2f(x+32,y-32);
glTexCoord2f(0,0);
glVertex2f(x+32,y+32);
glTexCoord2f(1,0);
glVertex2f(x-32,y+32);
glEnd();
cement.bind();
x += 64;
glBegin(GL_QUADS);
glTexCoord2f(1,1);
glVertex2f(x-32,y-32);
glTexCoord2f(0,1);
glVertex2f(x+32,y-32);
glTexCoord2f(0,0);
glVertex2f(x+32,y+32);
glTexCoord2f(1,0);
glVertex2f(x-32,y+32);
glEnd();
}
}
Would like to add an Image but I am unsure how.
I am also interested in a way to scale the textures I am using up to different sizes, if any one knows, which I am sure someone does ;)…