mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 06:55:38 +00:00
gdk: Add support for building with OpenGL on Xbox
This commit is contained in:
parent
6969b3be3b
commit
3b3c141ff9
|
@ -209,16 +209,21 @@
|
||||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||||
#define SDL_VIDEO_DRIVER_WINDOWS 1
|
#define SDL_VIDEO_DRIVER_WINDOWS 1
|
||||||
|
|
||||||
/* #ifndef SDL_VIDEO_RENDER_D3D
|
|
||||||
#define SDL_VIDEO_RENDER_D3D 1
|
|
||||||
#endif*/
|
|
||||||
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
|
|
||||||
#define SDL_VIDEO_RENDER_D3D11 1
|
|
||||||
#endif
|
|
||||||
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
|
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
|
||||||
#define SDL_VIDEO_RENDER_D3D12 1
|
#define SDL_VIDEO_RENDER_D3D12 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Enable OpenGL support */
|
||||||
|
#ifndef SDL_VIDEO_OPENGL
|
||||||
|
#define SDL_VIDEO_OPENGL 1
|
||||||
|
#endif
|
||||||
|
#ifndef SDL_VIDEO_OPENGL_WGL
|
||||||
|
#define SDL_VIDEO_OPENGL_WGL 1
|
||||||
|
#endif
|
||||||
|
#ifndef SDL_VIDEO_RENDER_OGL
|
||||||
|
#define SDL_VIDEO_RENDER_OGL 1
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Enable system power support */
|
/* Enable system power support */
|
||||||
/*#define SDL_POWER_WINDOWS 1*/
|
/*#define SDL_POWER_WINDOWS 1*/
|
||||||
#define SDL_POWER_HARDWIRED 1
|
#define SDL_POWER_HARDWIRED 1
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*/
|
*/
|
||||||
#include "../../SDL_internal.h"
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||||
|
|
||||||
#include "SDL_loadso.h"
|
#include "SDL_loadso.h"
|
||||||
#include "SDL_windowsvideo.h"
|
#include "SDL_windowsvideo.h"
|
||||||
|
@ -97,6 +97,16 @@ typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC,
|
||||||
const int
|
const int
|
||||||
*attribList);
|
*attribList);
|
||||||
|
|
||||||
|
#if __XBOXONE__ || __XBOXSERIES__
|
||||||
|
#define GetDC(hwnd) (HDC) hwnd
|
||||||
|
#define ReleaseDC(hwnd, hdc) 1
|
||||||
|
#define SwapBuffers _this->gl_data->wglSwapBuffers
|
||||||
|
#define DescribePixelFormat _this->gl_data->wglDescribePixelFormat
|
||||||
|
#define ChoosePixelFormat _this->gl_data->wglChoosePixelFormat
|
||||||
|
#define GetPixelFormat _this->gl_data->wglGetPixelFormat
|
||||||
|
#define SetPixelFormat _this->gl_data->wglSetPixelFormat
|
||||||
|
#endif
|
||||||
|
|
||||||
int WIN_GL_LoadLibrary(_THIS, const char *path)
|
int WIN_GL_LoadLibrary(_THIS, const char *path)
|
||||||
{
|
{
|
||||||
void *handle;
|
void *handle;
|
||||||
|
@ -135,10 +145,31 @@ int WIN_GL_LoadLibrary(_THIS, const char *path)
|
||||||
SDL_LoadFunction(handle, "wglShareLists");
|
SDL_LoadFunction(handle, "wglShareLists");
|
||||||
/* *INDENT-ON* */ /* clang-format on */
|
/* *INDENT-ON* */ /* clang-format on */
|
||||||
|
|
||||||
|
#if __XBOXONE__ || __XBOXSERIES__
|
||||||
|
_this->gl_data->wglSwapBuffers = (BOOL(WINAPI *)(HDC))
|
||||||
|
SDL_LoadFunction(handle, "wglSwapBuffers");
|
||||||
|
_this->gl_data->wglDescribePixelFormat = (int(WINAPI *)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR))
|
||||||
|
SDL_LoadFunction(handle, "wglDescribePixelFormat");
|
||||||
|
_this->gl_data->wglChoosePixelFormat = (int(WINAPI *)(HDC, const PIXELFORMATDESCRIPTOR *))
|
||||||
|
SDL_LoadFunction(handle, "wglChoosePixelFormat");
|
||||||
|
_this->gl_data->wglSetPixelFormat = (BOOL(WINAPI *)(HDC, int, const PIXELFORMATDESCRIPTOR *))
|
||||||
|
SDL_LoadFunction(handle, "wglSetPixelFormat");
|
||||||
|
_this->gl_data->wglGetPixelFormat = (int(WINAPI *)(HDC hdc))
|
||||||
|
SDL_LoadFunction(handle, "wglGetPixelFormat");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!_this->gl_data->wglGetProcAddress ||
|
if (!_this->gl_data->wglGetProcAddress ||
|
||||||
!_this->gl_data->wglCreateContext ||
|
!_this->gl_data->wglCreateContext ||
|
||||||
!_this->gl_data->wglDeleteContext ||
|
!_this->gl_data->wglDeleteContext ||
|
||||||
!_this->gl_data->wglMakeCurrent) {
|
!_this->gl_data->wglMakeCurrent
|
||||||
|
#if __XBOXONE__ || __XBOXSERIES__
|
||||||
|
|| !_this->gl_data->wglSwapBuffers ||
|
||||||
|
!_this->gl_data->wglDescribePixelFormat ||
|
||||||
|
!_this->gl_data->wglChoosePixelFormat ||
|
||||||
|
!_this->gl_data->wglGetPixelFormat ||
|
||||||
|
!_this->gl_data->wglSetPixelFormat
|
||||||
|
#endif
|
||||||
|
) {
|
||||||
return SDL_SetError("Could not retrieve OpenGL functions");
|
return SDL_SetError("Could not retrieve OpenGL functions");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,38 @@
|
||||||
|
|
||||||
#if SDL_VIDEO_OPENGL_WGL
|
#if SDL_VIDEO_OPENGL_WGL
|
||||||
|
|
||||||
|
#if __XBOXONE__ || __XBOXSERIES__
|
||||||
|
typedef struct tagPIXELFORMATDESCRIPTOR
|
||||||
|
{
|
||||||
|
WORD nSize;
|
||||||
|
WORD nVersion;
|
||||||
|
DWORD dwFlags;
|
||||||
|
BYTE iPixelType;
|
||||||
|
BYTE cColorBits;
|
||||||
|
BYTE cRedBits;
|
||||||
|
BYTE cRedShift;
|
||||||
|
BYTE cGreenBits;
|
||||||
|
BYTE cGreenShift;
|
||||||
|
BYTE cBlueBits;
|
||||||
|
BYTE cBlueShift;
|
||||||
|
BYTE cAlphaBits;
|
||||||
|
BYTE cAlphaShift;
|
||||||
|
BYTE cAccumBits;
|
||||||
|
BYTE cAccumRedBits;
|
||||||
|
BYTE cAccumGreenBits;
|
||||||
|
BYTE cAccumBlueBits;
|
||||||
|
BYTE cAccumAlphaBits;
|
||||||
|
BYTE cDepthBits;
|
||||||
|
BYTE cStencilBits;
|
||||||
|
BYTE cAuxBuffers;
|
||||||
|
BYTE iLayerType;
|
||||||
|
BYTE bReserved;
|
||||||
|
DWORD dwLayerMask;
|
||||||
|
DWORD dwVisibleMask;
|
||||||
|
DWORD dwDamageMask;
|
||||||
|
} PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct SDL_GLDriverData
|
struct SDL_GLDriverData
|
||||||
{
|
{
|
||||||
SDL_bool HAS_WGL_ARB_pixel_format;
|
SDL_bool HAS_WGL_ARB_pixel_format;
|
||||||
|
@ -53,6 +85,19 @@ struct SDL_GLDriverData
|
||||||
BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
|
||||||
BOOL (WINAPI *wglSwapIntervalEXT)(int interval);
|
BOOL (WINAPI *wglSwapIntervalEXT)(int interval);
|
||||||
int (WINAPI *wglGetSwapIntervalEXT)(void);
|
int (WINAPI *wglGetSwapIntervalEXT)(void);
|
||||||
|
#if __XBOXONE__ || __XBOXSERIES__
|
||||||
|
BOOL (WINAPI *wglSwapBuffers)(HDC hdc);
|
||||||
|
int (WINAPI *wglDescribePixelFormat)(HDC hdc,
|
||||||
|
int iPixelFormat,
|
||||||
|
UINT nBytes,
|
||||||
|
LPPIXELFORMATDESCRIPTOR ppfd);
|
||||||
|
int (WINAPI *wglChoosePixelFormat)(HDC hdc,
|
||||||
|
const PIXELFORMATDESCRIPTOR *ppfd);
|
||||||
|
BOOL (WINAPI *wglSetPixelFormat)(HDC hdc,
|
||||||
|
int format,
|
||||||
|
const PIXELFORMATDESCRIPTOR *ppfd);
|
||||||
|
int (WINAPI *wglGetPixelFormat)(HDC hdc);
|
||||||
|
#endif
|
||||||
/* *INDENT-ON* */ /* clang-format on */
|
/* *INDENT-ON* */ /* clang-format on */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@
|
||||||
|
|
||||||
#include "SDL_windowsclipboard.h"
|
#include "SDL_windowsclipboard.h"
|
||||||
#include "SDL_windowsevents.h"
|
#include "SDL_windowsevents.h"
|
||||||
|
#include "SDL_windowsopengl.h"
|
||||||
|
|
||||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
||||||
#include "SDL_windowskeyboard.h"
|
#include "SDL_windowskeyboard.h"
|
||||||
#include "SDL_windowsmodes.h"
|
#include "SDL_windowsmodes.h"
|
||||||
#include "SDL_windowsmouse.h"
|
#include "SDL_windowsmouse.h"
|
||||||
#include "SDL_windowsopengl.h"
|
|
||||||
#include "SDL_windowsopengles.h"
|
#include "SDL_windowsopengles.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,9 @@ static int SetupWindowData(_THIS, SDL_Window *window, HWND hwnd, HWND parent, SD
|
||||||
data->window = window;
|
data->window = window;
|
||||||
data->hwnd = hwnd;
|
data->hwnd = hwnd;
|
||||||
data->parent = parent;
|
data->parent = parent;
|
||||||
#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
|
#if defined(__XBOXONE__) || defined(__XBOXSERIES__)
|
||||||
|
data->hdc = (HDC) data->hwnd;
|
||||||
|
#else
|
||||||
data->hdc = GetDC(hwnd);
|
data->hdc = GetDC(hwnd);
|
||||||
#endif
|
#endif
|
||||||
data->hinstance = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
data->hinstance = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE);
|
||||||
|
|
Loading…
Reference in a new issue