title: How to make original (0,0) coordinate to be on the top left of QGLWIdget?
body: <p>I want to display an image using QGLWidget,  it doesn't show in the correct way, one of the problems is the original coordinate is on the bottom left of the widget.
  I would like to know how to make the original coordinate to be on the top left and flip the y axis.</p>
  
  <p><img src="https://i.stack.imgur.com/S0dbX.png" alt="enter image description here"></p>
  
  <p>here's my code:</p>
  
  <p>header</p>
  
  <pre><code>#ifndef _GLImageDisplay_H_
  #define _GLImageDisplay_H_
  
  #include "stdafx.h"
  
  class GLImageDisplay : public QGLWidget
  {
      Q_OBJECT
  
  public:
      GLImageDisplay(QWidget *parent = 0);
  
      void DisplayImage(QString img);
  
  protected:
      void initializeGL();
      void resizeGL(int w, int h);
      void paintGL();
  
  private:
      QImage svgImage;
      GLubyte* gluImage;
  };
  
  #endif
  </code></pre>
  
  <p>cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include "GLImageDisplay.h"
  
  GLImageDisplay::GLImageDisplay(QWidget *parent) : QGLWidget (parent) 
  {
  }
  
  void GLImageDisplay::DisplayImage(QString img)
  {
      svgImage.load(img);
      resize(svgImage.size());
  
      gluImage = new GLubyte[svgImage.height() * svgImage.width() * 3];
      for (int a = 0; a &lt; svgImage.width(); ++a)  
      {
          for (int b = 0; b &lt; svgImage.height(); ++b) 
          {
              QColor color = svgImage.pixel(a, b);
              gluImage[3 * (a + b * svgImage.width()) + 0] = (GLubyte) color.red();
              gluImage[3 * (a + b * svgImage.width()) + 1] = (GLubyte) color.green();
              gluImage[3 * (a + b * svgImage.width()) + 2] = (GLubyte) color.blue();
          }
      }
  
      this-&gt;setMinimumWidth(svgImage.width());
      this-&gt;setMinimumHeight(svgImage.height());
  }
  
  void GLImageDisplay::initializeGL() 
  {
      glClearColor(0.5, 0.5, 0.5, 1.0);
      glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  }
  
  void GLImageDisplay::resizeGL(int w, int h) 
  {
      glViewport(0, 0, svgImage.width(), svgImage.height());
  
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      glOrtho(0, svgImage.width(), 0, svgImage.height(), 0, 1);   
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
  }
  
  void GLImageDisplay::paintGL() 
  {
      glClear(GL_COLOR_BUFFER_BIT);
      glRasterPos2i(0, 0);
      glDrawPixels(svgImage.width(), svgImage.height(), GL_RGB, GL_UNSIGNED_BYTE, gluImage);
  }
  </code></pre>