Java (LWJGL) Window

54 views Asked by At

I am currently trying to figure out make to make window for a java game (with lwjgl 3.3.3). Most of the tutorials I have come across are very outdated so some help (along with some slight explanations as I am newer to java) would be very appreciated.

I have tried multiple tutorials but all of them are outdated so if you can help me or give a good tutorial I'd appreciate it.

1

There are 1 answers

0
Ociz On

If I understood the question correctly, creating a simple window looks like this..

        glfwInit();
        long glfwWindow = glfwCreateWindow(width, height, "Window title", glfwGetPrimaryMonitor(), MemoryUtil.NULL);

        glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
        glfwMakeContextCurrent(glfwWindow);

        //vsync: 1 on / 0 off
        glfwSwapInterval(1);
        //display settings
        glfwShowWindow(glfwWindow);
        //connects library tools
        GL.createCapabilities();

        //camera
        glMatrixMode(GL_PROJECTION);
        glOrtho(0, width, 0, height, 1, -1);
        glMatrixMode(GL_MODELVIEW);

        glClearColor(206f / 255f, 246f / 255f, 1.0f, 1.0f);
        while (!glfwWindowShouldClose(glfwWindow)) {
            //all draw here

            glfwSwapBuffers(glfwWindow);
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            glfwPollEvents();
        }