User Tools

Site Tools


code_snippets:platform_info

Table of Contents

Platform Info

This code snippet is simple and can be placed practically anywhere, it prints out the platform such as Windows or Linux or Mac, and the graphics backend such as DirectX or OpenGL.

In this example you can see it was placed directly inside the Game1() constructor.

I added a tab space to make it easier to discover in the Debug Console, along with lines surrounding it.

Code:

public Game1()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible = true;

            System.Diagnostics.Debug.WriteLine("\n===================\n");
            // Platform Name? Windows or Linux or Mac
            var whatPlatform = PlatformInfo.MonoGamePlatform;
            // print it to the debug console
            System.Diagnostics.Debug.WriteLine("\t Platform: " + whatPlatform);
            // Graphics Backend DirectX or OpengGL?
            var whatGraphicsEngine = PlatformInfo.GraphicsBackend;
            // print it to the debug console
            System.Diagnostics.Debug.WriteLine("\t Graphics Backend: " + whatGraphicsEngine);
            System.Diagnostics.Debug.WriteLine("\n===================\n");
        }

Output Example:

// DebugConsole Output
===================

	 Platform: Windows
	 Graphics Backend: DirectX

===================

code_snippets/platform_info.txt · Last modified: 2024/07/20 02:31 by mrvalentine