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:
#ifndef WINDOWWIDGET_H
#define WINDOWWIDGET_H
#include "player.h"
#include <QtOpenGl/QGLWidget>
{
public:
WindowWidget
(QWidget *parent
= NULL);
~WindowWidget();
protected:
Player mPLayer;
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
};
#endif
#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
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
Bookmarks