Ok, hello!
So, I've got a small problem, and I can't find out why it's happening, especially that the example you've got on your page ran OK previously, but now when I try to run it, all I see is a black screen, nothing more.
Here's how I initialize LWJGL:
private Controller() {
initGraphics();
try {
Keyboard.create();
Mouse.setGrabbed(false);
Mouse.create();
} catch (LWJGLException ex) {
Logger.getLogger(Controller.class.getName()).log(Level.SEVERE, null, ex);
}
mainMenu = new MainMenu();
controllerState = ControllerState.MENU;
}
private void initGraphics() {
try {
Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
Display.create();
Display.setFullscreen(false);
Display.setTitle("Memory Game");
Display.setVSyncEnabled(true);
} catch (LWJGLException ex) {
ex.printStackTrace();
System.exit(0);
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glViewport(0, 0, WIDTH, HEIGHT);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, WIDTH, HEIGHT, 0, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
Here's how I render it:
Controller.java:
void process {
for (;

{
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
switch (controllerState) {
case MENU:
mainMenu.process();
break;
case OPTIONS:
break;
case GAME:
break;
case HISCORE:
break;
case EXIT:
cleanup();
default:
break;
}
Display.update();
if (Display.isCloseRequested()) {
controllerState = ControllerState.EXIT;
}
}
}
MainMenu.java:
public class MainMenu {
DisplayableObject gameButton;
DisplayableObject optionsButton;
DisplayableObject hiscoreButton;
DisplayableObject exitButton;
DisplayableObject backgroundImage;
public MainMenu(){
backgroundImage = new DisplayableObject(0,0,"background.png");
gameButton = new DisplayableObject(100,100,"gameButton.png");
hiscoreButton = new DisplayableObject(100,250,"hiscoreButton.png");
exitButton = new DisplayableObject(100,400,"exitButton.png");
}
void process() {
System.out.println("PROCESS");
backgroundImage.render();
//gameButton.render();
//hiscoreButton.render();
//exitButton.render();
}
}
DisplayableObject.java:
public class DisplayableObject {
int x;
int y;
Texture texture;
public DisplayableObject(int tX, int tY, String imageName){
x = tX;
y = tY;
try {
texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("res/" + imageName));
} catch (IOException ex) {
Logger.getLogger(DisplayableObject.class.getName()).log(Level.SEVERE, null, ex);
System.out.println(imageName);
System.exit(0);
}
System.out.println(imageName + " X:" + texture.getTextureWidth() + " Y: " + texture.getTextureHeight());
}
public void render() {
Color.white.bind();
texture.bind();
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(0, 0);
GL11.glVertex2f(x, y);
GL11.glTexCoord2f(1, 0);
GL11.glVertex2f(x + texture.getWidth(), y);
GL11.glTexCoord2f(1, 1);
GL11.glVertex2f(x + texture.getWidth(), y + texture.getHeight());
GL11.glTexCoord2f(0, 1);
GL11.glVertex2f(x, y + texture.getHeight());
GL11.glEnd();
}
}
And all I see is a black box.
What's funnier, though, is that the code used to run OK, but suddenly after I've done pretty much nothing connected to these methods, it stopped working :/.
So, what might be the problem here?