21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_WINDOWS 30 #include "../SDL_sysvideo.h" 31 #include "../SDL_pixels_c.h" 39 static int WIN_VideoInit(
_THIS);
40 static void WIN_VideoQuit(
_THIS);
47 UpdateWindowsEnableMessageLoop(
void *userdata,
const char *
name,
const char *oldValue,
const char *newValue)
49 if (newValue && *newValue ==
'0') {
57 UpdateWindowFrameUsableWhileCursorHidden(
void *userdata,
const char *name,
const char *oldValue,
const char *newValue)
59 if (newValue && *newValue ==
'0') {
93 WIN_CreateDevice(
int devindex)
172 #if SDL_VIDEO_OPENGL_WGL 182 #elif SDL_VIDEO_OPENGL_EGL 209 device->
free = WIN_DeleteDevice;
216 "windows",
"SDL Windows video driver", WIN_Available, WIN_CreateDevice
244 #define D3D_DEBUG_INFO 252 typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t) (
UINT SDKVersion);
253 Direct3DCreate9_t Direct3DCreate9Func;
256 typedef HRESULT (WINAPI *Direct3DCreate9Ex_t)(
UINT SDKVersion, IDirect3D9Ex **ppD3D);
257 Direct3DCreate9Ex_t Direct3DCreate9ExFunc;
259 Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)
SDL_LoadFunction(*pD3DDLL,
"Direct3DCreate9Ex");
260 if (Direct3DCreate9ExFunc) {
261 IDirect3D9Ex *pDirect3D9ExInterface;
262 HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface);
264 const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } };
265 hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (
void**)pDirect3D9Interface);
266 IDirect3D9Ex_Release(pDirect3D9ExInterface);
274 Direct3DCreate9Func = (Direct3DCreate9_t)
SDL_LoadFunction(*pD3DDLL,
"Direct3DCreate9");
275 if (Direct3DCreate9Func) {
276 *pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION);
277 if (*pDirect3D9Interface) {
285 *pDirect3D9Interface =
NULL;
297 return D3DADAPTER_DEFAULT;
300 int adapterIndex = D3DADAPTER_DEFAULT;
307 unsigned int count = IDirect3D9_GetAdapterCount(pD3D);
309 for (i=0; i<
count; i++) {
310 D3DADAPTER_IDENTIFIER9
id;
311 IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &
id);
313 if (
SDL_strcmp(
id.DeviceName, displayName) == 0) {
322 IDirect3D9_Release(pD3D);
335 DXGI_LoadDLL(
void **pDXGIDLL, IDXGIFactory **pDXGIFactory)
339 HRESULT (WINAPI *CreateDXGI)(REFIID riid,
void **ppFactory);
343 "CreateDXGIFactory");
345 GUID dxgiGUID = {0x7b7166ec,0x21c7,0x44ae,{0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}};
346 if (!
SUCCEEDED(CreateDXGI(&dxgiGUID, (
void**)pDXGIFactory))) {
347 *pDXGIFactory =
NULL;
350 if (!*pDXGIFactory) {
358 *pDXGIFactory =
NULL;
369 if (adapterIndex) *adapterIndex = -1;
370 if (outputIndex) *outputIndex = -1;
371 SDL_SetError(
"SDL was compiled without DXGI support due to missing dxgi.h header");
377 int nAdapter, nOutput;
378 IDXGIFactory *pDXGIFactory;
379 IDXGIAdapter *pDXGIAdapter;
380 IDXGIOutput* pDXGIOutput;
400 if (!DXGI_LoadDLL(&pDXGIDLL, &pDXGIFactory)) {
407 while (*adapterIndex == -1 &&
SUCCEEDED(IDXGIFactory_EnumAdapters(pDXGIFactory, nAdapter, &pDXGIAdapter))) {
409 while (*adapterIndex == -1 &&
SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) {
410 DXGI_OUTPUT_DESC outputDesc;
411 if (
SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) {
413 if (
SDL_strcmp(outputName, displayName) == 0) {
414 *adapterIndex = nAdapter;
415 *outputIndex = nOutput;
419 IDXGIOutput_Release(pDXGIOutput);
422 IDXGIAdapter_Release(pDXGIAdapter);
428 IDXGIFactory_Release(pDXGIFactory);
431 if (*adapterIndex == -1) {
int(* Vulkan_LoadLibrary)(_THIS, const char *path)
struct IDirect3D9 IDirect3D9
int(* GetDisplayDPI)(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
SDL_bool g_WindowFrameUsableWhileCursorHidden
void(* RestoreWindow)(_THIS, SDL_Window *window)
void WIN_SetWindowSize(_THIS, SDL_Window *window)
int Win32_ResizeWindowShape(SDL_Window *window)
SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputIndex)
Returns the DXGI Adapter and Output indices for the specified display index.
int(* SetWindowHitTest)(SDL_Window *window, SDL_bool enabled)
void WIN_QuitModes(_THIS)
void WIN_RaiseWindow(_THIS, SDL_Window *window)
GLuint GLuint GLsizei count
int WIN_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
void WIN_DestroyWindow(_THIS, SDL_Window *window)
char * WIN_GetClipboardText(_THIS)
SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
int(* GL_SetSwapInterval)(_THIS, int interval)
void WIN_MaximizeWindow(_THIS, SDL_Window *window)
void(* ShowWindow)(_THIS, SDL_Window *window)
void(* StartTextInput)(_THIS)
void(* SetWindowSize)(_THIS, SDL_Window *window)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
int(* GetWindowBordersSize)(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
SDL_WindowShaper * Win32_CreateShaper(SDL_Window *window)
#define SDL_InvalidParamError(param)
SDL_bool g_WindowsEnableMessageLoop
void WIN_OnWindowEnter(_THIS, SDL_Window *window)
int(* GL_LoadLibrary)(_THIS, const char *path)
GLuint const GLchar * name
int(* SetDisplayMode)(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
void WIN_SetWindowPosition(_THIS, SDL_Window *window)
void * SDL_GetDisplayDriverData(int displayIndex)
int WIN_SetWindowHitTest(SDL_Window *window, SDL_bool enabled)
void(* SetWindowBordered)(_THIS, SDL_Window *window, SDL_bool bordered)
int WIN_CreateWindow(_THIS, SDL_Window *window)
int SDL_Direct3D9GetAdapterIndex(int displayIndex)
Returns the D3D9 adapter index that matches the specified display index.
static SDL_VideoDevice * _this
void WIN_InitMouse(_THIS)
int WIN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
void(* HideWindow)(_THIS, SDL_Window *window)
static SDL_AudioDeviceID device
void SDL_UnregisterApp(void)
void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
void(* RaiseWindow)(_THIS, SDL_Window *window)
int(* SetWindowShape)(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
void(* SetTextInputRect)(_THIS, SDL_Rect *rect)
void WIN_StartTextInput(_THIS)
SDL_bool(* Vulkan_GetInstanceExtensions)(_THIS, SDL_Window *window, unsigned *count, const char **names)
int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
SDL_bool(* GetWindowWMInfo)(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_GLContext(* GL_CreateContext)(_THIS, SDL_Window *window)
void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
void WIN_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
#define SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP
A variable controlling whether the windows message loop is processed by SDL.
VideoBootStrap WINDOWS_bootstrap
SDL_bool(* Vulkan_CreateSurface)(_THIS, SDL_Window *window, VkInstance instance, VkSurfaceKHR *surface)
void WIN_MinimizeWindow(_THIS, SDL_Window *window)
int(* GL_MakeCurrent)(_THIS, SDL_Window *window, SDL_GLContext context)
int WIN_SetWindowOpacity(_THIS, SDL_Window *window, float opacity)
HRESULT(WINAPI *GetDpiForMonitor)(HMONITOR hmonitor
void WIN_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
void(* Vulkan_UnloadLibrary)(_THIS)
int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
void WIN_ShowWindow(_THIS, SDL_Window *window)
int(* GetDisplayBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
void(* DestroyWindow)(_THIS, SDL_Window *window)
void WIN_StopTextInput(_THIS)
#define WIN_StringToUTF8(S)
void(* StopTextInput)(_THIS)
void(* SetWindowIcon)(_THIS, SDL_Window *window, SDL_Surface *icon)
void WIN_InitKeyboard(_THIS)
SDL_bool WIN_HasClipboardText(_THIS)
#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 WIN_QuitKeyboard(_THIS)
BOOL(WINAPI *CloseTouchInputHandle)(HTOUCHINPUT)
void WIN_RestoreWindow(_THIS, SDL_Window *window)
void WIN_QuitMouse(_THIS)
SDL_bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface)
void(* DestroyWindowFramebuffer)(_THIS, SDL_Window *window)
void(* GL_UnloadLibrary)(_THIS)
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)
void(* GetDisplayModes)(_THIS, SDL_VideoDisplay *display)
int WIN_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
int(* CreateSDLWindow)(_THIS, SDL_Window *window)
#define SDL_OutOfMemory()
void WIN_SetWindowTitle(_THIS, SDL_Window *window)
void WIN_SetTextInputRect(_THIS, SDL_Rect *rect)
SDL_WindowShaper *(* CreateShaper)(SDL_Window *window)
void WIN_PumpEvents(_THIS)
int(* ResizeWindowShape)(SDL_Window *window)
int(* SetWindowOpacity)(_THIS, SDL_Window *window, float opacity)
void WIN_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode)
void(* SetWindowPosition)(_THIS, SDL_Window *window)
int(* GL_SwapWindow)(_THIS, SDL_Window *window)
int(* GetWindowGammaRamp)(_THIS, SDL_Window *window, Uint16 *ramp)
void(* MinimizeWindow)(_THIS, SDL_Window *window)
#define SDL_AddHintCallback
void WIN_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
SDL_bool(* HasClipboardText)(_THIS)
SDL_ShapeDriver shape_driver
int(* CreateSDLWindowFrom)(_THIS, SDL_Window *window, const void *data)
int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, float *hdpi, float *vdpi)
void(* SetWindowFullscreen)(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
void WIN_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
int(* UpdateWindowFramebuffer)(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
void * SDL_LoadFunction(void *handle, const char *name)
void(* GL_DeleteContext)(_THIS, SDL_GLContext context)
char *(* GetClipboardText)(_THIS)
int WIN_GetWindowBordersSize(_THIS, SDL_Window *window, int *top, int *left, int *bottom, int *right)
int WIN_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void(* SetWindowTitle)(_THIS, SDL_Window *window)
void(* SetWindowResizable)(_THIS, SDL_Window *window, SDL_bool resizable)
int(* GetDisplayUsableBounds)(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int(* GL_GetSwapInterval)(_THIS)
void(* MaximizeWindow)(_THIS, SDL_Window *window)
int(* SetClipboardText)(_THIS, const char *text)
void WIN_HideWindow(_THIS, SDL_Window *window)
int(* SetWindowGammaRamp)(_THIS, SDL_Window *window, const Uint16 *ramp)
int WIN_SetClipboardText(_THIS, const char *text)
void(* OnWindowEnter)(_THIS, SDL_Window *window)
void(* SetWindowGrab)(_THIS, SDL_Window *window, SDL_bool grabbed)
int(* CreateWindowFramebuffer)(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
void *(* GL_GetProcAddress)(_THIS, const char *proc)
int WIN_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
void(* PumpEvents)(_THIS)