Example #1
0
        private static bool CheckGraphicsPlatform(PlatformType platform, PreferredGraphicsPlatform preferredGraphicsPlatform)
        {
            switch (platform)
            {
            case PlatformType.Shared:
                return(false);

            case PlatformType.UWP:
                return(preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D11);

            case PlatformType.Windows:
                return(preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D11 ||
                       preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D12 ||
                       preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL ||
                       preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES ||
                       preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan);

            case PlatformType.Android:
                return(preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES ||
                       preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan);

            case PlatformType.iOS:
                return(preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES);

            case PlatformType.macOS:
                return(preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL);

            case PlatformType.Linux:
                return(preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL ||
                       preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan);

            default:
                throw new ArgumentOutOfRangeException(nameof(platform), platform, null);
            }
        }
Example #2
0
        public static GraphicsPlatform GetGraphicsPlatform(PlatformType platform, PreferredGraphicsPlatform preferredGraphicsPlatform)
        {
            //revert to default if platforms are not compatible
            if (!CheckGraphicsPlatform(platform, preferredGraphicsPlatform))
            {
                return(GetDefaultGraphicsPlatform(platform));
            }

            GraphicsPlatform graphicsPlatform;

            switch (preferredGraphicsPlatform)
            {
            case PreferredGraphicsPlatform.Default:
                graphicsPlatform = GetDefaultGraphicsPlatform(platform);
                break;

            case PreferredGraphicsPlatform.Direct3D11:
                graphicsPlatform = GraphicsPlatform.Direct3D11;
                break;

            case PreferredGraphicsPlatform.Direct3D12:
                graphicsPlatform = GraphicsPlatform.Direct3D12;
                break;

            case PreferredGraphicsPlatform.OpenGL:
                graphicsPlatform = GraphicsPlatform.OpenGL;
                break;

            case PreferredGraphicsPlatform.OpenGLES:
                graphicsPlatform = GraphicsPlatform.OpenGLES;
                break;

            case PreferredGraphicsPlatform.Vulkan:
                graphicsPlatform = GraphicsPlatform.Vulkan;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(graphicsPlatform);
        }
        public static GraphicsPlatform GetGraphicsPlatform(PlatformType platform, PreferredGraphicsPlatform preferredGraphicsPlatform)
        {
            //revert to default if platforms are not compatible
            if (!CheckGraphicsPlatform(platform, preferredGraphicsPlatform))
            {
                return GetDefaultGraphicsPlatform(platform);
            }

            GraphicsPlatform graphicsPlatform;
            switch (preferredGraphicsPlatform)
            {
                case PreferredGraphicsPlatform.Default:
                    graphicsPlatform = GetDefaultGraphicsPlatform(platform);
                    break;
                case PreferredGraphicsPlatform.Direct3D11:
                    graphicsPlatform = GraphicsPlatform.Direct3D11;
                    break;
                case PreferredGraphicsPlatform.Direct3D12:
                    graphicsPlatform = GraphicsPlatform.Direct3D12;
                    break;
                case PreferredGraphicsPlatform.OpenGL:
                    graphicsPlatform = GraphicsPlatform.OpenGL;
                    break;
                case PreferredGraphicsPlatform.OpenGLES:
                    graphicsPlatform = GraphicsPlatform.OpenGLES;
                    break;
                case PreferredGraphicsPlatform.Vulkan:
                    graphicsPlatform = GraphicsPlatform.Vulkan;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            return graphicsPlatform;
        }
 private static bool CheckGraphicsPlatform(PlatformType platform, PreferredGraphicsPlatform preferredGraphicsPlatform)
 {
     switch (platform)
     {
         case PlatformType.Shared:
             return false;
         case PlatformType.UWP:
             return preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D11;
         case PlatformType.Windows:
             return preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D11
                 || preferredGraphicsPlatform == PreferredGraphicsPlatform.Direct3D12
                 || preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL
                 || preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES
                 || preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan;
         case PlatformType.Android:
             return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES
                 || preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan;
         case PlatformType.iOS:
             return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGLES;
         case PlatformType.macOS:
             return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL;
         case PlatformType.Linux:
             return preferredGraphicsPlatform == PreferredGraphicsPlatform.OpenGL
                 || preferredGraphicsPlatform == PreferredGraphicsPlatform.Vulkan;
         default:
             throw new ArgumentOutOfRangeException(nameof(platform), platform, null);
     }
 }