简体   繁体   English

QGLWidget update(rect)始终绘制整个rect

[英]QGLWidget update(rect) always paints the entire rect

I have a simple painting app using a QGLWidget that I am calling update(rect) on, passing in a rect that is much smaller than the rect of the QGLWidget . 我有一个使用QGLWidget的简单绘画应用程序,我在其中调用update(rect) ,传入的rect比QGLWidget的rect小得多。 I use a QImage to draw into, and then in the paintEvent , I draw a portion of that to the QGLWidget . 我使用QImage进行绘制,然后在paintEvent ,将其中一部分绘制到QGLWidget When I put a break point on the paintEvent method, and call event->rect() or event->region().rects() , it returns the entire rect of the QGLWidget . 当我在paintEvent方法上放置一个断点并调用event->rect()event->region().rects() ,它将返回QGLWidget的整个rect。 I would have expected it to return only the rect that was passed to the update method. 我希望它只返回传递给update方法的rect。

As a consequence, drawing on my iPhone is horribly laggy. 结果,在我的iPhone上绘图太迟了。

Here is my code: http://pastebin.com/beyyHCPw 这是我的代码: http : //pastebin.com/beyyHCPw

If you scroll to the bottom of the pastebin, you will see my logging code where I am logging which rect I draw (draw rect) to and then later which rect comes back in the paint event (update rect). 如果滚动到pastebin的底部,您将看到我的日志记录代码,在该代码中我正在记录绘制(绘制rect)到哪个rect,然后在paint事件中返回哪个rect(更新rect)。

I think that this is expected if QGLWidget is using double buffering and that you're asked to draw in a different buffer each time. 我认为,如果QGLWidget使用双缓冲,并且每次都要求您绘制一个不同的缓冲,这是可以预期的。

Dirty rects are a concept not normally used that way with GL as far as I know. 据我所知,脏直肠是一个通常不用于GL的概念。

The performance problem with your code might also be that you're uploading the content of your 1024x1536 QImage to graphics memory each time you draw it after it changed in main memory. 代码的性能问题还可能是,每次在主存储器中更改它之后,每次绘制1024x1536 QImage时,都将其上载到图形存储器。 Drawing to an intermediate Q(Open)GLFramebufferObject could be an improvement (though fast blitting using GL_EXT_framebuffer_blit might not be supported on the iPhone). 使用中间Q(Open)GLFramebufferObject可能会有所改进(尽管iPhone可能不支持使用GL_EXT_framebuffer_blit进行快速对齐)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM