简体   繁体   中英

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 . I use a QImage to draw into, and then in the paintEvent , I draw a portion of that to the 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 . I would have expected it to return only the rect that was passed to the update method.

As a consequence, drawing on my iPhone is horribly laggy.

Here is my code: 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).

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.

Dirty rects are a concept not normally used that way with GL as far as I know.

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. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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