Results 1 to 2 of 2

Thread: QGLWidget trouble again

  1. #1
    Join Date
    Jul 2009
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy QGLWidget trouble again

    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?

  2. #2
    Join Date
    Mar 2008
    Posts
    27
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGLWidget trouble again

    Prepend those functions with void. If you don't specify a type, C++ will assume it's int. Also, you're not following the ANSI programming standard.

    If you want a more complete example of the NeHe tutorial in Qt, check out my port of them - http://wesley.vidiqatch.org/03-08-20...apter-1-and-2/

Similar Threads

  1. QGLWidget trouble
    By John82 in forum Qt Programming
    Replies: 9
    Last Post: 31st July 2009, 01:03
  2. Replies: 1
    Last Post: 23rd April 2009, 09:05
  3. Replies: 1
    Last Post: 21st November 2008, 07:00
  4. QGLWidget resize problem.
    By anderl in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2008, 08:57
  5. QGLWidget on another QGLWiget
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2006, 09:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.