Does SDL completely encapsulates D3D and OpenGL APIs?

Simple question: can I develop a complete 3D game which its code is completely agnostic to a specific graphics API (D3D or OpenGL) using SDL?

I couldn’t find a direct and objective answer to this question so far. Some places there are ppl saying SDL will not completely abstract the graphics backend and therefore one still needs to call SDL interface functions of a specific backend, and at others, ppl saying one could develop completely agnostic to the graphics backend using SDL as SDL will choose which backend to use at compile-time based upon the target platform the code is being built.

Hi!
No, you cannot do this.
For an “agnostic” way try https://github.com/bkaradzic/bgfx.
There is also an example where the SDL is a layer between the OS and the application https://github.com/bkaradzic/bgfx/blob/master/examples/common/entry/entry_sdl.cpp.
And there is a 3D game engine implementation on top of bgfx https://github.com/fredakilla/GPlay3D.

1 Like

Not the question you asked, but perhaps worth pointing out that you can run the OpenGL backend in Windows so in practice you can write an OS-agnostic 3D game even though you can’t write a graphics API-agnostic 3D game.

1 Like