[Qt-interest] beginNativePainting

John Clayton john_clayton at me.com
Thu Dec 10 17:58:21 CET 2009


Thanks - I guess the next question is then, 'when' should it be called?

By the time my paint() method for a given QGraphicsItem is being  
called - the model and projection matrix has been set up (right?) -  
and the object simply needs to set clipping and render - so if within  
the QGraphicsItem::paint() method I then call beginNativePainting(),  
doesn't that break the QGraphicsView's state setup?

So,a shorter way to ask the same question - is this code going to fly;  
or is a a 'bad thing' (tm).

It's the code in my QGraphicsItem derived base class - and is  
responsible for setting up the clipping, then drawing the content,  
then drawing the [potentially] curved border around *any* object in  
the scene

	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,  
QWidget *widget) {
		painter->beginNativePainting();
		setupClipping(painter, option, widget);
		paintContent(painter, option, widget);
		paintBorder(painter, option, widget);
		painter->endNativePainting();
	}

Thanks for the reply - I was beginning to go nuts

--
John Clayton
Skype: johncclayton




On Dec 10, 2009, at 2:35 PM, Samuel Rødal wrote:

> John Clayton wrote:
>> Hi All
>> *Must* I use the beginNativePainting() method if I intend to use  
>> my  own OpenGL commands to render content within the   
>> QGraphicsItem::paint() method?
>> Thanks
>> --
>> John Clayton
>> Skype: johncclayton
>
> It's heavily recommended, otherwise the paint engine won't be aware  
> that the GL state has changed behind its back on the next painter  
> call, and it won't have a chance to prepare a 'clean' state for you  
> to issue GL commands in.
>
> --
> Samuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091210/8f525888/attachment.html 


More information about the Qt-interest-old mailing list