Direct3D under SDL

I am currently writing a high level 2D game programming library that runs on
top of SDL. I currently have rendering backends for OpenGL and for the SDL
2D API. I want to add a third rendering backend for Direct3D so that the
numerous Windows users who have a 3D card but don’t have OpenGL drivers can
benefit from 3D acceleration. I still want to use SDL for event handling
and audio. I see three possible approaches:

  1. Expose the DirectDraw interface SDL_SysWMInfo on Windows.
  2. Create a Direct3D window in user code and somehow transfer it to SDL.
  3. Add a SDL_DIRECT3D flag that tells SDL to create a Direct3D window,
    analogous to SDL_OPENGL.

AFAIK all three would require changes to SDL. My questions:

  1. Which of these approaches is best? Do any of these approaches have
    hidden drawbacks?

  2. Is there any chance of seeing these changes in a future version of SDL?

–?
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com

Rainer Deyke wrote:

I am currently writing a high level 2D game programming library that runs on
top of SDL. I currently have rendering backends for OpenGL and for the SDL
2D API. I want to add a third rendering backend for Direct3D so that the
numerous Windows users who have a 3D card but don’t have OpenGL drivers can
benefit from 3D acceleration. I still want to use SDL for event handling
and audio. I see three possible approaches:

  1. Expose the DirectDraw interface SDL_SysWMInfo on Windows.
  2. Create a Direct3D window in user code and somehow transfer it to SDL.
  3. Add a SDL_DIRECT3D flag that tells SDL to create a Direct3D window,
    analogous to SDL_OPENGL.

AFAIK all three would require changes to SDL. My questions:

  1. Which of these approaches is best? Do any of these approaches have
    hidden drawbacks?

  2. Is there any chance of seeing these changes in a future version of SDL?

All 3 approaches implement platform-dependent functionality.
If you simply want to do 2D over Direct3d, why not just implement
direct3d as a new SDL rendering backend ? Just like what is done with dx5…

Stephane

I successfully integrated Direct3D to SDL with no changes to SDL. I
submitted that a long time ago to Sam to be a FAQ but I’m not sure if it
was included - I’ll try to find the email and send it again.

--Gabriel

Stephane Marchesin wrote:

All 3 approaches implement platform-dependent
functionality.
If you simply want to do 2D over Direct3d, why not just
implement
direct3d as a new SDL rendering backend ? Just like what
is done with dx5…

Because my high level library should be able to take advantage of Direct3D
features that are not available through SDL.

–?
Rainer Deyke - rainerd at eldwood.com - http://eldwood.com

I successfully integrated Direct3D to SDL with no changes to SDL. I
submitted that a long time ago to Sam to be a FAQ but I’m not sure if it
was included - I’ll try to find the email and send it again.

I think it got lost. Can you add it to the wiki project?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

I successfully integrated Direct3D to SDL with no changes to SDL. I
submitted that a long time ago to Sam to be a FAQ but I’m not sure if
it
was included - I’ll try to find the email and send it again.

[Sam] I think it got lost. Can you add it to the wiki project?

Sure. If I didn’t lose it too :slight_smile:

--Gabriel