Skip to content

Commit 4b0926a

Browse files
Copilotphilstopford
andcommitted
Fix compilation errors: Remove invalid GraphicsDevice properties and implement missing WPF handler method
Co-authored-by: philstopford <1983851+philstopford@users.noreply.github.com>
1 parent adf56f7 commit 4b0926a

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

Eto/Eto.Veldrid.Gtk/Examples/BackendSwitchingExample.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ private void ShowBackendInfo()
102102
$"Device: {device?.DeviceName}\n" +
103103
$"Vendor: {device?.VendorName}\n" +
104104
$"API Version: {device?.ApiVersion}\n" +
105-
$"Driver: {device?.DriverName} {device?.DriverInfo}\n" +
106105
$"Uniform Buffer Alignment: {device?.UniformBufferMinOffsetAlignment}\n" +
107-
$"Max Texture Size: {device?.GetPixelFormatSupport(PixelFormat.R8G8B8A8UNorm, TextureType.Texture2D, TextureUsage.Sampled)}";
106+
$"UV Origin Top Left: {device?.IsUvOriginTopLeft}\n" +
107+
$"Depth Range Zero To One: {device?.IsDepthRangeZeroToOne}";
108108

109109
MessageBox.Show(this, info, "Backend Information");
110110
}

Eto/Eto.Veldrid.Wpf/WpfVeldridSurfaceHandler.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Runtime.InteropServices;
66
using Veldrid;
7+
using Veldrid.OpenGL;
78

89
[assembly: Eto.ExportHandler(typeof(VeldridSurface), typeof(WpfVeldridSurfaceHandler))]
910

@@ -20,6 +21,51 @@ public WpfVeldridSurfaceHandler() : base(new WinFormsVeldridUserControl())
2021
Control.Loaded += Control_Loaded;
2122
}
2223

24+
public void InitializeGraphicsDevice(VeldridSurface surface, InitializeEventArgs e)
25+
{
26+
switch (surface.Backend)
27+
{
28+
case GraphicsBackend.Metal:
29+
surface.GraphicsDevice = GraphicsDevice.CreateMetal(surface.GraphicsDeviceOptions);
30+
break;
31+
case GraphicsBackend.Direct3D11:
32+
surface.GraphicsDevice = GraphicsDevice.CreateD3D11(surface.GraphicsDeviceOptions);
33+
break;
34+
case GraphicsBackend.Vulkan:
35+
surface.GraphicsDevice = GraphicsDevice.CreateVulkan(surface.GraphicsDeviceOptions);
36+
break;
37+
case GraphicsBackend.OpenGL:
38+
surface.GraphicsDevice = GraphicsDevice.CreateOpenGL(
39+
surface.GraphicsDeviceOptions,
40+
new OpenGLPlatformInfo(
41+
surface.OpenGL.OpenGLContextHandle,
42+
surface.OpenGL.GetProcAddress,
43+
surface.OpenGL.MakeCurrent,
44+
surface.OpenGL.GetCurrentContext,
45+
surface.OpenGL.ClearCurrentContext,
46+
surface.OpenGL.DeleteContext,
47+
surface.OpenGL.SwapBuffers,
48+
surface.OpenGL.SetSyncToVerticalBlank,
49+
surface.OpenGL.SetSwapchainFramebuffer,
50+
surface.OpenGL.ResizeSwapchain),
51+
(uint)e.Width,
52+
(uint)e.Height);
53+
break;
54+
default:
55+
string message;
56+
if (!Enum.IsDefined(typeof(GraphicsBackend), surface.Backend))
57+
{
58+
message = "Unrecognized backend!";
59+
}
60+
else
61+
{
62+
message = "Specified backend not supported on this platform!";
63+
}
64+
65+
throw new ArgumentException(message);
66+
}
67+
}
68+
2369
public Swapchain? CreateSwapchain()
2470
{
2571
Swapchain? swapchain;

0 commit comments

Comments
 (0)