title: OpenGL or GLFW renders ok only when moving the window
body: <p>I'm just trying to draw a line between the bottom left corner and the top right corner of the screen. The result is quite annoying since it renders a line that goes from the bottom left corner to the middle point of the screen... However if I move the window position with the mouse, it suddenly changes and renders properly! What is happening and how can I solve this?</p>
  
  <p>I'm running the code on a macOS system and it's being builded using Xcode.</p>
  
  <p>Before moving the window:</p>
  
  <p><a href="https://i.stack.imgur.com/NOBDb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/NOBDb.png" alt="Before moving the window"></a>
  <br></p>
  
  <p>After moving the window:</p>
  
  <p><a href="https://i.stack.imgur.com/1rQja.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1rQja.png" alt="After moving the window"></a>
  <br></p>
  
  <p>This is the code:</p>
  
  <pre><code>#include &lt;GLFW/glfw3.h&gt;
  
  #define SCREEN_W 640
  #define SCREEN_H 480
  
  int main(int argc, char * argv[]) {
  
      glfwInit();
  
      GLFWwindow* window = glfwCreateWindow(SCREEN_W, SCREEN_H, "GLFW Window", NULL, NULL);
  
      glfwMakeContextCurrent(window);
  
      float lineVertices[] = {
          0, 0, 0,
          SCREEN_W, SCREEN_H, 0
      };
  
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glViewport(0.0f, 0.0f, SCREEN_W, SCREEN_H);
      glOrtho(0, SCREEN_W, 0, SCREEN_H, 0, 1);
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  
      while (!glfwWindowShouldClose(window)) {
          glClear(GL_COLOR_BUFFER_BIT);
  
          glEnableClientState(GL_VERTEX_ARRAY);
          glVertexPointer(3, GL_FLOAT, 0, lineVertices);
          glDrawArrays(GL_LINES, 0, 2);
          glDisableClientState(GL_VERTEX_ARRAY);
  
          glfwSwapBuffers(window);
  
          glfwPollEvents();
      }
  
      glfwDestroyWindow(window);
  
      glfwTerminate();
  
      return 0;
  }
  </code></pre>