1

If one were to code a game for most versions of Windows, which API should be used?

I know DirectDraw works from NT4 and up (although DirectDraw is emulated on NT4 with GDI). However, I am told DirectDraw is deprecated in newer versions of Windows?

I could revert to just GDI, but then it is hard to completely eliminate flicker and tearing, since there is no double buffering with flipping between buffers.

Should I go for Direct3D or DirectDraw? Or is there some way of completely eliminating flicker in GDI?

If Direct3D is the answer, which version of it is supported on most platforms?

Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
  • 2
    Have you considered using a higher level library like SDL for this? For example SDL supports pretty much all Windows versions, and if you use it's facilities in general your game could also run on other systems like Linux or MacOS. – thkala Dec 19 '10 at 17:46
  • Do you really need to support NT4? Or even 2000? I can't imagine there's much out there still earlier than XP. – Rup Dec 19 '10 at 17:49
  • @Rup I don't have to, but it would be fun. Lower than XP would of course be dropped first, but it would be fun to support NT4 and Win95 up. – Prof. Falken Dec 19 '10 at 17:50
  • I agree with thkala, using a Cross-Platform library/toolkit will also result in higher compatibility within the Windows-World. And Cross-Platform-Support is just a pretty big bonus you'll get with it (which is, imho, the way to go in the modern world). – Bobby Dec 20 '10 at 09:05
  • @Amigable: I have to say, I find your definition of "fun" intriguing! – Dan Puzey Dec 20 '10 at 09:54
  • @Dan Puzey, I know! I get this a lot - and not just in programming. :) – Prof. Falken Dec 20 '10 at 10:14
  • Last time I checked, double-buffering with GDI was commonplace. – Aaron Klotz Dec 20 '10 at 17:45
  • @Aaron Klotz, yes, double-buffering is commonplace, but it is not obvious how you avoid tearing. – Prof. Falken Dec 20 '10 at 21:07

1 Answers1

2

Unless you are sure you will never want to port your game to any non-Windows platform, I would recommend OpenGL. It should work on all versions from 2000 upwards, and some lucky NT4 or Win98 users may be able to run it (but don't advertise those versions as "supported.") Hardware acceleration won't always work, but the impact on performance won't be noticeable for a simple 2D game. And you will be able to port it reasonably cheaply to other platforms (e.g. iPhone) if necessary.

finnw
  • 47,861
  • 24
  • 143
  • 221
  • I like it. I am considering accepting this answer. Can you double buffer and flip frames in OpenGL, even on old versions? – Prof. Falken Dec 20 '10 at 21:04
  • @Amigable, That is not specific to OpenGL. Most GPUs can do it but a few (typically found in netbooks and "business" PCs) cannot. – finnw Dec 20 '10 at 21:16
  • but OpenGL as an API (maybe with a Windows extension?) has mechanisms for doing a flip on vsync? – Prof. Falken Dec 20 '10 at 21:43
  • 1
    @Amigable, yes, and it's covered in [this question](http://stackoverflow.com/questions/589064/how-to-enable-vertical-sync-in-opengl/589232#589232). – finnw Dec 21 '10 at 17:05