• Advertisement
Sign in to follow this  

SDL or Win32 GDI

This topic is 4275 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

I just bought Beginning Game Programming by Micheal Morrison and teaches game programming with the Win32 GDI for its primary graphics api. But i am wondering if i should learn SDL instead because i have heard that the GDI is very slow in drawing stuff to the screen. So can yall please tell me which one is better for writing games in. If i do decide to go with SDL then i am going to try and change the code so i will make the engine and all the games in SDL.(i think that will be a great challenge for while i try and learn SDL.)

Share this post


Link to post
Share on other sites
Advertisement
I've written a simple little hangman game in Win32. I am learning SDL, and realize that making it would have been so much easier in SDL. I would say SDL, but I have very little experience in either, but to me SDL is simpler and easier to work with.

Share this post


Link to post
Share on other sites
It's all about what you want to do. GDI/GDI+ is slow compared to SDL/DirectX/OGL, but it's not so slow that it's impossible to write a game with it. Can't say for sure cause I haven't seen it, but there's someone here who claims to have written a decent 2D engine in just GDI+, so apparently it's doable. If you're wanting to get things going faster or use more advanced rendering techniques, you'll need to switch over to SDL or whatever graphics library suits your needs. Hope that helps.

-AJ

Share this post


Link to post
Share on other sites
In my own experiments, I have found GDI to be much too slow for programs that redraw pretty much the entire screen every frame. For such games, you should definitely use SDL, DirectX, or OpenGL; it might be possible to optimize GDI code to be fast enough for relatively simple scenes, but it's not really worth the trouble, since DirectX and OpenGL render plenty fast enough for those same simple scenes even if your code is pretty inefficient. You might have to be a bit more careful with SDL to get an acceptable framerate, but it is still much, much faster than GDI, and SDL is easier to use than DirectX or OpenGL. My recommendation would be to learn SDL, unless you aren't interested in real-time games; GDI is great for turn based, non-animated stuff like chess, risk, poker, etc.

Share this post


Link to post
Share on other sites
I'd recommend SDL, if that's what you've been looking at besides GDI. Win32 code puts a bad taste in my mouth every time I look at it. I'm personally working on a SDL/OpenGL project. The graphics are handled almost entirely by OpenGL, and it's simple enough.

Regardless of what APIs you choose, you should be writing well-designed, well-encapsulated code that hides those things as necessary. (I say 'as necessary', because you don't always need to hide everything. You may find a given data type, for example, to be very useful and choose to use it publicly.) That way, you write this code once, and never look at it again (excusing bug fixes, etc.). It also makes porting the code-base to different APIs that much easier.

Share this post


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

  • Advertisement