private void InitGL() { GL.createCapabilities(); System.out.println("OpenGL: " + glGetString(GL_VERSION)); glEnable(GL13.GL_MULTISAMPLE); glEnable(GL_DEPTH_TEST); glViewport(0, 0, pix_width, pix_height); }
public void init() { // if not true after being executed then it will fail. - THIS MUST RETURN TRUE IN ORDER TO // CONTINUE if (glfwInit() != GL_TRUE) { // Once GLFW is initialised - window can be created System.err.println("GLFW initialisation has failed"); throw new IllegalStateException("Unable to initialize GLFW"); } // indicate that the window we wish to create is to be made resizable glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); // glfwCreateWindow(width, height, title, monitor, share) window = glfwCreateWindow(800, 600, "Mikes Tester Window", NULL, NULL); // if window is not populated with necessary bytes - then it fails if (window == NULL) { System.err.println("Failed to create window"); glfwTerminate(); throw new RuntimeException("Failed to create the GLFW window"); } glfwSetKeyCallback(window, keyCallback = new Input()); // Returns the video resolution of primary monitor GLFWVidMode vidMode = glfwGetVideoMode(glfwGetPrimaryMonitor()); // int WIDTH = 300; int HEIGHT = 300; // Centre the window glfwSetWindowPos(window, (vidMode.width() - WIDTH) / 2, (vidMode.height() - HEIGHT) / 2); // Make the OpenGL context current glfwMakeContextCurrent(window); // library can detect the context and make the OpenGL bindings available for use. GL.createCapabilities(); // Enable v-sync glfwSwapInterval(1); // show the window glfwShowWindow(window); // glClearColor(056f, 0.258f, 0.425f, 1.0f); glEnable(GL_DEPTH_TEST); System.out.println("OPenGL: " + glGetString(GL_VERSION)); }
private void loop() { GL.createCapabilities(); System.out.println("OPENGL VERSION " + glGetString(GL_VERSION)); glClearColor(0, 0, 0, 0); glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, WORLD_X, WORLD_Y, 0, -1, 1); while (!glfwWindowShouldClose(winID)) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); drawMe(); glfwSwapBuffers(winID); glfwPollEvents(); } }