Hi,
I' trying to do a minimal OpenGL Image Viewer. Here's the code:
Qt Code:
  1. class ImageWidget : public QGLWidget
  2. {
  3. QPixmap pixmap;
  4. public:
  5. ImageWidget(const QPixmap &_pixmap, const IO& _io, QWidget *parent=0)
  6. : QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
  7. , pixmap(_pixmap)
  8. {
  9. }
  10. void resizeGL(int w, int h)
  11. {
  12. glViewport(0, 0, w, h);
  13. }
  14. void paintGL()
  15. {
  16. glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);
  17. glLoadIdentity();
  18.  
  19. glMatrixMode(GL_PROJECTION);
  20. glPushMatrix();
  21. glLoadIdentity();
  22.  
  23. glOrtho(0, width(), 0, height(), -1, 1);
  24. glMatrixMode(GL_MODELVIEW);
  25. glPushMatrix();
  26. glLoadIdentity();
  27.  
  28. bindTexture ( pixmap, GL_TEXTURE_2D, GL_RGBA );
  29. glBegin (GL_QUADS);
  30. glTexCoord2f (0.0, 0.0); glVertex3f (10.0, 10.0, 0.0);
  31. glTexCoord2f (1.0, 0.0); glVertex3f (width()-10, 10.0, 0.0);
  32. glTexCoord2f (1.0, 1.0); glVertex3f (width()-10, height()-10, 0.0);
  33. glTexCoord2f (0.0, 1.0); glVertex3f (10.0, height()-10, 0.0);
  34. glEnd ();
  35. /*glBegin(GL_TRIANGLES);
  36. glColor3ub(255, 0, 0);
  37. glVertex2d(0, 0);
  38. glColor3ub(0, 255, 0);
  39. glVertex2d(width(),0);
  40. glColor3ub(0, 0, 255);
  41. glVertex2d(width()/2, height());
  42. glEnd();*/
  43. }
  44. };
To copy to clipboard, switch view to plain text mode 
The problem is I just see a white rectangle instead of the image. The commented code draws a triangle just fine, so I seem to have set up the viewport correctly.
I'm probably making some very simple mistake, so I'm thankful for any suggestions!

btw. Should I move any code from paintGL() to initGL()? I'm not sure if I have to make all of these calls every time I render the scene.