Hello,
I have just started with OpenGl and I am using the LWJGL for it. I have created this code with the help of the OpenGl superbible.
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
public class Main {
public Main(String title){
try {
Display.setDisplayMode(new DisplayMode(600,400));
Display.setTitle(title);
Display.create();
}catch (LWJGLException e) {
e.printStackTrace();
}
//Initialization
init();
while(!Display.isCloseRequested()){
//Render
render();
Display.update();
Display.sync(60);
}
Display.destroy();
}
public static void main(String[] args){
new Main("OpenGl tests");
}
private void init(){
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL11.glOrtho(0, 640, 0, 480, 1, -1);
GL11.glClearColor(.0f, .0f, .0f, .0f);
}
private void render(){
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
GL11.glRectf(20, 20, 20, 20);
GL11.glFlush();
}
}
But I got a problem there are no graphics in the window.