mirror of
https://github.com/libretro/RetroArch
synced 2025-04-16 17:43:02 +00:00
(WGL) Make context driver more modular
This commit is contained in:
parent
822d66f401
commit
0433d3ca6e
@ -36,13 +36,17 @@
|
|||||||
#include "../../runloop.h"
|
#include "../../runloop.h"
|
||||||
#include "../video_context_driver.h"
|
#include "../video_context_driver.h"
|
||||||
|
|
||||||
#include "../common/gl_common.h"
|
|
||||||
#include "../common/win32_common.h"
|
#include "../common/win32_common.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENGL
|
||||||
|
#include "../common/gl_common.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_VULKAN
|
#ifdef HAVE_VULKAN
|
||||||
#include "../common/vulkan_common.h"
|
#include "../common/vulkan_common.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_OPENGL) || defined(HAVE_VULKAN)
|
||||||
#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB
|
#ifndef WGL_CONTEXT_MAJOR_VERSION_ARB
|
||||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||||
#endif
|
#endif
|
||||||
@ -66,8 +70,12 @@
|
|||||||
#ifndef WGL_CONTEXT_DEBUG_BIT_ARB
|
#ifndef WGL_CONTEXT_DEBUG_BIT_ARB
|
||||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
|
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_OPENGL)
|
||||||
typedef HGLRC (APIENTRY *wglCreateContextAttribsProc)(HDC, HGLRC, const int*);
|
typedef HGLRC (APIENTRY *wglCreateContextAttribsProc)(HDC, HGLRC, const int*);
|
||||||
|
static wglCreateContextAttribsProc pcreate_context;
|
||||||
|
#endif
|
||||||
static BOOL (APIENTRY *p_swap_interval)(int);
|
static BOOL (APIENTRY *p_swap_interval)(int);
|
||||||
|
|
||||||
static bool g_use_hw_ctx;
|
static bool g_use_hw_ctx;
|
||||||
@ -88,8 +96,6 @@ static unsigned g_interval;
|
|||||||
|
|
||||||
static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */
|
static dylib_t dll_handle = NULL; /* Handle to OpenGL32.dll */
|
||||||
|
|
||||||
static wglCreateContextAttribsProc pcreate_context;
|
|
||||||
|
|
||||||
static void setup_pixel_format(HDC hdc)
|
static void setup_pixel_format(HDC hdc)
|
||||||
{
|
{
|
||||||
PIXELFORMATDESCRIPTOR pfd = {0};
|
PIXELFORMATDESCRIPTOR pfd = {0};
|
||||||
@ -105,6 +111,7 @@ static void setup_pixel_format(HDC hdc)
|
|||||||
SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd);
|
SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(HAVE_OPENGL)
|
||||||
static void create_gl_context(HWND hwnd, bool *quit)
|
static void create_gl_context(HWND hwnd, bool *quit)
|
||||||
{
|
{
|
||||||
bool core_context;
|
bool core_context;
|
||||||
@ -228,13 +235,16 @@ static void create_gl_context(HWND hwnd, bool *quit)
|
|||||||
RARCH_ERR("[WGL]: wglCreateContextAttribsARB not supported.\n");
|
RARCH_ERR("[WGL]: wglCreateContextAttribsARB not supported.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void create_graphics_context(HWND hwnd, bool *quit)
|
void create_graphics_context(HWND hwnd, bool *quit)
|
||||||
{
|
{
|
||||||
switch (g_api)
|
switch (g_api)
|
||||||
{
|
{
|
||||||
case GFX_CTX_OPENGL_API:
|
case GFX_CTX_OPENGL_API:
|
||||||
|
#if defined(HAVE_OPENGL)
|
||||||
create_gl_context(hwnd, quit);
|
create_gl_context(hwnd, quit);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GFX_CTX_VULKAN_API:
|
case GFX_CTX_VULKAN_API:
|
||||||
@ -250,9 +260,9 @@ void create_graphics_context(HWND hwnd, bool *quit)
|
|||||||
width, height, g_interval))
|
width, height, g_interval))
|
||||||
*quit = true;
|
*quit = true;
|
||||||
g_inited = true;
|
g_inited = true;
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case GFX_CTX_NONE:
|
case GFX_CTX_NONE:
|
||||||
default:
|
default:
|
||||||
@ -328,8 +338,8 @@ static void gfx_ctx_wgl_swap_buffers(void *data)
|
|||||||
case GFX_CTX_OPENGL_API:
|
case GFX_CTX_OPENGL_API:
|
||||||
#ifdef HAVE_OPENGL
|
#ifdef HAVE_OPENGL
|
||||||
SwapBuffers(g_hdc);
|
SwapBuffers(g_hdc);
|
||||||
break;
|
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
case GFX_CTX_VULKAN_API:
|
case GFX_CTX_VULKAN_API:
|
||||||
#ifdef HAVE_VULKAN
|
#ifdef HAVE_VULKAN
|
||||||
@ -576,9 +586,11 @@ static bool gfx_ctx_wgl_has_windowed(void *data)
|
|||||||
|
|
||||||
static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
static gfx_ctx_proc_t gfx_ctx_wgl_get_proc_address(const char *symbol)
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_OPENGL) || defined(HAVE_VULKAN)
|
||||||
void *func = (void *)wglGetProcAddress(symbol);
|
void *func = (void *)wglGetProcAddress(symbol);
|
||||||
if (func)
|
if (func)
|
||||||
return (gfx_ctx_proc_t)wglGetProcAddress(symbol);
|
return (gfx_ctx_proc_t)wglGetProcAddress(symbol);
|
||||||
|
#endif
|
||||||
return (gfx_ctx_proc_t)GetProcAddress((HINSTANCE)dll_handle, symbol);
|
return (gfx_ctx_proc_t)GetProcAddress((HINSTANCE)dll_handle, symbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -597,7 +609,16 @@ static bool gfx_ctx_wgl_bind_api(void *data,
|
|||||||
g_minor = minor;
|
g_minor = minor;
|
||||||
g_api = api;
|
g_api = api;
|
||||||
|
|
||||||
return api == GFX_CTX_OPENGL_API || api == GFX_CTX_VULKAN_API;
|
#if defined(HAVE_OPENGL)
|
||||||
|
if (api == GFX_CTX_OPENGL_API)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_VULKAN)
|
||||||
|
if (api == GFX_CTX_VULKAN_API)
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gfx_ctx_wgl_show_mouse(void *data, bool state)
|
static void gfx_ctx_wgl_show_mouse(void *data, bool state)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user