[Qt-interest] View JPEG in QGLWidget

Brilliantov Kirill Vladimirovich brilliantov at byterg.ru
Fri Aug 19 07:18:02 CEST 2011


>
> Try to remove the "glTranslate()" line ? it moves the quad out of view. You shouldn't apply any transformations at all as the [-1, -1]?[1, 1] rectangle already covers the whole viewport.
>
> And override the QGLWidget::resizeGL() function with something like this:
>
> void Image::resizeGL (int width, int height)
> {
>      glViewport(0, 0, width, height);
> }
>

Hello Constantin and thank for your reply!
I comment glTranslate() in paintGL, my resizeGL function:
void Image::resizeGL(int width, int height)
{
	if (width < frame_resolution.width() || height < frame_resolution.height())
		setMinimumSize(frame_resolution);
	else {
		/*(switch (mode) {
			case GL_MODE_NATIVE:
				glTranslatef(-(width - frame_resolution.width()) / 2,
							 -(height - frame_resolution.height()) / 2,
							 0.0);
				break;
			case GL_MODE_PAINTER:
				QPainter paint(this);
				paint.setWindow((width - frame_resolution.width()) / 2,
								(height - frame_resolution.height()) / 2,
								frame_resolution.width(),
								frame_resolution.height());
				break;
		}*/
		glViewport(0, 0, width, height);
	}
}

Now I see white rectangle ;)
Any ideas?



More information about the Qt-interest-old mailing list