title: Error while creating basic GLFW window with LWJGL 3.2.3 build 13
body: <p>I get this error <em>There is no OpenGL context current in the current thread</em> when trying to display a frame. The line where it occurs may be this one <em>GL.createCapabilities();</em> (in the private method Window.init) and i think it fails because the glcontext is not initialized or something like this.</p>
  <p>here's the code :</p>
  <pre><code>package com.engine.window;
  
  import static org.lwjgl.glfw.GLFW.*;
  import static org.lwjgl.system.MemoryUtil.NULL;
  import org.lwjgl.glfw.GLFWErrorCallback;
  import org.lwjgl.glfw.GLFWVidMode;
  import org.lwjgl.opengl.GL;
  import org.lwjgl.opengl.GLCapabilities;
  
  /**
   * The class {@code Window} represents a graphical frame.
   * This is an abstract class that cannot be instantiated directly.
   */
  public  class Window { //abstract
      public enum DisplayMode { FULLSCREEN, WINDOWED, BORDERLESS };
  
      private DisplayMode mode;
      private long window;
      private java.awt.Rectangle bounds;
  
      public Window(String title, int x, int y, int width, int height) {
          GLFWErrorCallback.createPrint(System.err).set();
          init();
  
          if ((window = glfwCreateWindow(width, height, title, NULL, NULL)) != NULL) {
              bounds = new java.awt.Rectangle(x, y, width, height);
              glfwSetWindowPos(window, x, y);
              glfwSetWindowSize(window, width, height);
  
              glfwSetKeyCallback(window, (window, key, scancode, action, mods) -&gt; {
                  if (key == GLFW_KEY_ESCAPE &amp;&amp; action == GLFW_RELEASE) {
                      glfwSetWindowShouldClose(window, true);
                  }
              });
  
              glfwMakeContextCurrent(window);
              GL.createCapabilities();
              glfwShowWindow(window);
              glfwFocusWindow(window);
          } else {
              throw new RuntimeException(&quot;Error: Failed to create the GLFW window.&quot;);
          }
      }
  
      private void init() throws RuntimeException {
          if (glfwInit()) {
              glfwDefaultWindowHints();
              glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
              long tmp = glfwCreateWindow(1, 1, &quot;&quot;, NULL, NULL); //creating a temporary window to get the available opengl version
              if (tmp != NULL) {
                  glfwMakeContextCurrent(tmp);
                  GL.createCapabilities();
                  GLCapabilities capabilities = GL.getCapabilities();
                  glfwDestroyWindow(tmp);
              
                  glfwDefaultWindowHints(); //resets window hints
                  if (capabilities.OpenGL32) {
                      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
                      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
                      glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); //avoids using old opengl
                      glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); //for mac os user
                  } else if (capabilities.OpenGL21) {
                      glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
                      glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
                  } else {
                      throw new RuntimeException(&quot;Error: Neither OpenGL 3.2 nor OpenGL 2.1 is supported.&quot;);
                  }
                  glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
                  glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
                  glfwWindowHint(GLFW_FOCUSED, GLFW_TRUE);
                  glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
                  glfwWindowHint(GLFW_CENTER_CURSOR, GLFW_TRUE);
                  glfwWindowHint(GLFW_SAMPLES, 4); //enables anti-aliasing
              } else {
                  throw new RuntimeException(&quot;Error: Failed to create the GLFW window.&quot;);
              }    
          } else {
              throw new RuntimeException(&quot;Error: Failed to Initialize GLFW library.&quot;);
          }
      }
  
      public void setMode(DisplayMode displayMode) {
          long monitor = glfwGetPrimaryMonitor();
          GLFWVidMode videoMode = glfwGetVideoMode(monitor);
          if (displayMode == DisplayMode.FULLSCREEN) {
              glfwSetWindowMonitor(window, monitor, 0, 0, videoMode.width(), videoMode.height(), 0);
          } else if (displayMode == DisplayMode.WINDOWED) {
              glfwSetWindowMonitor(window, NULL, bounds.x, bounds.y, bounds.width, bounds.height, 0);
          } else if (displayMode == DisplayMode.BORDERLESS) {
              glfwWindowHint(GLFW_RED_BITS,videoMode.redBits());
              glfwWindowHint(GLFW_GREEN_BITS, videoMode.greenBits());
              glfwWindowHint(GLFW_BLUE_BITS, videoMode.blueBits());
              glfwWindowHint(GLFW_REFRESH_RATE, videoMode.refreshRate());
              glfwSetWindowMonitor(window, monitor, 0, 0, videoMode.width(), videoMode.height(), videoMode.refreshRate());
          }
          mode = displayMode;
      }
  
      public void setMode(String displayMode) {
          setMode(DisplayMode.valueOf(displayMode));
      }
  
      public void setVSync(boolean verticalSync) {
          glfwMakeContextCurrent(window);
          glfwSwapInterval(verticalSync ? 1 : 0);
      }
  
      public void pollEvents() {
          glfwPollEvents();
      }
  
      public void swapBuffers() {
          glfwSwapBuffers(window);
      }
  
      public boolean shouldClose() {
          return glfwWindowShouldClose(window);
      }
  
      /**
       * Release the resources and destroys windows and cursors.
       */
      public void dispose() {
          glfwDestroyWindow(window);
          glfwTerminate();
          glfwSetErrorCallback(null).free();
      }
  }
  </code></pre>
  <p>The trace:</p>
  <pre><code>[java] [LWJGL] GLFW_NO_WINDOW_CONTEXT error
       [java]     Description : Cannot make current with a window that has no OpenGL or OpenGL ES context
       [java]     Stacktrace  :
       [java]             org.lwjgl.glfw.GLFW.glfwMakeContextCurrent(GLFW.java:4522)
       [java]             com.engine.window.Window.&lt;init&gt;(Window.java:42)
       [java]             com.engine.window.Stage.&lt;init&gt;(Stage.java:14)
       [java]             com.engine.window.Stage.create(Stage.java:9)
       [java]             com.engine.application.Application.onstart(Application.java:73)
       [java]             com.engine.application.Application.setup(Application.java:60)
       [java]             com.engine.application.Plateform.launchApplication(Plateform.java:27)
       [java]             com.engine.application.Application.launch(Application.java:39)
       [java]             Launcher.main(Launcher.java:9)
       [java] [LWJGL] An OpenGL context was in an error state before the creation of its capabilities instance. Error: 0x502
       [java] Exception in thread &quot;main&quot; java.lang.RuntimeException: Error: Failed to create and initialize a new instance of the constructor's declaring class : class Launcher.
       [java]     at com.engine.application.Plateform.launchApplication(Plateform.java:29)
       [java]     at com.engine.application.Application.launch(Application.java:39)
       [java]     at Launcher.main(Launcher.java:9)
       [java] Caused by: java.lang.IllegalStateException: There is no OpenGL context current in the current thread.
       [java]     at org.lwjgl.opengl.GL.createCapabilities(GL.java:378)
       [java]     at org.lwjgl.opengl.GL.createCapabilities(GL.java:322)
       [java]     at com.engine.window.Window.&lt;init&gt;(Window.java:43)
       [java]     at com.engine.window.Stage.&lt;init&gt;(Stage.java:14)
       [java]     at com.engine.window.Stage.create(Stage.java:9)
       [java]     at com.engine.application.Application.onstart(Application.java:73)
       [java]     at com.engine.application.Application.setup(Application.java:60)
       [java]     at com.engine.application.Plateform.launchApplication(Plateform.java:27)
       [java]     ... 2 more
       [java] Java Result: 1
  </code></pre>