PDA

View Full Version : renderText of QGLWidget not working



Elmo23x
7th July 2008, 18:25
Hello!

I try to display some text in my QT/OpenGL application. I try to use the methond renderText... but instead of letters "squares" are drawn (you can see them on red on the top left corner of the attached screenshot). I hope you can help me.

The code I use is this:



void OGLFrame::paintGL_R(GLenum mode, int x, int y)
{
GLint vp[4];
bool select;

glViewport(_vp[0], _vp[1], _vp[2], _vp[3]);

if(mode != GL_SELECT)
{
select = false;

glRenderMode(GL_RENDER);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
}
else
{
select = true;

glGetIntegerv(GL_VIEWPORT, vp);

glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();

gluPickMatrix((GLdouble) x, (GLdouble) y, 5.0, 5.0, vp);
}

gluPerspective(_fovy, _aspect, 0.01, 2*EXT);

glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();

this->setCamera();

_ph->drawObjects(select);

this->drawBackGround();

glColor4f(1.0, 0.0, 0.0, 1.0);
this->renderText(100, 100, "Hola");

// glMatrixMode(GL_PROJECTION);
// glPushMatrix();
// glLoadIdentity();

// glMatrixMode(GL_MODELVIEW);
// glPushMatrix();
// glLoadIdentity();

// renderText(100, 100, "Hola");

// glMatrixMode(GL_MODELVIEW);
// glPopMatrix();
// glMatrixMode(GL_PROJECTION);
// glPopMatrix();


glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glMatrixMode(GL_PROJECTION);
glPopMatrix();

glFlush();
glFinish();
}


As you can see, I made different attempts, but I always get the same result.

Thanks for your help

Elmo23x
10th July 2008, 12:00
Upgrading from qt 4.3.4 to 4.4.0 made it work.

Is it a bug of qt 4.3? or was I doing something wrong?

Rashi
19th January 2016, 05:16
Hi,

I am facing similar issue after porting my code to Qt5 from Qt 4.8, instead of text square/rectangular blocks are displayed on QGLWidget.
Please let me know if u found reason for this issue. Text displayed fine with Qt 4.8.

Thanks.