Jump to content
  • Advertisement
Sign in to follow this  
Kyo

Windows GDI vs OpenGL for 2D

This topic is 4811 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well I've written a 2D bomberman game using the windows GDI BitBlt function and the game runs fine. The lowest I've tested it on is a 700mhz pc with 128mb which gave a playable framerate of 25fps, and a 1ghz centrino laptop and 512mb ram was all smooth at 50fps. Now I'm considering rewriting the graphics part using OpenGL. It wouldn't be hard, but I'd just like to know for sure the performance difference and whether it's worth it? I know a 2D bomberman game should run at 60fps on sub-1ghz PC's but it's not like there's that many of them around anymore. The main reason for using OpenGL would probably be for windows 98 PC's, as the TransparentBlt function I'm using to blit has a memory leak in win98, but again are there that many windows 98 users out there looking to play a freeware bomberman clone? And would using glRasterPos be faster than using textured quads? Textured quads would benefit from 3d hardware acceleration but what if the PC/laptop doesn't have 3D hardware? I'm sure most of the performance issues are due to sloppy coding on my 3ghz PC anyway so I think I just want to use OpenGL just for the sake of it... More "professional" or something.

Share this post


Link to post
Share on other sites
Advertisement
GDI is known not to be the fastest thing in the world. Writing it for OpenGL would cause a speed-up on all but the most ancient graphics cards, but tbh if I were you I would stick with 2D and use SDL instead.

Share this post


Link to post
Share on other sites
If it runs at a playable rate then it's fast enough, don't worry about how fast it 'should' run. Though that said I'd recomend using GL over GDI for any 2D graphics work you may want to do. You'll achieve greater speeds as well as getting features such as alpha blending and multitexturing. Performing operations such as rotating and scaling is also extremely easy. Use textured quads in preference to drawing things using glRasterPos, glDrawPixels et al. Drawing directly to the display like that using GL isn't what it's designed for and I doubt it's got particularly good performance on modern hardware. Plus if you use such functions you'll have to do things like blending manually.

Share this post


Link to post
Share on other sites
I'd just stick with GDI or you can check out GDI+. The reason I say this is that GDI is guaranteed to work 100% of the times on a default windows install whereas opengl is dependent on having latest video drivers installed which can't be guaranteed. You'd be suprised how many computers are out there that don't have any sort of video drivers installed let alone decent opengl ones.

Share this post


Link to post
Share on other sites
One problem with working with the GDI is that it's slow. It might not only be easier but also faster (development-wise and program speed-wise) to use SDL. If you're looking to use hardware optimization, and complex graphic operations, you could use SDL along with OpenGL.

Share this post


Link to post
Share on other sites
I (also) think SDL would be a fine choice for moving your game to. GDI+ is pretty darn slow, and SDL gives you that ever-lingering option of going crossplatform if you ever become inclined to do so. OpenGL might be overkill -- not to mention a learning curve -- for a non-graphics-intensive 2D game, but SDL (or Allegro) would be nice choices.

(I feel like I'm seconding a lot of opinions around here, but I'll continue to do so if only for ostentatious purposes. :) )

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!