public static void Main() { bool onWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); OpenTKWindow window; RenderContext rc; if (onWindows) { window = new DedicatedThreadWindow(); } else { window = new SameThreadWindow(); } bool preferOpenGL = Preferences.Instance.PreferOpenGL; if (!preferOpenGL && onWindows) { rc = CreateDefaultD3dRenderContext(window); } else { rc = CreateDefaultOpenGLRenderContext(window); } var options = new List <RenderDemo.RendererOption>(); var openGLOption = new RenderDemo.RendererOption("OpenGL", () => CreateDefaultOpenGLRenderContext(window)); var d3dOption = new RenderDemo.RendererOption("Direct3D", () => CreateDefaultD3dRenderContext(window)); if (onWindows) { if (rc is OpenGLRenderContext) { options.Add(openGLOption); options.Add(d3dOption); } else { options.Add(d3dOption); options.Add(openGLOption); } } else { options.Add(openGLOption); } RenderDemo.RunDemo(rc, options.ToArray()); }
public static void Main() { bool onWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); var window = new Sdl2Window("Veldrid Render Demo", 100, 100, 960, 540, SDL_WindowFlags.Resizable | SDL_WindowFlags.OpenGL, RuntimeInformation.IsOSPlatform(OSPlatform.Windows)); RenderContext rc; GraphicsBackend preferredBackend = Preferences.Instance.PreferredBackend; if (preferredBackend == GraphicsBackend.Vulkan) { rc = CreateVulkanRenderContext(window); } else if (preferredBackend == GraphicsBackend.Direct3D11 && onWindows) { rc = CreateDefaultD3dRenderContext(window); } else if (preferredBackend == GraphicsBackend.OpenGLES && onWindows) { rc = CreateDefaultOpenGLESRenderContext(window); } else { rc = CreateDefaultOpenGLRenderContext(window); } var options = new List <RenderDemo.RendererOption>(); var openGLOption = new RenderDemo.RendererOption("OpenGL", () => CreateDefaultOpenGLRenderContext(window)); var openGLESOption = new RenderDemo.RendererOption("OpenGL ES", () => CreateDefaultOpenGLESRenderContext(window)); var d3dOption = new RenderDemo.RendererOption("Direct3D", () => CreateDefaultD3dRenderContext(window)); var vulkanOption = new RenderDemo.RendererOption("Vulkan", () => CreateVulkanRenderContext(window)); if (onWindows) { if (rc is OpenGLRenderContext) { options.Add(openGLOption); options.Add(d3dOption); options.Add(openGLESOption); options.Add(vulkanOption); } else if (rc is OpenGLESRenderContext) { options.Add(openGLESOption); options.Add(openGLOption); options.Add(d3dOption); options.Add(vulkanOption); } else if (rc is VkRenderContext) { options.Add(vulkanOption); options.Add(d3dOption); options.Add(openGLOption); options.Add(openGLESOption); } else { Debug.Assert(rc is D3DRenderContext); options.Add(d3dOption); options.Add(vulkanOption); options.Add(openGLOption); options.Add(openGLESOption); } } else { if (rc is VkRenderContext) { options.Add(vulkanOption); options.Add(openGLOption); } else { options.Add(openGLOption); options.Add(vulkanOption); } } RenderDemo.RunDemo(rc, window, options.ToArray()); }