Search code examples
javaopengllwjgl

LWJGL: How to create two different OpenGL contexts?


    GLFW.glfwMakeContextCurrent(window);
    main = GLContext.createFromCurrent();
    other = GLContext.createFromCurrent();

This is what I have tried so far, and in the other thread, I call

    GL.setCurrent(other);

But all my OGL calls have no effect (calling genVertexArrays() returns 0). I can't find any examples online of how to even create two different contexts let alone make one current in another thread.


Solution

  • You need to create another window with glfwCreateWindow (but it does not need to be visible). See the GLFW context guide.