I recevie 0 errors but I get this in the console:
>Exception in thread "main" java.lang.NullPointerException
>>at org.lwjgl.opengl.GL11.glMatrixMode(GL11.java:2052)
>>>at game.engine.GameLoop.start(GameLoop.java:22)
>>>>at game.engine.GameLoop.main(GameLoop.java:15)
I tried to put the actual value into "glMatrixMode()" instead of "GL11.GL_PROJECTION" but it returns same Exception.
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.Display;
public class GameLoop
{
//Main
public static void main(String[] argv)
{
GameLoop.start();
}
//Metodo che gestisce il loop
public static void start()
{
//Inizializzazione OpenGL
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, 800, 600, 0, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
try
{
Display.setDisplayMode(new DisplayMode(800, 600));
Display.create();
} catch (LWJGLException e)
{
e.printStackTrace();
System.exit(0);
}
while(!Display.isCloseRequested())
{
Entità.pulisci();
Entità.colora();
Entità.disegna();
Display.update();
}
}
}
import org.lwjgl.opengl.GL11;
public class Entità
{
//Disegna un poligono
public static void disegna()
{
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(100,100);
GL11.glVertex2f(200,100);
GL11.glVertex2f(200,200);
GL11.glVertex2f(100,200);
GL11.glEnd();
}
//Pulisce il buffer
public static void pulisci()
{
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
}
//Setta il colore al poligono
public static void colora()
{
GL11.glColor3f(0.5f,0.5f,1.0f);
}
}