miivers
31st August 2010, 14:27
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. :rolleyes:
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:
#ifndef WINDOWWIDGET_H
#define WINDOWWIDGET_H
#include "player.h"
#include <QtOpenGl/QGLWidget>
class WindowWidget : public QGLWidget
{
public:
WindowWidget(QWidget *parent = NULL);
~WindowWidget();
protected:
Player mPLayer;
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
};
#endif
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? :confused:
- What do I have to do to make a update function that runs all the time? :confused:
Michael
So we started with openGL on my school this week and instead of using glut I am giving Qt a shot. :rolleyes:
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:
#ifndef WINDOWWIDGET_H
#define WINDOWWIDGET_H
#include "player.h"
#include <QtOpenGl/QGLWidget>
class WindowWidget : public QGLWidget
{
public:
WindowWidget(QWidget *parent = NULL);
~WindowWidget();
protected:
Player mPLayer;
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent *event);
};
#endif
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? :confused:
- What do I have to do to make a update function that runs all the time? :confused:
Michael