protected void createContext(final AppSettings settings) {
        glfwSetErrorCallback(
            errorCallback =
                new GLFWErrorCallback() {
                    @Override
                    public void invoke(int error, long description) {
                        final String message = GLFWErrorCallback.getDescription(description);
                        listener.handleError(message, new Exception(message));
                    }
                }
        );

        if (!glfwInit()) {
            throw new IllegalStateException("Unable to initialize GLFW");
        }

        glfwDefaultWindowHints();

        final String renderer = settings.getRenderer();

        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

        RENDER_CONFIGS
            .computeIfAbsent(
                renderer,
                s ->
                    () -> {
                        glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_FALSE);
                        glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE);
                        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
                        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
                    }
            )
            .run();

        if (settings.getBoolean("RendererDebug")) {
            glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GLFW_TRUE);
        }

        if (settings.isGammaCorrection()) {
            glfwWindowHint(GLFW_SRGB_CAPABLE, GLFW_TRUE);
        }

        glfwWindowHint(GLFW_VISIBLE, GL_FALSE);
        glfwWindowHint(GLFW_RESIZABLE, settings.isResizable() ? GLFW_TRUE : GLFW_FALSE);
        glfwWindowHint(GLFW_DEPTH_BITS, settings.getDepthBits());
        glfwWindowHint(GLFW_STENCIL_BITS, settings.getStencilBits());
        glfwWindowHint(GLFW_SAMPLES, settings.getSamples());
        glfwWindowHint(GLFW_STEREO, settings.useStereo3D() ? GLFW_TRUE : GLFW_FALSE);
        glfwWindowHint(
            GLFW_REFRESH_RATE,
            settings.getFrequency() <= 0 ? GLFW_DONT_CARE : settings.getFrequency()
        );
        glfwWindowHint(
            GLFW_COCOA_RETINA_FRAMEBUFFER,
            settings.isUseRetinaFrameBuffer() ? GLFW_TRUE : GLFW_FALSE
        );

        if (settings.getBitsPerPixel() == 24) {
            glfwWindowHint(GLFW_RED_BITS, 8);
            glfwWindowHint(GLFW_GREEN_BITS, 8);
            glfwWindowHint(GLFW_BLUE_BITS, 8);
        } else if (settings.getBitsPerPixel() == 16) {
            glfwWindowHint(GLFW_RED_BITS, 5);
            glfwWindowHint(GLFW_GREEN_BITS, 6);
            glfwWindowHint(GLFW_BLUE_BITS, 5);
        }

        glfwWindowHint(GLFW_ALPHA_BITS, settings.getAlphaBits());

        //        long monitor = NULL;

        /**
         * Let's grab the display selected, if not found it will return
         * primaryMonitor. if not full screen just use primary display data.
         */
        if (settings.isFullscreen()) {
            monitor = getDisplay(settings.getDisplay());
        } else {
            monitor = glfwGetPrimaryMonitor();
        }

        final GLFWVidMode videoMode = glfwGetVideoMode(monitor);
        int requestWidth = settings.getWindowWidth();
        int requestHeight = settings.getWindowHeight();
        if (requestWidth <= 0 || requestHeight <= 0) {
            requestWidth = videoMode.width();
            requestHeight = videoMode.height();
        }
        int requestX = GLFW_ANY_POSITION;
        int requestY = GLFW_ANY_POSITION;
        if (!settings.isFullscreen()) {
            if (settings.getCenterWindow()) {
                // Center the window
                requestX = (videoMode.width() - requestWidth) / 2;
                requestY = (videoMode.height() - requestHeight) / 2;
            } else {
                requestX = settings.getWindowXPosition();
                requestY = settings.getWindowYPosition();
            }
            glfwWindowHint(GLFW_POSITION_X, requestX);
            glfwWindowHint(GLFW_POSITION_Y, requestY);
        }
        // Lets use the monitor selected from AppSettings if FullScreen is
        // set.
        if (settings.isFullscreen()) {
            window = glfwCreateWindow(requestWidth, requestHeight, settings.getTitle(), monitor, NULL);
        } else {
            window = glfwCreateWindow(requestWidth, requestHeight, settings.getTitle(), NULL, NULL);
        }
        if (window == NULL) {
            throw new RuntimeException("Failed to create the GLFW window");
        }

        glfwSetWindowFocusCallback(
            window,
            windowFocusCallback =
                new GLFWWindowFocusCallback() {
                    @Override
                    public void invoke(final long window, final boolean focus) {
                        if (wasActive != focus) {
                            if (!wasActive) {
                                listener.gainFocus();
                                timer.reset();
                            } else {
                                listener.loseFocus();
                            }
                            wasActive = !wasActive;
                        }
                    }
                }
        );

        int platformId = glfwGetPlatform();
        if (platformId != GLFW_PLATFORM_WAYLAND && !settings.isFullscreen()) {
            /*
             * in case the window positioning hints above were ignored, but not
             * on Wayland, since Wayland doesn't support window positioning
             */
            glfwSetWindowPos(window, requestX, requestY);
        }

        // Make the OpenGL context current
        glfwMakeContextCurrent(window);

        // Enable vsync
        if (settings.isVSync()) {
            glfwSwapInterval(1);
        } else {
            glfwSwapInterval(0);
        }

        setWindowIcon(settings);
        showWindow();

        // HACK: the framebuffer seems to be initialized with the wrong size
        // on some HiDPI platforms until glfwPollEvents is called 2 or 3 times
        for (int i = 0; i < 4; i++) glfwPollEvents();

        // Windows resize callback
        glfwSetWindowSizeCallback(
            window,
            windowSizeCallback =
                new GLFWWindowSizeCallback() {
                    @Override
                    public void invoke(final long window, final int width, final int height) {
                        updateSizes();
                    }
                }
        );

        // Add a framebuffer resize callback which delegates to the listener
        glfwSetFramebufferSizeCallback(
            window,
            framebufferSizeCallback =
                new GLFWFramebufferSizeCallback() {
                    @Override
                    public void invoke(final long window, final int width, final int height) {
                        updateSizes();
                    }
                }
        );

        allowSwapBuffers = settings.isSwapBuffers();

        // Create OpenCL
        if (settings.isOpenCLSupport()) {
            initOpenCL(window);
        }

        updateSizes();
    }
Apply the settings, changing resolution, etc.

@param settings the settings to apply when creating the context.
jme3-lwjgl3/src/main/java/com/jme3/system/lwjgl/LwjglWindow.java