Hello Guest

There is no OpenGL context current in the current thread.

  • 1 Replies
  • 79 Views
There is no OpenGL context current in the current thread.
« on: August 30, 2018, 15:56:38 »
Hello,

I followed the beginner guide of LWJGL3 but I am experiencing a problem I am not able to solve.
I always get the exception Exception in thread "main" java.lang.IllegalStateException: There is no OpenGL context current in the current thread.
I searched a bit on the internet and I found some "solutions" but they not worked for me.
I do not have multiple threads running.
I am running Linux 64Bit and here is the important code:

Here I make the OpenGL context for the thread.
Code: [Select]
    private void pushFrame() {
        try (MemoryStack memoryStack = MemoryStack.stackPush()) {
            pWidth = memoryStack.mallocInt(1);
            pHeight = memoryStack.mallocInt(1);

            GLFW.glfwGetWindowSize(handle, pWidth, pHeight);

            vidMode = userMonitor.getResolution();
            centerWindow();

            GLFW.glfwMakeContextCurrent(handle);

            GLFW.glfwSwapInterval(1);

            GLFW.glfwShowWindow(handle);
        }
    }


This method will be called in my game loop after the window was created.
So the glfwMakeContextCurrent method is called before the createCapabilities method.
Code: [Select]
    public void loop() {

        GL.createCapabilities();

        GL11.glClearColor(0, 0, 0, 0);

        clearFrameBuffer();
        GLFW.glfwSwapBuffers(handle);
        GLFW.glfwPollEvents();

    }

If thats not enough for you i posted the whole code on ghostbin:
https://ghostbin.com/paste/r9ghg


Thanks for reading!



*

Online spasi

  • *****
  • 2028
    • WebHotelier
Re: There is no OpenGL context current in the current thread.
« Reply #1 on: August 30, 2018, 18:30:36 »
There is a terminate() call in the GameWindow constructor.