title: Converting Window coordinates to Axis coordinates in OpenGL
body: <p>Im creating a simple program in OpenGL to draw rectangles with the mouse. My goal is to click somewhere, drag the mouse and create a rectangle just like you do in paint or any other design program.</p>
  
  <p>I have a view defined like:</p>
  
  <pre><code>glMatrixMode(GL_PROJECTION);
  glOrtho(AXIS_X_MIN, AXIS_X_MAX, AXIS_Y_MIN, AXIS_Y_MAX, AXIS_Z_MIN, AXIS_Z_MAX);
  </code></pre>
  
  <p>and a window defined this way:</p>
  
  <pre><code>glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT);
  </code></pre>
  
  <p>How can I convert the window coordinates which go from 0 to WINDOW_WIDTH and from 0 to WINDOW_HEIGHT into axis coordinates and respective quadrants?</p>