Win32 API: Am I missing something?

Started by
4 comments, last by Anon Mike 17 years, 11 months ago
I am currently writing an application that has my own customized GUI style (or at least I'm intending to), the thing is, GDI is very slow and drawing some effects using bitmap blits, text and straight GDI calls makes the application update slowly, it even has something that looks like tearing when repainting, you know like when you create a graphical application that uses a single buffer and try to draw things as fast as possible? I have seen many applications that completely customizes the look with alpha blending, animation and other effects but they still retain the highest performance possible, what are these applications using to achieve that under windows? what is the secret? Thanks in advance for any replies.
------------------------
Advertisement
They are most likely also using GDI. They are just using smart tricks like only re-painting when absolutely required. In a full-screen game we re-paint as fast as possible, under Win32 we should wait for the WM_PAINT message and only paint inside the "dirty region".
when using GDI i almost always draw to a dibsection and blit the result to the client window rather than draw directly to the window. this way, when the window needs repainting but the drawing hasn't changed, you only have to reblit your dibsection rather than redraw everything. it's kind of like caching, sort to say, and it works fairly well.
Bliting to a dib section is a very nice idea, but how slow is it for an application that constantly updates it's contents? is it fast enough?
------------------------
It's fast enough for simple 2D games and non-game applications, but it really depends on how many BitBlt, PatBlt, and other GDI calls you are making to it, and the amount of overdraw. you can reap 60-100 fps easily if you're careful. If the sheer amount of GDI calls is too much for your system however, you'd probably be better off switching to Direct3D (like if you have hundreds of moving lines, it's better to use Direct3D's line list or line strip rather than a ton of MoveToEx and LineTo calls).
GDI is fast enough for basically everything except complex games and really high powered CAD stuff and the like. The most common reason an app will run slow is that, as has been mentioned, it has some naive repainting logic that makes no attempt to optimize what it is drawing.
-Mike

This topic is closed to new replies.

Advertisement