PDA

View Full Version : Problem on Print GraphicsScene with OpenGL



redmong
2nd June 2010, 16:37
Problem on Print Graphicsscene with OpenGL
I wanted to print OpenGL scene which is implemented with QGraphicsView and QGraphicsScene. but i can't print OpenGL scene. Rendering on display works well. Any idea on this problem? Please give me a solution.


I put OpenGL native code in QGraphicsScene:drawbackground() as follows:


void View3D::drawBackground(QPainter *painter, const QRectF &rect) // View3D inherited QGrphicsSene
{
m_WindowWidth = rect.width();
m_WindowHeight = rect.height();

painter->beginNativePainting();
Render(m_WindowWidth, m_WindowHeight); // OpenGL code
painter->endNativePainting();

painter->drawText(20, 40, "Show Text");
}

And core print code is

void OnRealPrint(QPrinter* printer)
{
QPainter painter(printer);

painter.setRenderHint(QPainter::Antialiasing);
m_pView3D->render(&painter);

//m_pView3DWidget->m_pGraphicsView->render(&painter);
}

this code only print "Show Text" text. On my tests, GrphicsItem works well on Printing. Only OpenGL code does not work.