MadBear
26th September 2011, 08:27
Greetings,
I have a strange problem. I have created application where user can create several QGraphicsScenes (shown is only one in main view) and since I had to use OpenGL for some items I have also used OpenGL (FBO) to save current scene as JPEG image. Now it works great until I have several scenes in "script" and some of those scenes use QGraphicsTextItem. In that case text is not rendered correctly (it is rendered only as a filled box). That does not occur if there is only one scene. In that case text is rendered correctly. What am I doing wrong? The relevant code is:
QGLFramebufferObject *mbuff=new QGLFramebufferObject(width(),height());
QStyleOptionGraphicsItem pom;
mbuff->bind();
glPushAttrib(GL_ALL_ATTRIB_BITS);
glViewport(0,0,mbuff->width(),mbuff->height());
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,mbuff->width(),0,mbuff->height(),-100,100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
QPainter paint;
paint.begin(mbuff);
paint.setRenderHint(QPainter::HighQualityAntialias ing,true);
QList<QGraphicsItem*> list=items(Qt::AscendingOrder);
int i;
for(i=0;i<list.size();i++)
{
paint.save();
paint.setMatrix(list[i]->sceneMatrix(),true);
list[i]->paint(&paint,&pom,NULL);
paint.restore();
}
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPopAttrib();
paint.end();
mbuff->release();
QImage pix=mbuff->toImage();
pix.save(fn);
delete mbuff;
I am realy at a loss here. I have tried software rendering but it is very slow.
Thank you in advance.
Regards,
MadBear
I have a strange problem. I have created application where user can create several QGraphicsScenes (shown is only one in main view) and since I had to use OpenGL for some items I have also used OpenGL (FBO) to save current scene as JPEG image. Now it works great until I have several scenes in "script" and some of those scenes use QGraphicsTextItem. In that case text is not rendered correctly (it is rendered only as a filled box). That does not occur if there is only one scene. In that case text is rendered correctly. What am I doing wrong? The relevant code is:
QGLFramebufferObject *mbuff=new QGLFramebufferObject(width(),height());
QStyleOptionGraphicsItem pom;
mbuff->bind();
glPushAttrib(GL_ALL_ATTRIB_BITS);
glViewport(0,0,mbuff->width(),mbuff->height());
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,mbuff->width(),0,mbuff->height(),-100,100);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
QPainter paint;
paint.begin(mbuff);
paint.setRenderHint(QPainter::HighQualityAntialias ing,true);
QList<QGraphicsItem*> list=items(Qt::AscendingOrder);
int i;
for(i=0;i<list.size();i++)
{
paint.save();
paint.setMatrix(list[i]->sceneMatrix(),true);
list[i]->paint(&paint,&pom,NULL);
paint.restore();
}
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glPopAttrib();
paint.end();
mbuff->release();
QImage pix=mbuff->toImage();
pix.save(fn);
delete mbuff;
I am realy at a loss here. I have tried software rendering but it is very slow.
Thank you in advance.
Regards,
MadBear