Hi all, I've wrote a simple opengl program to make some test. Here is the program:
#include <QApplication>
#include <QGLWidget>
#include <QTimer>
#include <glut.h>
class Ren : public QGLWidget
{
public:
Ren() : QGLWidget()
{
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()),
this, SLOT(updateGL()));
}
void startUpdateTimer()
{
timer->start(40);
}
void initializeGL()
{
glShadeModel(GL_SMOOTH);
glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
glClearDepth(1.0f);
glEnable(GL_DEPTH_TEST);
}
void resizeGL(int width, int height)
{
if(height == 0){
height = 1;
}
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLfloat aspectRatio = (GLfloat)width / (GLfloat)height;
gluPerspective(60.0, aspectRatio, 0.01, 10000.0);
glMatrixMode(GL_MODELVIEW);
}
void paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0, 0, 1, 0, 0, 0, 0, 1, 0);
glColor3d(1, 0, 0);
glutSolidCube(0.3);
}
QTimer *timer;
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Ren r;
r.show();
r.startUpdateTimer();
return app.exec();
}
The problem is that the application is leaking memory, when timer is active. For leak detection I used windows task manager.