PDA

View Full Version : QPixmap



dragon
18th January 2010, 14:55
Hello anyone

Iám using windows xp with qt-4.5.2
I have a application with QGLWidget and FTGL
I use this application for 3d font and its works fine.
Its works together with a .ttf file.
I have read the documentation FTGL and its only can be used for fonts or special fonts.

I want to use a Pixmap.
Is it possible to do this.
Must i convert the QPixmap to QBytearray? or something else QBuffer.

This is a piece of my implentation glwidget.cpp


// Set up the FTGL library for 3D text rendering
bool GLWidget::initFTGL() {
font = new FTExtrudeFont("Arial.ttf");
if (font->Error()) {
qDebug("initFTGL(): Could not load font.");
return false;
}
font->FaceSize(14);
font->Depth(1.0f);
return true;
}


In my paintGL()



void GLWidget::paintGL()
{
......
QByteArray cStr = ( QVariant("img/s.png" ) ).toByteArray() ;
FTBBox rect = font->BBox(cStr.data());
FTPoint p = rect.Upper();
glColor3f(0.0,0.0,0.0);
glRotatef(rot, 0.0f, 1.0f, 0.0f);
glTranslatef(-p.Xf() / 2.0f, -p.Yf() / 2.0f, 0.0f);
font->Render(cStr.data());
}


I only see in my application the text img/s.png not the image


Thanks in advance.

wysota
19th January 2010, 10:28
I don't think you can render a pixmap using a font renderer, this seems to be a misunderstanding of either OpenGL or FTGL. But you can use an image as a texture and render it on some quad.

dragon
19th January 2010, 20:19
Thanks for your reply.
I have already an image as texture on a different cubes.