MyPaintable(Gui::View3DInventorViewer* v) :view(v), img(v->getGLWidget()->size(), QImage::Format_ARGB32) { img.fill(qRgba(255, 255, 255, 0)); { QPainter p(&img); p.setPen(Qt::white); p.drawText(200,200,QString::fromLatin1("Render to QImage")); } img = QGLWidget::convertToGLFormat(img); fbo = new QGLFramebufferObject(v->getGLWidget()->size()); fbo->bind(); //glClear(GL_COLOR_BUFFER_BIT); fbo->release(); { QPainter p(fbo); p.setPen(Qt::white); p.drawText(200,200,QString::fromLatin1("Render to QGLFramebufferObject")); p.end(); //img = fbo->toImage(); //img = QGLWidget::convertToGLFormat(img); } //fbo->bind(); //glEnable(GL_DEPTH_TEST); //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //glDepthRange(0.1,1.0); //glEnable(GL_LINE_SMOOTH); //SoGLRenderAction a(SbViewportRegion(128,128)); //a.apply(v->getSceneManager()->getSceneGraph()); //fbo->release(); //img = fbo->toImage(); //img = QGLWidget::convertToGLFormat(img); view->getSoRenderManager()->scheduleRedraw(); }
void resizeGL(int width, int height) { #if 0 fbObject->bind(); glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); if (width <= height) { glOrtho(0.0, 20.0, 0.0, 20.0 * GLfloat(height) / GLfloat(width), -10.0, 10.0); } else { glOrtho(0.0, 20.0 * GLfloat(width) / GLfloat(height), 0.0, 20.0, -10.0, 10.0); } glMatrixMode(GL_MODELVIEW); drawTeapots(); fbObject->release(); #else fbObject->bind(); glDisable(GL_TEXTURE_2D); glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); glEnable(GL_LINE_SMOOTH); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glDepthRange(0.1,1.0); SoGLRenderAction gl(SbViewportRegion(fbObject->size().width(),fbObject->size().height())); gl.apply(view->getSoRenderManager()->getSceneGraph()); fbObject->release(); #endif }
void QGLViewPickSurface::deactivate(QGLAbstractSurface *nextSurface) { Q_UNUSED(nextSurface); if (m_fbo) m_fbo->release(); }