Пример #1
0
        private void InitializeGraphicsBackend(InitializeEventArgs e)
        {
            switch (Backend)
            {
            case GraphicsBackend.Metal:
                GraphicsDevice = GraphicsDevice.CreateMetal(GraphicsDeviceOptions);
                break;

            case GraphicsBackend.Direct3D11:
                GraphicsDevice = GraphicsDevice.CreateD3D11(GraphicsDeviceOptions);
                break;

            case GraphicsBackend.Vulkan:
                GraphicsDevice = GraphicsDevice.CreateVulkan(GraphicsDeviceOptions);
                break;

            case GraphicsBackend.OpenGL:
                GraphicsDevice = GraphicsDevice.CreateOpenGL(
                    GraphicsDeviceOptions,
                    new OpenGLPlatformInfo(
                        OpenGL.OpenGLContextHandle,
                        OpenGL.GetProcAddress,
                        OpenGL.MakeCurrent,
                        OpenGL.GetCurrentContext,
                        OpenGL.ClearCurrentContext,
                        OpenGL.DeleteContext,
                        OpenGL.SwapBuffers,
                        OpenGL.SetSyncToVerticalBlank,
                        OpenGL.SetSwapchainFramebuffer,
                        OpenGL.ResizeSwapchain),
                    (uint)e.Width,
                    (uint)e.Height);
                break;

            default:
                string message;
                if (!Enum.IsDefined(typeof(GraphicsBackend), Backend))
                {
                    message = "Unrecognized backend!";
                }
                else
                {
                    message = "Specified backend not supported on this platform!";
                }

                throw new ArgumentException(message);
            }

            Swapchain = Handler.CreateSwapchain();

            OnVeldridInitialized(e);
        }
Пример #2
0
 public void OnInitializeBackend(VeldridSurface s, InitializeEventArgs e) => s?.InitializeGraphicsBackend(e);
Пример #3
0
 protected virtual void OnVeldridInitialized(InitializeEventArgs e) => Properties.TriggerEvent(VeldridInitializedEvent, this, e);