Picking between OpenGL vs. DirectX

I’m primarily developing my game for PCs (Windows and Linux) if that matters. After reading the latter part of this thread and some of this thread, it seems to me that OpenGL and DirectX projects in MonoGame are pretty much identical in terms of functionality.

That said, how do I choose between the two for any given project I’m working on? Does it come down to platform support?

1 Like

DirectX is windows only, OpenGL is cross platform. You can create a solution that contains projects for both and a third project that contains all the code that can be used by both.

For Example:

- DesktopGL (Project)
- DesktopDX (Project)
- Common (Project)

Hope this helps…


Thanks, that helps. From what I read, OpenGL works well on Windows, too. Isn’t it simpler to also have a DesktopGL project alone and put all the code there?

Your welcome.

Depends on what you are trying to do. Having separate projects can help with organization and code reuse.

Can you elaborate? I’ve used MonoGame a lot over the years, but I’m approaching this as a complete newbie.

My understanding is that separating concerns (data vs. view objects) is a good idea (best practice?) so I use something MVC-like. The actual rendering goes in the MonoGame OpenGL project, and as much as possible is simple POCO objects in a class library.

That pretty much sums it up. I was thinking in terms of reuse, not DirectX and OpenGL… Sorry for the confusion…

1 Like

I’d use OpenGL since you change virtually nothing to make it work on Linux. If you used both - I’d keep in mind that the shaders need to be tweaked a bit with a few tiny differences between OpenGL and DirectX (ie: some of the input formats). The differences are very tiny tho.

If you want to use other types of advanced shaders (like geometry shaders, etc), you can use compiled shader objects (.cso files) with DirectX version. I have a tutorial for that on youtube.
To do so with OpenGL is more tricky since it would need to do first-time compile at runtime after it determines the hardware it’s on (also it would check if the hardware has changed since each time too). Possible but very tricky.


While Linux and macOS sound good, how useful that feature is for you. Are you willing to actively support those extra devices and test them? And second is these platforms have a different packaging scheme for example on Linux you can’t just execute a .exe file. You have to package it, which itself can be a hard challenge(if you want to automate this process) if your game is not complex and can run on other Os than Windows with little to no modification, then do it. But if you had to implement a complex feature like Unicode input handling just stick with Windows it prevents you from a lot of headaches.

It’s useful. My previous game (Oneons) was Linux/Windows, I’m happy to run a VM / dual-boot into Linux to support my game. I gave up on MacOS, even though it’s trivial to publish and package, because I can’t test it myself.

I wrote a Powershell script to call dotnet publish, chmod a+x, etc. as needed, that’s the easy part of supporting those platforms.

1 Like

Speaking of which, I was wondering if anyone might know if a VM/emulator for MacOS on Windows would provide a reliable way to test. I guess it does seem a bit sketchy if it works on the Emu but to sell something that’s technically not tested on a real Mac… Maybe it’s quite reliable?

Linky, so I can add your YT channel to the links thread

1 Like

The only way I know of to virtualize MacOS is through Linux.

This video from Chris Titus Tech → MacOS Virtual Machine Made Easy - YouTube explains how to install MacOS.

This video also from Chris → PCI Passthrough | System Configuration | Part 1 - YouTube explains the PCI passthrough to get hardware acceleration in the VMs.

1 Like

I think DesktopGL MonoGame uses SDL for input whereas DirectX uses DirectInput, apparently these means DesktopGL has much wider controller support. So I’ve heard anyway.

I use DesktopGL for MacOS, Linux and Windows and have to do pretty much nothing to get the builds to work on the respective platforms. Packaging the macOS app is a bit of a faff but once you have written a script to do it it’s easy. I even build the Linux version on MacOS which I never thought would work but it does!

I have a separate project for the Windows build but that’s only because I couldn’t figure out how to import different native APIs per platform for the Steamworks stuff. If I wasn’t using native libs I could run them all from the same project no problem.

One issue I ran into with 3.6 DesktopGL is that is does not play nice with OBS and other streaming software. Screen goes black and/or freezes in the recording. This is/was a bit of a bummer. I don’t know if this is any better with 3.8 as I haven’t specifically tested it. I considered switching to DirectX for the Windows build because of this but decided against it when I read about the superior controller support in the GL version (if this is true)!!


Here’s the one for HLSL pre-compiled shaders in monogame. :slight_smile:

1 Like

Ah, thanks. I have Linux too so that’ll work. Maybe I can run tests on there and send a copy to my friend to see if it works on his actual mac.