Advertisement

Deciding which graphics API to use

Started by March 20, 2020 08:10 PM
22 comments, last by primarybastard 4 years, 10 months ago

I'm building my own engine and am trying to decide on which graphics API to use. My graphical requirements are simple, I'm going for a mid-late 90s art style. As of right now I'm only concerned with Windows. My entire graphics programming experience at this point is using OpenGL to draw some cubes and navigating the camera around this space.

That said, I have a few questions:

  • Is there any reason I should prefer DX11 over DX10? As far as machine compatibility goes, DX10 has more reach and it's unlikely DX11 offers any new features I'll need.
  • On that note, is DX9 worth using?
  • Is the quality of OpenGL drivers across vendors still inconsistent? Would it be on par with Direct3D for a project with my graphical requirements?
  • Is it worth using the bgfx library with my limited experience? Would it simplify things or does it assume I already understand the entire pipeline? Would it just make things harder to learn?
  • I've heard Frank Luna's DX11 book uses a lot of deprecated material. Is it with reading if I decide to use DX11? Is the DX10 book worth reading if I choose DX10?

primarybastard said:
Is there any reason I should prefer DX11 over DX10? As far as machine compatibility goes, DX10 has more reach and it's unlikely DX11 offers any new features I'll need.

DirectX11 and DirectX10 are very similar, with 11 being the more complete API, and there are a few neat features that can make your life easier, especially when targeting 11.1 or 11.2.
Also, forget DirectX10 having more reach. DX11 has feature levels backwards compatible up until 9, which allows you to target GPUs that don't even support DirectX11 naturally. Only requirement is Win7/10, and given that Windows Vista is dead long along, that should not be a problem.

primarybastard said:
On that note, is DX9 worth using?

DX9 is slightly easier to setup, especially if you use the fixed function pipeline. Other than that, DirectX11 in the long run might even be easier to handle - ie. I find Cbuffers a very handy feature versus DX9s way of binding constants by global slots.

primarybastard said:
Is the quality of OpenGL drivers across vendors still inconsistent? Would it be on par with Direct3D for a project with my graphical requirements?

The last time I checked (a few years ago), OpenGL was still very inconsistent. Projekt might work on my main PC, but crash on another. Some illegal things you can do in shaders on one driver while another forbits it and complains.
Also, if you can choose, I would always go with DirectX. Its the much better and cleaner API. OpenGL has that weird resource model where (most/)every resource is just an integer, making things harder to get right. Also error reporting on OpenGL is much worse. It takes OpenGL4 and a compatible driver to even get any practical formatted error-mesages, while DirectX11 will scream in your face exactly whats wrong at every turn.

Can't comment on the rest of your questions.
However, ;TL;DR, having written a backend implementation for my engine in DX9, DX11 and OpenGl, I would say DX11 wins.
(my main usecase ATM is also a 2D-game with graphics similar to yours from 1990, so I'm not talking strictly due to 3D requirements ? )

Advertisement

Regarding Dx10 vs 11, there is no reason whatsoever to prefer 10 over 11. Every PC which supports Dx10 will also support 11, at the worst case via feature levels, so just go straight to 11 and use feature levels for downlevel hardware. 11 will also be better documented, you'll find more examples, and it's better supported by Microsoft, whereas 10 is basically just a dead stopgap version by now.

Don't go near 9. With 9 you'll be dealing with nonsense such as lost devices, half-pixel offsets and seemingly arbitrary restrictions. If you're thinking about 9 for downlevel hardware, don't - use 11 with feature levels instead. If you're thinking about 9 for Windows XP support, you're probably better off with OpenGL. Or even better, don't bother with XP.

It's too long since I've worked with OpenGL and I don't have direct experience of the items in your other questions, so I'll leave those for others to deal with.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Good to know about DX11's backwards compatibility. I think that's what I'll go with. Next step for me is choosing the right learning resource.

@primarybastard Take a look at Vulkan. For gaming, it's the future. www.khronos.org/vulkan

JeffinPNW said:
@primarybastard Take a look at Vulkan. For gaming, it's the future. www.khronos.org/vulkan

No, please don't. Vulkan is a very bad starting point if you have little experience with graphics APIs. Unless you need the additional freedom and performance, I would never recommand Vulkan (or DX12 for that matter). The increased complexity and proneness to error is substantial.
(Yeah, OpenGL is pretty shitty itself, and vulkan seems to be making improvements on the API, but if DX11 is a choice, that doesn't matter. And in regards to “the future”. I can't see the future being only Vulkan/DX12-stlye API with no other options. I would think that there will always have to be an API that isn't quite as demanding in micro-managing things as the new APIs. Unless they wanna screw over beginners entirely, which I don't hope).

Advertisement

I can second that. I am only a hobbyist and tried to start with Vulkan in 1.0. The specification was no enlightening read for me at that time and i was overwhelmed by the complexity. I then decided in favour of opengl, but a recent version (4.5). I am on Linux, so there is not that much choice for me for a basic graphics api. The documentation (e.g. red and blue book) is really good and helps get running quickly.

I can say nothing about the Microsoft versions. I reimplemented CDLOD, originally wrtten for D9, in OpenGL 4.5. I also played with a few tutorials on Vulkan (the ones from Sascha Wilhelms, they are on github), and must say that i don't realize performance differences between opengl and vulkan, at least not in the number of vertices, but i have only scratched the surface.

Otoh, one needs >1500 lines of code for a simple scene in Vulkan, that could equally be done with just a few hundred in OpenGL 4.5. A few weeks ago i looked again at Vulkan in version 1.2 now and saw that they start to enumerate their API calls for different purposes. Do they still have to find their way :-/ ?

So for a more rewarding start, OpenGL 4.5 or the Microsoft analoguous (DX11 ?) will probably give you an easier start as well. Nevertheless, expect stones on the way.

One observation about OpenGL is that there's basically two options that make sense. You either go for a more recent variant and use it's core API with DSA features, or you go for a really old variant - 1.4 or earlier - where the object zoo didn't become too much, and where it was used by id Software games so the vendors made damn certain their implementations behaved.

OpenGL versions in between the two tend to be quite insane, and we're really the source of all the “OpenGL is broken” hoo-hah from a few years back.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

@21st Century Moose Is OpenGL 1.4 consistent on all modern hardware between vendors? I don't really care to use any features beyond the complexity of Quake 1. Would I still face any potential drawbacks if I used GL 1.4 over DX11?

primarybastard said:
@21st Century Moose Is OpenGL 1.4 consistent on all modern hardware between vendors? I don't really care to use any features beyond the complexity of Quake 1. Would I still face any potential drawbacks if I used GL 1.4 over DX11?

OpenGL still a much more sucky API, mostly due to being old. Its also much harder to getting to work under windows. For DX11, you install Windows-SDK (probably already there if you are developing for windows), include the headers, and done.

OpenGL cannot be used without an external helper, like GLEW or GLUT, which binds the DLL-only calls to a c++-interface. Even getting the window/backbuffer-interaction is much more of a chore.

Well as you can tell I'm not a huge fan of OpenGL. I honestly cannot say without a doubt that the smaller featureset will be a win for you in the long run. Perhaps you should take an afternoon for both OpenGL and DX11, test it out and see which one is easier to get going and which API you like best for yourself.

This topic is closed to new replies.

Advertisement