PDA

View Full Version : QGLWidget resize problem.



anderl
20th January 2008, 15:12
Hi,

i'm using a QGLWidget in my class to establish a OpenGL Context. When i resize the QGLWidget using the resize method, the framebuffer will be resized as expected, but not the actual color target. For example, if i resize the widget to 1280x1024 and clear the scene using a red color, only a part of the scene will be cleared in red (as shown on the the following image)
http://img254.imageshack.us/img254/274/testnm7.th.png (http://img254.imageshack.us/my.php?image=testnm7.png)

The class using the QGLWidget:


class OpenGLExample
{
public:
OpenGLExample()
{
widget.resize(1280,1024);
widget.makeCurrent();
}

void draw()
{
glClearColor(1.0f,0.0f,0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT);
widget.grabFrameBuffer().save("test.png");
}
private:
QGLWidget widget;
};

And the main class:


int main(int argc, char *argv[])
{
QApplication app(argc,argv);
OpenGLExample example;
example.draw();
return 0;
}


glClear should affect the complete framebuffer and not only a part. Whats wrong with my code?

Thanks!

ConfusedSushi
20th January 2008, 21:01
try to setup the viewport with glViewPort.

anderl
22nd January 2008, 08:57
I solved it.
QGLWidget must be visible in order to get the resize working.