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();
paint.begin(mbuff);
paint.
setRenderHint(QPainter::HighQualityAntialiasing,
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();
pix.save(fn);
delete mbuff;
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::HighQualityAntialiasing,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;
To copy to clipboard, switch view to plain text mode
Bookmarks