Results 1 to 4 of 4

Thread: gluPerspective and gluOrtho2d not found in QGLWidget

  1. #1
    Join Date
    Aug 2011
    Posts
    5
    Platforms
    Unix/X11

    Default gluPerspective and gluOrtho2d not found in QGLWidget

    ...And I'm running the most recent version of Qt (which, unless I'm wrong, is 4.8.0).

    What could be the issue here? So far the project I'm working on builds on Ubuntu and Windows perfectly fine, yet it won't build on Arch Linux because of this. I spoke with someone else who was running Arch as well and he too had problems building the project. The interesting thing is that while he got his Qt from Pacman, I wound up downloading the QtSDK. I'll post an example of the ppdirectives:

    Qt Code:
    1. #pragma once
    2. #include <list>
    3. #include <QGLWidget>
    4. #include <GL/glext.h>
    5. #include "SharedPtr.h"
    6. #include "Shape.h"
    7. #include "Vec2f.h"
    To copy to clipboard, switch view to plain text mode 

    And the actual header file:

    Qt Code:
    1. class BoxOfShapes
    2. : public QGLWidget
    3. {
    4. Q_OBJECT
    5. public:
    6. explicit BoxOfShapes( QWidget* parent, float width, float height );
    7.  
    8. virtual ~BoxOfShapes( void );
    9.  
    10. void addShape( std::shared_ptr< Shape > shape );
    11.  
    12. public slots:
    13. void doPhysics( void );
    14.  
    15. void resetWorld( void );
    16.  
    17. signals:
    18. void numShapesChanged( int numShapes );
    19.  
    20. protected:
    21. std::list< shared_ptr< Shape > > collide( std::list< shared_ptr< Shape > > toCollide );
    22.  
    23. std::list< shared_ptr< Shape > > explode( std::list< shared_ptr< Shape > > toExplode );
    24.  
    25. int heightForWidth( int w ) { return w; }
    26.  
    27. void initializeGL( void );
    28.  
    29. void move( std::list< shared_ptr< Shape > >& toMove );
    30.  
    31. void paintGL( void );
    32.  
    33. virtual void Render( void );
    34.  
    35. void resizeGL( int width, int height );
    36.  
    37. Vec2f mDims;
    38.  
    39. std::list< shared_ptr< Shape > > mShapes;
    40.  
    41. std::list< shared_ptr< Shape > > mParticles;
    42. };
    To copy to clipboard, switch view to plain text mode 

    And the error...

    Qt Code:
    1. void BoxOfShapes::paintGL( void )
    2. {
    3. glMatrixMode( GL_PROJECTION );
    4. glLoadIdentity();
    5. gluOrtho2D( 0, width(), 0, height() );
    6. glClear( GL_COLOR_BUFFER_BIT );
    7.  
    8. Render();
    9. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ‘gluOrtho2D’ was not declared in this scope
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void BoxOfShapes::resizeGL( int width, int height )
    2. {
    3. if ( height == 0 ) height = 1;
    4. if ( width == 0 ) width = 1;
    5.  
    6. glViewport( 0, 0, width, height );
    7. glMatrixMode( GL_PROJECTION );
    8. glLoadIdentity();
    9.  
    10. gluPerspective( 45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 8.0f );
    11. glMatrixMode( GL_MODELVIEW );
    12. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. ‘gluPerspective’ was not declared in this scope
    To copy to clipboard, switch view to plain text mode 

    I have no idea how this could be, but for whatever reason it appears that QGLWidget isn't registering the glu library. Is there a way to edit this?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: gluPerspective and gluOrtho2d not found in QGLWidget

    Qt has nothing to do with this. gluPerspective() is a function from GLU library. If you link your project against it, all will be fine.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: gluPerspective and gluOrtho2d not found in QGLWidget

    Quote Originally Posted by wysota View Post
    Qt has nothing to do with this. gluPerspective() is a function from GLU library. If you link your project against it, all will be fine.
    How do I link my project against it?

    I'm sorry if it's really simple but I just haven't found how to do it and I have the same problem.

    Also I've #included "GL/glu.h" at the header and the error message changes to "GluOrto2d undefined reference". Any idea?

    [SOLVED]

    For Ubuntu (>= 11.10) is necessary to install an extra package because the linker doesn't links correctly:

    sudo apt-get install binutils-gold
    Last edited by danadn; 25th February 2012 at 20:33.

  4. #4
    Join Date
    Sep 2013
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: gluPerspective and gluOrtho2d not found in QGLWidget

    Try to add the title file " #include "GL/glu.h" "

Similar Threads

  1. Found a bad bug in QTableWidget!
    By trallallero in forum Qt Programming
    Replies: 2
    Last Post: 7th December 2012, 13:54
  2. QtMaemo5 not found
    By toner_cloud in forum Newbie
    Replies: 0
    Last Post: 17th November 2010, 15:55
  3. Phonon_ds94.dll not found
    By thanuj in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 29th September 2010, 11:53
  4. mingw10.dll not found
    By ctote in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2010, 10:16
  5. I've found but how to use
    By Laser in forum Newbie
    Replies: 5
    Last Post: 11th August 2008, 13:52

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
  •  
Qt is a trademark of The Qt Company.