Qt-interest Archive, October 2007
Re : QGraphicsScene and opengl
Message 1 in thread
Hello,
I tried it and it works. Like you said, I called QGraphicsView::setViewport( new QGLWidget ).
And inside the function drawBackground I call the opengl primitives.
void QGraphicsScene::drawBackground( QPainter* painter, const QRectF & rect )
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glBegin(GL_POLYGON);
glVertex3f (0.25, 0.25, 0.0);
glVertex3f (0.75, 0.25, 0.0);
glVertex3f (0.75, 0.75, 0.0);
glVertex3f (0.25, 0.75, 0.0);
glEnd();
glFlush();
}
The code above will draw a white rectangle on a black background in the background of the scene.
Now I have other kind of problems:
1. Drawing concave polygons
2. Smoothing
3. ...
Apparently, with opengl, we gain point of view performences but we lose point of view functionnalities.
For that, I think a mailing list for opengl is more suitable ;).
----- Message d'origine ----
De : Tony Rietwyk <tony.rietwyk@xxxxxxxxxxxxxxxx>
À : qt-interest@xxxxxxxxxxxxx
Envoyé le : Dimanche, 21 Octobre 2007, 16h26mn 51s
Objet : RE: QGraphicsScene and opengl
Hi Sean & Moez,
I haven't tried, but look at the Graphics View Framework help in section The
View, quote:
To enable OpenGL support, you can set a QGLWidget as the viewport by calling
QGraphicsView::setViewport().
Regards,
Tony Rietwyk
> -----Original Message-----
> From: Sean Harmer [mailto:sean.harmer@xxxxxxxxxxxxxxxxx]
> Sent: Sunday, 21 October 2007 22:20
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Re: QGraphicsScene and opengl
>
>
> I don't have an answer for you but this is something that I
> am about to start
> looking into too. So if anybody has any pointers on where to
> start that would
> be great.
>
> Sean
>
> On Friday 19 October 2007 10:38:38 moez gadri wrote:
> > Hello,
> >
> > How can use opengl to draw the background of QGraphicsScene?
> > The function drawBackground provides only access to a
> pointer on QPainter.
> >
> > Thanks in advance,
> > Moez
_____________________________________________________________________________
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail
Message 2 in thread
moez gadri schrieb:
> Hello,
> ...
> Now I have other kind of problems:
> 1. Drawing concave polygons
Huh? Doesn't glBegin(GL_LINE_STRIP) (with the proper polygon
coordinates) do the job for you?
> 2. Smoothing
Hint: try glHint (with GL_LINE_SMOOTH_HINT) or enable antialiasing for
example for lines explicitly with glEnable(GL_LINE_SMOOTH).
The quality of the antialiasing is off course dependent on the concrete
hardware (driver).
> Apparently, with opengl, we gain point of view performences but we lose
> point of view functionnalities.
Again, this depends on the quality of the OpenGL driver.
There are other techniques for antialiasing, too, if the hardware does
not provide support. For example using the accumulation buffer and
rendering the entire scene several times, as to antialias the entire
scene. But off course this takes more CPU time.
See for example "OpenGL Programming Guide" (and yes, it's a book ;) I
have the 3rd edition which only covers OpenGL 1.2), chapter 10, The
Accumulation Buffer, Scene Antialiasing
Modern graphic cards support scene antialiasing in hardware (I believe
similar to the Accumulation Buffer approach), but how to enable this I
don't know (OpenGL extensions? Or is this part now of OpenGL 2.0?)
> For that, I think a mailing list for opengl is more suitable ;).
For advanced questions, yes sure ;)
Cheers, Oliver
--
[ signature omitted ]