Results 1 to 2 of 2

Thread: Qt and openGl

  1. #1
    Join Date
    Aug 2010
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Question Qt and openGl

    Hello new user on the forum here.

    So we started with openGL on my school this week and instead of using glut I am giving Qt a shot.

    The thing I can seem to get a good answer on is how should I use openGL in Qt if I want to make a basic gameEngine out of it? So fare what I have seen of code examples is the use of QGLWidgets.

    Basically what I have is:
    Qt Code:
    1. #ifndef WINDOWWIDGET_H
    2. #define WINDOWWIDGET_H
    3. #include "player.h"
    4. #include <QtOpenGl/QGLWidget>
    5.  
    6. class WindowWidget : public QGLWidget
    7. {
    8. public:
    9. WindowWidget(QWidget *parent = NULL);
    10. ~WindowWidget();
    11.  
    12. protected:
    13. Player mPLayer;
    14. void initializeGL();
    15. void resizeGL(int w, int h);
    16. void paintGL();
    17. void mousePressEvent(QMouseEvent *event);
    18. void mouseMoveEvent(QMouseEvent *event);
    19. void keyPressEvent(QKeyEvent *event);
    20. };
    21.  
    22. #endif
    To copy to clipboard, switch view to plain text mode 

    There is one problem with this code. The paintGL() function is only called when the window gets focus again.

    So my questions are:
    - Is QGLWidgets what I should use?
    - What do I have to do to make a update function that runs all the time?

    Michael

  2. #2
    Join Date
    Nov 2007
    Posts
    26
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt and openGl

    You can use a QTimer to control updates.

    I found the follwing helpful when trying to learn openGL with Qt:

    http://www.digitalfanatics.org/projects/qt_tutorial/chapter14.html


    Alernatively you might also want to have a look at Qt/3D
    Last edited by robertson1; 31st August 2010 at 19:32. Reason: wrong link

  3. The following user says thank you to robertson1 for this useful post:

    miivers (12th September 2010)

Similar Threads

  1. Replies: 0
    Last Post: 6th December 2009, 00:41
  2. Qt with OpenGL ES for ARM9 - All OpenGL ES tests have failed!
    By vinpa in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 3rd December 2009, 10:10
  3. OpenGL
    By randomguy in forum Qt Tools
    Replies: 2
    Last Post: 6th July 2009, 12:28
  4. Problem from OpenGL to QT OpenGL
    By nuts_fever_007 in forum Newbie
    Replies: 5
    Last Post: 15th May 2009, 09:37
  5. openGL
    By dragon in forum Qt Programming
    Replies: 2
    Last Post: 13th July 2006, 16:07

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.