How to determine if Direct3D or OpenGL is used for rendering?

Edit: I’ve read up a bit about the ‘switch and bait’ pattern that was used to distribute MonoGame.Portable (quite a clever use of NuGet). Anyway, it seems there is no way around of having to create a .csproj per platform.

This is a theoretical question.

Let’s say there MonoGame provided a portable version of its dll (PCL). It has both Direct3D and OpenGL compiled shader bytecode embedded into the assembly How would it determine which version of this shader code to load? How would it know whether a project consuming the assembly is targeting a Direct3D or OpenGL platform?

Currently the shader loading decision is made based on preprocessor directives, which means that when MonoGame is compiled, it will contain different code based on target platform. This obviously wouldn’t work for a portable version since the target platform would not be known at compile time.

i may be way out of the ball park, but if your using the PCL, you shouldnt have to worry because i do belive your not ment to include the PCL with the game, so when your game loads shouldnt it load the graphics based on the dll the system it is running on uses

You are correct! I wasn’t aware of what was really happening when a platform specific game was targeting MonoGame.Portable for example.

glad to have helped, hope that will help speed up your coding