gpu: implement OpenGL / OpenGL ES adapter discovery in example
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
d8d0c85572
commit
6b0129f590
1 changed files with 11 additions and 11 deletions
|
|
@ -189,18 +189,18 @@ fn glfwWindowHintsForBackend(backend: c.WGPUBackendType) glfw.Window.Hints {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn discoverAdapter(instance: c.MachDawnNativeInstance, window: glfw.Window, typ: c.WGPUBackendType) !void {
|
fn discoverAdapter(instance: c.MachDawnNativeInstance, window: glfw.Window, typ: c.WGPUBackendType) !void {
|
||||||
if (typ == c.WGPUBackendType_OpenGL or typ == c.WGPUBackendType_OpenGLES) {
|
if (typ == c.WGPUBackendType_OpenGL) {
|
||||||
try glfw.makeContextCurrent(window);
|
try glfw.makeContextCurrent(window);
|
||||||
// auto getProc = reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress);
|
const adapter_options = c.MachDawnNativeAdapterDiscoveryOptions_OpenGL{
|
||||||
// if (type == wgpu::BackendType::OpenGL) {
|
.getProc = @ptrCast(fn ([*c]const u8) callconv(.C) ?*c_void, glfw.getProcAddress),
|
||||||
// dawn_native::opengl::AdapterDiscoveryOptions adapterOptions;
|
};
|
||||||
// adapterOptions.getProc = getProc;
|
_ = c.machDawnNativeInstance_discoverAdapters(instance, typ, &adapter_options);
|
||||||
// instance->DiscoverAdapters(&adapterOptions);
|
} else if (typ == c.WGPUBackendType_OpenGLES) {
|
||||||
// } else {
|
try glfw.makeContextCurrent(window);
|
||||||
// dawn_native::opengl::AdapterDiscoveryOptionsES adapterOptions;
|
const adapter_options = c.MachDawnNativeAdapterDiscoveryOptions_OpenGLES{
|
||||||
// adapterOptions.getProc = getProc;
|
.getProc = @ptrCast(fn ([*c]const u8) callconv(.C) ?*c_void, glfw.getProcAddress),
|
||||||
// instance->DiscoverAdapters(&adapterOptions);
|
};
|
||||||
// }
|
_ = c.machDawnNativeInstance_discoverAdapters(instance, typ, &adapter_options);
|
||||||
} else {
|
} else {
|
||||||
c.machDawnNativeInstance_discoverDefaultAdapters(instance);
|
c.machDawnNativeInstance_discoverDefaultAdapters(instance);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue