Qpainter and OpenGL - Window, Qt 3.3.4
I have a problem with draw ellipse in an OpenGL window.
OS is Windows 7 and 8 and Qt 3.3.4.
The problem is that the ellipse has white background and is not white.
Maybe someone has an idea? Thank you
QPainter *p = new QPainter();
p->setPen(QPen(white,2)); // xxx xx x
glClear( GL_COLOR_BUFFER_BIT ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -10.0 ); glScalef( scale, scale, scale ); glRotatef( xRot, 1.0, 0.0, 0.0 ); glRotatef( yRot, 0.0, 1.0, 0.0 ); glRotatef( zRot, 0.0, 0.0, 1.0 ); glCallList( object );
Hi and welcome to devnet,
Are you really using Qt 3.3.4 ?
Judging from the setRasterOp() he really is.
If it's a new or relatively small app please please upgrade. It's been over a decade for Qt3 and the API has gone through 2 major revisions and a dozen of smaller ones. It's gonna be very hard getting any support for Qt3 since very few people remember it.
That being said what I say might not be true for Qt3.
Ellipse is drawn using a pen for the border and a brush for the filling. Try setting a transparent brush on the painter first. Another thing is that you're drawing with painter first and then using OpenGL to clear the window. This is weird.
With the XOR mode selected it's basically src xor dst. If the background is white before drawing then xoring it with white ellipse would result in black color. I'm guessing that's what you're seeing.
I would clear the screen to black first and overdraw with painter. If that doesn't help fill the window with black rectangle using QPainter first. Maybe it's a weird interaction of QPainter and OpenGL, but I can't really say, since this sort of thing is done completely different in modern Qt.
Btw. you have a memory leak (not releasing p). The usual way to work with QPainter is to create it on the stack, pass this in the constructor and not to call the begin/end pair (these are more for when you get a painter pointer from somewhere). Effectively you're now creating another dangling pointer every time you draw.
Unfortunately I have no budget for new version of Qt.
And I do not come on.
You might have an example code?
I need to draw a white ellipse(qpainter) on Opengl windows
Sorry. I can't help you with a sample. These days you would use methods like beginNativePainting() or QOpenGLPaintDevice class which didn't exist in Qt3.
Have you tried my suggestions (drawing opengl first and drawing a black rectangle first)?
As for the price - do you know that since Qt4 there's a free LGPL/GPL license?