PDA

View Full Version : QFont:Handle() usage?



josep
12th June 2008, 12:36
I'm trying to render text in a QGLWidget, but I need render from OpenGL, not from QGLWidget methots.

I need to use native WGL, GLX OpenGL text rendering, using wglUseFontBitmaps and glXUseXFont.

I found in the past (1999) a message:
**********************************

Hi!

Some time ago i asked how to use this stuff under win32.

Here is the example how to use it:


int listid;
QFont aFont(font);

#ifndef WIN32
unsigned long glFont;
glFont = (unsigned long)aFont.handle();
#else
HDC glFont;
glFont = qt_display_dc();
#endif

listid = glGenLists(1);
if(listid != 0)
{
#ifndef WIN32
glXUseXFont(glFont,32,96,listid);
#else
wglUseFontBitmaps(glFont,32,96,listid);
#endif
}

qt_display_dc() seem to be a bit ugly - but it works!

Bye
Bernd

**********************************

my code:
**********************************

GLuint Offset;
QFont aFont = wOver->getFont(i);

#ifndef WIN32

Font glFont;

glFont = aFont.handle();

#else

HDC glFont;

glFont = wImag->getDC();

#endif



if(fontOffset[contextoActual][i] == -1)

{

Offset=glGenLists((GLsizei)lastfont);
#ifndef WIN32

glXUseXFont(glFont,firstfont,lastfont-firstfont+1,Offset+firstfont);

#else

wglUseFontBitmaps(glFont,firstfont,lastfont-firstfont+1,Offset+firstfont);

#endif

fontOffset[contextoActual][i]=(int)Offset;
}
glListBase((GLuint)fontOffset[contextoActual][i]);

glFinish();

**********************************


Using QFont::handle() in my code is returnig 0 (glfont is 0 and aFont is a valid QFont ) that was an invalid handle and then glXUseXFont don't work.

Has someone any idea of how to do it in qt4.4??

Thanks and Regards!

fsoltanshahi
21st October 2008, 23:19
I am struggling with the same issue, have you found any answers?

Thanks,

Fred