I am trying a simple Qt Application using OpenGL to display a triangle on screen.

But my QGLWidget is not display anything except the background color.

Here is the code :

Qt Code:
  1. intializeGL () { } // Blank for now. not initializing any states
  2.  
  3. resizeGL () {
  4. if (h==0) // Prevent A Divide By Zero By
  5. {
  6. h=1; // Making Height Equal One
  7. }
  8.  
  9. glViewport(0,0,w,h); // Reset The Current Viewport
  10.  
  11. glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
  12. glLoadIdentity(); // Reset The Projection Matrix
  13.  
  14. // Calculate The Aspect Ratio Of The Window
  15. gluPerspective(45.0f,(GLfloat)w/(GLfloat)h,0.1f,100.0f);
  16.  
  17. glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
  18. glLoadIdentity(); // Reset The Modelview Matrix
  19. }
  20.  
  21. paintGL ()
  22. {
  23. clearWindow(); // Clear window to black
  24.  
  25. glColor3f (1.0, 1.0, 1.0);
  26. glBegin(GL_TRIANGLES); // Drawing Using Triangles
  27. glVertex3f( 0.0f, 1.0f, 0.0f); // Top
  28. glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
  29. glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
  30. glEnd(); // Finished Drawing The Triangle
  31. }
To copy to clipboard, switch view to plain text mode 

It is a simple enough code downloaded from Nehe. But the triangle is not being displayed at all!! can someone help please?