VideoBackends: Pass window system info from host on creation

This commit is contained in:
Stenzek 2018-10-03 23:03:22 +10:00
commit eb284b5d66
26 changed files with 148 additions and 75 deletions

View file

@ -82,8 +82,7 @@ void* GLContext::GetFuncAddress(const std::string& name)
return nullptr;
}
std::unique_ptr<GLContext> GLContext::Create(void* display_handle, void* window_handle, bool stereo,
bool core)
std::unique_ptr<GLContext> GLContext::Create(const WindowSystemInfo& wsi, bool stereo, bool core)
{
std::unique_ptr<GLContext> context;
#if defined(__APPLE__)
@ -103,7 +102,7 @@ std::unique_ptr<GLContext> GLContext::Create(void* display_handle, void* window_
#else
return nullptr;
#endif
if (!context->Initialize(display_handle, window_handle, stereo, core))
if (!context->Initialize(wsi.display_connection, wsi.render_surface, stereo, core))
return nullptr;
return context;

View file

@ -8,6 +8,7 @@
#include <string>
#include "Common/CommonTypes.h"
#include "Common/WindowSystemInfo.h"
class GLContext
{
@ -44,8 +45,8 @@ public:
virtual void* GetFuncAddress(const std::string& name);
// Creates an instance of GLInterface specific to the platform we are running on.
static std::unique_ptr<GLContext> Create(void* display_handle, void* window_handle,
bool stereo = false, bool core = true);
static std::unique_ptr<GLContext> Create(const WindowSystemInfo& wsi, bool stereo = false,
bool core = true);
protected:
virtual bool Initialize(void* display_handle, void* window_handle, bool stereo, bool core);

View file

@ -0,0 +1,35 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
enum class WindowSystemType
{
Headless,
Windows,
MacOS,
Android,
X11,
Wayland
};
struct WindowSystemInfo
{
WindowSystemInfo() = default;
WindowSystemInfo(WindowSystemType type_, void* display_connection_, void* render_surface_)
: type(type_), display_connection(display_connection_), render_surface(render_surface_)
{
}
// Window system type. Determines which GL context or Vulkan WSI is used.
WindowSystemType type = WindowSystemType::Headless;
// Connection to a display server. This is used on X11 and Wayland platforms.
void* display_connection = nullptr;
// Render surface. This is a pointer to the native window handle, which depends
// on the platform. e.g. HWND for Windows, Window for X11. If the surface is
// set to nullptr, the video backend will run in headless mode.
void* render_surface = nullptr;
};