21#include "../../SDL_internal.h"
23#if SDL_VIDEO_DRIVER_WINDOWS
30#include "../SDL_sysvideo.h"
31#include "../SDL_pixels_c.h"
39static int WIN_VideoInit(
_THIS);
40static void WIN_VideoQuit(
_THIS);
47UpdateWindowsEnableMessageLoop(
void *userdata,
const char *
name,
const char *oldValue,
const char *newValue)
49 if (newValue && *newValue ==
'0') {
57UpdateWindowFrameUsableWhileCursorHidden(
void *userdata,
const char *
name,
const char *oldValue,
const char *newValue)
59 if (newValue && *newValue ==
'0') {
66static void WIN_SuspendScreenSaver(
_THIS)
69 SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
71 SetThreadExecutionState(ES_CONTINUOUS);
93 if (
data->shcoreDLL) {
102WIN_CreateDevice(
int devindex)
133 if (
data->shcoreDLL) {
140 device->VideoInit = WIN_VideoInit;
141 device->VideoQuit = WIN_VideoQuit;
148 device->SuspendScreenSaver = WIN_SuspendScreenSaver;
183#if SDL_VIDEO_OPENGL_WGL
184 device->GL_LoadLibrary = WIN_GL_LoadLibrary;
185 device->GL_GetProcAddress = WIN_GL_GetProcAddress;
186 device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
187 device->GL_CreateContext = WIN_GL_CreateContext;
188 device->GL_MakeCurrent = WIN_GL_MakeCurrent;
189 device->GL_SetSwapInterval = WIN_GL_SetSwapInterval;
190 device->GL_GetSwapInterval = WIN_GL_GetSwapInterval;
191 device->GL_SwapWindow = WIN_GL_SwapWindow;
192 device->GL_DeleteContext = WIN_GL_DeleteContext;
193#elif SDL_VIDEO_OPENGL_EGL
195 device->GL_LoadLibrary = WIN_GLES_LoadLibrary;
196 device->GL_GetProcAddress = WIN_GLES_GetProcAddress;
197 device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary;
198 device->GL_CreateContext = WIN_GLES_CreateContext;
199 device->GL_MakeCurrent = WIN_GLES_MakeCurrent;
200 device->GL_SetSwapInterval = WIN_GLES_SetSwapInterval;
201 device->GL_GetSwapInterval = WIN_GLES_GetSwapInterval;
202 device->GL_SwapWindow = WIN_GLES_SwapWindow;
203 device->GL_DeleteContext = WIN_GLES_DeleteContext;
206 device->Vulkan_LoadLibrary = WIN_Vulkan_LoadLibrary;
207 device->Vulkan_UnloadLibrary = WIN_Vulkan_UnloadLibrary;
208 device->Vulkan_GetInstanceExtensions = WIN_Vulkan_GetInstanceExtensions;
209 device->Vulkan_CreateSurface = WIN_Vulkan_CreateSurface;
220 device->free = WIN_DeleteDevice;
227 "windows",
"SDL Windows video driver", WIN_Available, WIN_CreateDevice
255#define D3D_DEBUG_INFO
263 typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t) (
UINT SDKVersion);
264 Direct3DCreate9_t Direct3DCreate9Func;
267 typedef HRESULT (WINAPI *Direct3DCreate9Ex_t)(
UINT SDKVersion, IDirect3D9Ex **ppD3D);
268 Direct3DCreate9Ex_t Direct3DCreate9ExFunc;
270 Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)
SDL_LoadFunction(*pD3DDLL,
"Direct3DCreate9Ex");
271 if (Direct3DCreate9ExFunc) {
272 IDirect3D9Ex *pDirect3D9ExInterface;
273 HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface);
275 const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } };
276 hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (
void**)pDirect3D9Interface);
277 IDirect3D9Ex_Release(pDirect3D9ExInterface);
285 Direct3DCreate9Func = (Direct3DCreate9_t)
SDL_LoadFunction(*pD3DDLL,
"Direct3DCreate9");
286 if (Direct3DCreate9Func) {
287 *pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION);
288 if (*pDirect3D9Interface) {
296 *pDirect3D9Interface =
NULL;
308 return D3DADAPTER_DEFAULT;
311 int adapterIndex = D3DADAPTER_DEFAULT;
318 unsigned int count = IDirect3D9_GetAdapterCount(pD3D);
321 D3DADAPTER_IDENTIFIER9
id;
322 IDirect3D9_GetAdapterIdentifier(pD3D,
i, 0, &
id);
324 if (
SDL_strcmp(
id.DeviceName, displayName) == 0) {
333 IDirect3D9_Release(pD3D);
346DXGI_LoadDLL(
void **pDXGIDLL, IDXGIFactory **pDXGIFactory)
350 HRESULT (WINAPI *CreateDXGI)(REFIID riid,
void **ppFactory);
354 "CreateDXGIFactory");
356 GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}};
357 if (!
SUCCEEDED(CreateDXGI(&dxgiGUID, (
void**)pDXGIFactory))) {
358 *pDXGIFactory =
NULL;
361 if (!*pDXGIFactory) {
369 *pDXGIFactory =
NULL;
380 if (adapterIndex) *adapterIndex = -1;
381 if (outputIndex) *outputIndex = -1;
382 SDL_SetError(
"SDL was compiled without DXGI support due to missing dxgi.h header");
388 int nAdapter, nOutput;
389 IDXGIFactory *pDXGIFactory;
390 IDXGIAdapter *pDXGIAdapter;
391 IDXGIOutput* pDXGIOutput;
411 if (!DXGI_LoadDLL(&pDXGIDLL, &pDXGIFactory)) {
418 while (*adapterIndex == -1 &&
SUCCEEDED(IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter))) {
420 while (*adapterIndex == -1 &&
SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) {
421 DXGI_OUTPUT_DESC outputDesc;
422 if (
SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
424 if (
SDL_strcmp(outputName, displayName) == 0) {
425 *adapterIndex = nAdapter;
426 *outputIndex = nOutput;
430 IDXGIOutput_Release(pDXGIOutput);
433 IDXGIAdapter_Release(pDXGIAdapter);
439 IDXGIFactory_Release(pDXGIFactory);
442 if (*adapterIndex == -1) {
#define SDL_AddHintCallback
#define SDL_OutOfMemory()
#define SDL_InvalidParamError(param)
#define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP
A variable controlling whether the windows message loop is processed by SDL.
#define SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN
A variable controlling whether the window frame and title bar are interactive when the cursor is hidd...
void * SDL_LoadFunction(void *handle, const char *name)
int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
void SDL_UnregisterApp(void)
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLuint const GLchar * name
int SDL_Direct3D9GetAdapterIndex(int displayIndex)
Returns the D3D9 adapter index that matches the specified display index.
SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
Returns the DXGI Adapter and Output indices for the specified display index.
void * SDL_GetDisplayDriverData(int displayIndex)
VideoBootStrap WINDOWS_bootstrap
static SDL_VideoDevice * _this
#define WIN_StringToUTF8(S)
int WIN_SetClipboardText(_THIS, const char *text)
char * WIN_GetClipboardText(_THIS)
SDL_bool WIN_HasClipboardText(_THIS)
void WIN_PumpEvents(_THIS)
void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
void WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
void WIN_InitKeyboard(_THIS)
void WIN_StopTextInput(_THIS)
void WIN_StartTextInput(_THIS)
void WIN_QuitKeyboard(_THIS)
int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
void WIN_QuitModes(_THIS)
int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
void WIN_InitMouse(_THIS)
void WIN_QuitMouse(_THIS)
int Win32_ResizeWindowShape(SDL_Window *window)
int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
SDL_WindowShaper * Win32_CreateShaper(SDL_Window *window)
SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
struct IDirect3D9 IDirect3D9
SDL_bool g_WindowFrameUsableWhileCursorHidden
SDL_bool g_WindowsEnableMessageLoop
int WIN_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
void WIN_ShowWindow(_THIS, SDL_Window *window)
void WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
int WIN_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
void WIN_RaiseWindow(_THIS, SDL_Window *window)
int WIN_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void WIN_SetWindowPosition(_THIS, SDL_Window *window)
void WIN_HideWindow(_THIS, SDL_Window *window)
void WIN_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
void WIN_DestroyWindow(_THIS, SDL_Window *window)
int WIN_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
void WIN_MinimizeWindow(_THIS, SDL_Window *window)
void WIN_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void WIN_SetWindowTitle(_THIS, SDL_Window *window)
void WIN_MaximizeWindow(_THIS, SDL_Window *window)
void WIN_AcceptDragAndDrop(SDL_Window *window, SDL_bool accept)
void WIN_RestoreWindow(_THIS, SDL_Window *window)
void WIN_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
void WIN_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
void WIN_OnWindowEnter(_THIS, SDL_Window *window)
int WIN_CreateWindow(_THIS, SDL_Window *window)
SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
int WIN_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
void WIN_SetWindowSize(_THIS, SDL_Window *window)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
static SDL_AudioDeviceID device
HRESULT(WINAPI *GetDpiForMonitor)(HMONITOR hmonitor
BOOL(WINAPI *CloseTouchInputHandle)(HTOUCHINPUT)
SDL_bool suspend_screensaver