I'm making a Java game engine, for personal use, using Java2D. But now, i need some performance so i'm adding an implementation of LWGL. So far, i setup the basics but when it comes to render in the main loop i get this exception:
Exception in thread "GraphicsEngine" java.lang.NullPointerException
at org.lwjgl.opengl.GL11.glClear(GL11.java:576)
at APE.engines.graphics.OpenGLGraphicsEngine.render(OpenGLGraphicsEngine.java:37)
at APE.engines.graphics.GraphicsEngine.run(GraphicsEngine.java:52)
at java.lang.Thread.run(Thread.java:595)
The OpenGL graphics engine has these relevant methods:
public void start() {
super.start();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GLU.gluOrtho2D(0, getGraphicsMode().getWidth(), getGraphicsMode().getHeight(), 0);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
}
public void render() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
((OpenGLGameContext) getGameContext()).render();
Display.update();
}
The problem is in "GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);"; the Display is setup and everything else seems right.
I'm new to LWJGL and i've been reading tutorials and documentation. Also i searched the forum for some related issue but unsuccessfully, so i apologize if this had already been answered.