spraff
22nd June 2009, 14:52
Hi, here's the code I'm working from:
class GLTest : public QGLWidget {
Q_OBJECT
public:
GLTest (QWidget * = NULL);
protected:
void initializeGL ();
void resizeGL (int, int);
void paintGL ();
};
GLTest :: GLTest (QWidget * parent) : QGLWidget (parent) {
QGLFormat f = format();
f.setDoubleBuffer (true);
setFormat (f);
}
void GLTest :: initializeGL () {
glClearColor (0.0, 0.0, 0.0, 0.0);
}
void GLTest :: resizeGL (int w, int h) {
glViewport (0, 0, (GLint)w, (GLint)h);
}
void GLTest :: paintGL () {
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1,0,0);
glBegin (GL_QUADS);
glVertex2f (0, 0);
glVertex2f (150, 0);
glVertex2f (150, 50);
glVertex2f (0, 50);
glEnd ();
swapBuffers ();
};
The red-on-black is drawn as expected, but only when the window is being resized. The rest of the time the display shows lingering artefacts of e.g. moved window borders.
Why isn't the image persistent?
Thanks
class GLTest : public QGLWidget {
Q_OBJECT
public:
GLTest (QWidget * = NULL);
protected:
void initializeGL ();
void resizeGL (int, int);
void paintGL ();
};
GLTest :: GLTest (QWidget * parent) : QGLWidget (parent) {
QGLFormat f = format();
f.setDoubleBuffer (true);
setFormat (f);
}
void GLTest :: initializeGL () {
glClearColor (0.0, 0.0, 0.0, 0.0);
}
void GLTest :: resizeGL (int w, int h) {
glViewport (0, 0, (GLint)w, (GLint)h);
}
void GLTest :: paintGL () {
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1,0,0);
glBegin (GL_QUADS);
glVertex2f (0, 0);
glVertex2f (150, 0);
glVertex2f (150, 50);
glVertex2f (0, 50);
glEnd ();
swapBuffers ();
};
The red-on-black is drawn as expected, but only when the window is being resized. The rest of the time the display shows lingering artefacts of e.g. moved window borders.
Why isn't the image persistent?
Thanks