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
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