InitializeGL doesnt clear whole background
-
I just started using openGL with QT
i created a class GLWidget : public QGLWidget
reimplemented initializeGL() as
initializeGL()
{
glClearColor(0.0, 0.0, 0.0, 0);
glClear(GL_COLOR_BUFFER_BIT);
}if my initial widget size(defined in ui file) goes above a certain limit then whole background is not cleared. In my case if width and height goes above 650 x550 the problem appears. I dont know whether i need to look at Qt or OpenGL for this. If it is with Qt then what do i need to do to get it right.
-
Did you override the function resizeGL()? This function resizes the OpenGL window when you resize your program's window:
@
void GLWidget::resizeGL(int width, int height)
{
int side = qMin(width, height);
glViewport((width - side) / 2, (height - side) / 2, side, side);
}
@ -
Yes I did, i override function resizeGL(int , int) and when i wirte the same code(glClear) in resize. the new background is clear when i resize. But the problem is I want it to happen with initializeGL() also.
Does there exist any default limit to QGLWidget upto which my initialize code is showing effect ?
-
I think taking it that way isn't even valid, because you're asking OpenGL to clear your scene before defining the size of the scene. initializeGL is called only once when the program starts. It's not called anymore later.
In my simulations, I do clear at each paintGL(); i.e., each time the scene changes.
@
void GLWidget::paintGL() //drawing function
{
glClear(GL_COLOR_BUFFER_BIT);
//draw next scene
}
@ -
[quote author="TheDestroyer" date="1333537380"]I think taking it that way isn't even valid, because you're asking OpenGL to clear your scene before defining the size of the scene. initializeGL is called only once when the program starts. It's not called anymore later.
In my simulations, I do clear at each paintGL(); i.e., each time the scene changes.
@
void GLWidget::paintGL() //drawing function
{
glClear(GL_COLOR_BUFFER_BIT);
//draw next scene
}
@[/quote]thnx buddy. problem solved
-
You're welcome. Although it took relatively long for the problem to get solved ^^