views:

104

answers:

3

I've been writing a small desktop gadget-type application that displays scrolling text along the bottom of the screen (Similar to the old CNN news ticker), however the performance of GDI is just unsatisfactory (As high as 8-12% on a quad core and 20% on a single core) even after I've attempted to clean out bottlenecks.

I was considering using OpenGL instead to render everything, but I don't know if that is a reasonable option to require users to have hardware acceleration for a tiny app like this.

Does anybody have any input on this?

+2  A: 

If you're comfortable with using OpenGL and your intended users are happy with the additional dependencies that OpenGL brings then I say go for it. :)

In terms of staying with GDI, I'd make sure you're rendering the text a few times as possible (through such techniques as rendering to bitmap and just scrolling that instead).

If neither one of those two options sounds appealing then there's always DirectX.

lzcd
Right now the way I have it setup is that each ticker loops through all the active items (Text, bitmaps, etc..) and updates their positions and then, in another method, draws all the items to a bitmap.When drawing to the actual window, the ticker bitmap is bitblt'd to the window itself.I went with this design because it would allow me to optionally have more then one ticker.
JamesK89
+1  A: 

I wouldn't want to install open gl for a program like that. You say that you "attempted" to eliminate the bottlenecks, but it does not sound like you succeeded. Like lzcd mentioned, there are other ways to scroll text than to repaint it constantly. Why not just draw to a bitmap and scroll that?

Ed Swangren
Yes, I originally used GDI+ but I moved to GDI and didn't notice a huge performance improvement. I also tried things like ignoring the paint event until a new frame was ready to prevent overdraw.However, like lzcd mentioned I never thought of prerendering the entire ticker beforehand, which sounds like the magic bullet.
JamesK89
@Ed:At least for a typical OS, the user doesn't install anything extra for a program to use OpenGL. There are undoubtedly *some* exceptions (e.g., a Linux distribution that does't include Mesa3D, at least by default) but it's *usually* transparent to the user.
Jerry Coffin
Yeah, you're right about that, though you would still have to bundle it (or link to it) in your app and make sure they are using the right version. I guess my point was that, for something so simple, there is no reason to use a big graphics library.
Ed Swangren
+2  A: 

You could write the app in WPF and let WPF handle the acceleration for you (it's backed by DirectX).

Matt Greer