[Qt-interest] QGraphicsView promotion
Sajjad
dosto.walla at gmail.com
Mon Aug 2 12:23:26 CEST 2010
Hello forum,
I am trying to do opengl rendering to the QGraphicsView subclass. The
mainwindow consists several QGraphicsViiew widgets which i have promoted to
specialized ones.
I have set the viewport and enabled opengl rendering inside the constructor
of mainwindow() as follows:
*****************************
LightPositionWindow::LightPositionWindow(QWidget *parent)
:QMainWindow(parent)
{
setupUi(this);
graphicsViewWorldSpace->setViewport(new
QGLWidget(QGLFormat(QGL::SampleBuffers)));
graphicsViewWorldSpace->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
graphicsViewWorldSpace->setScene(new GraphicsWorldScene);
}
****************************
But the progeam exits with a warning that i have specified , saying that
OpenGL rendering context not found .
************************************''
void GraphicsWorldScene::drawBackground(QPainter *painter, const QRectF
&rect)
{
Q_UNUSED(rect);
* if(painter->paintEngine()->type() != QPaintEngine::OpenGL) {
qWarning("Scene cannot be rendered without the OpenGL support");
return;
}*
glClearColor(mBackgroundColor.redF(),mBackgroundColor.greenF(),mBackgroundColor.blueF(),1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPerspective(70,width()/height(),0.01,1000);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
const float pos[] = { mLightItem->x() - width() / 2, height() / 2 -
mLightItem->y(), 512, 0 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
//glColor4f(m_modelColor.redF(), m_modelColor.greenF(),
m_modelColor.blueF(), 1.0f);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
***************************************
In the above the bold statement gets executed and the program does not
proceed any furthur.
Any idea why it is not finding the OpenGL cotext?
Regards
Sajjad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100802/05ad952a/attachment.html
More information about the Qt-interest-old
mailing list