So I am coding a RTS game, and trying to setup its menu and such.
However, when I try to display a background image for the entire screen, it does not load properly.
This is the code:
public static Texture Btexture;
public static void initBackground() {
try
{
Btexture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("Artyas_Background.png"));
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static void Brender()
{
GL11.glEnable(GL11.GL_TEXTURE_2D);
Color.white.bind();
Btexture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0,0);
GL11.glVertex2f(0,600);
GL11.glTexCoord2f(1,0);
GL11.glVertex2f(800,600);
GL11.glTexCoord2f(1,1);
GL11.glVertex2f(800, 0);
GL11.glTexCoord2f(0,1);
GL11.glVertex2f(0, 0);
GL11.glEnd();
}
I initialise it (Like all the other images):
public static void initStates()
{
MenuGUI.initBackStatic();
MenuGUI.initStartStatic();
MenuGUI.initExitStatic();
MenuGUI.initStartHover();
MenuGUI.initExitHover();
MenuGUI.initBackground();
}
And I render it:
case MENU:
GL11.glColor3f(1.0f, 0.0f, 0.2f);
// glRectf(0, 0, 800, 600);
MenuGUI.Brender();
MenuGUI.BDrender();
MenuGUI.STrender();
MenuGUI.ETrender();
int mousex = Mouse.getX();
int mousey = Mouse.getY();
//System.out.println(mousex + " - " + mousey);
boolean leftButtonDown = Mouse.isButtonDown(0);
boolean rightButtonDown = Mouse.isButtonDown(1);
if((mousex>=50 && mousex < 200) && (mousey<500 && mousey >450))
{
//System.out.println(mousex + " - " + mousey);
MenuGUI.SHrender();
if(leftButtonDown)
{
state = States.GAME;
}
}
if((mousex>=50 && mousex < 200) && (mousey<450 && mousey >400))
{
//System.out.println(mousex + " - " + mousey);
MenuGUI.EHrender();
if(leftButtonDown)
{
Display.destroy();
System.exit(0);
}
}
break;
Any help would be appreciated. I keep trying to fix this since yesterday.