[SDL2]-Is "Dirty Rectangle" Optimization Possible? |
[SDL2]-Is "Dirty Rectangle" Optimization Possible? |
Jonas Kulla
Guest
|
2014-11-14 5:13 GMT+01:00 JeZ-l-Lee:
If you're doing accelerated rendering, either directly via OpenGL, or indirectly via SDL_Render, the backbuffer's contents become undefined once swapped. This is so things like double buffering work reliably. However, nobody is stopping you from keeping your own backbuffer (eg. a render target SDL_Texture) that you blit to the screen every frame, and onto which you can apply any optimizations you'd like, such as keeping track of the dirty region. |
|||||||||||||
|
[SDL2]-Is "Dirty Rectangle" Optimization Possible? |
Bob Rubbens
Guest
|
Have you tried caching the textures TTF generates? I never had any problems with performance that way
2014-11-14 5:33 GMT+01:00 Jonas Kulla:
|
|||||||||||||||
|
[SDL2]-Is "Dirty Rectangle" Optimization Possible? |
Ryan C. Gordon
Guest
|
Sort of. The framebuffer is invalid after you present, so you can't count on it having a stable image left over from previous drawings. You _can_ manage your own software surface and upload it to a texture as dirty rectangles, but I wouldn't recommend it. Overall, this is usually slower and uglier code. What you _should_ do is one of two things: - Don't call SDL_ttf more than necessary. If it's the same string every frame, generate the texture once with SDL_ttf and use it multiple times. - Build a texture atlas with SDL_ttf (or whatever) and have a single texture with all the glyphs on it (or several textures with several glyphs on each, if you have a lot of glyphs), and then draw your strings on the fly, picking out the glyphs you need. The beauty of having a GPU is that you don't have to manage dirty rectangles anymore...it's crazy fast to just redraw the whole screen every time, but a few rules change: uploading to the GPU is slow, so get everything to the GPU once and use it over and over, and it'll be fast, fast, fast. --ryan. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
JeZ-l-Lee
|
Hi,
Thanks for the information. I got a new optimized TTF text drawing system operation at the below URL link: http://forums.libsdl.org/viewtopic.php?t=10833 Thanks! |
|||||||||||
|