Commit a5eb0788 authored by Sam Lantinga's avatar Sam Lantinga

Don't add any renderers if you can't add any displays

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404264
parent b6b1631c
...@@ -157,7 +157,7 @@ WIN_AddDisplay(LPTSTR DeviceName) ...@@ -157,7 +157,7 @@ WIN_AddDisplay(LPTSTR DeviceName)
return SDL_TRUE; return SDL_TRUE;
} }
void int
WIN_InitModes(_THIS) WIN_InitModes(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
...@@ -192,6 +192,11 @@ WIN_InitModes(_THIS) ...@@ -192,6 +192,11 @@ WIN_InitModes(_THIS)
WIN_AddDisplay(DeviceName); WIN_AddDisplay(DeviceName);
} }
} }
if (_this->num_displays == 0) {
SDL_SetError("No displays available");
return -1;
}
return 0;
} }
void void
...@@ -205,10 +210,11 @@ WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display) ...@@ -205,10 +210,11 @@ WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
if (!WIN_GetDisplayMode(data->DeviceName, i, &mode)) { if (!WIN_GetDisplayMode(data->DeviceName, i, &mode)) {
break; break;
} }
if (mode.format != SDL_PIXELFORMAT_UNKNOWN) if (mode.format != SDL_PIXELFORMAT_UNKNOWN) {
if (!SDL_AddDisplayMode(display, &mode)) { if (!SDL_AddDisplayMode(display, &mode)) {
SDL_free(mode.driverdata); SDL_free(mode.driverdata);
} }
}
} }
} }
......
...@@ -34,7 +34,7 @@ typedef struct ...@@ -34,7 +34,7 @@ typedef struct
DEVMODE DeviceMode; DEVMODE DeviceMode;
} SDL_DisplayModeData; } SDL_DisplayModeData;
extern void WIN_InitModes(_THIS); extern int WIN_InitModes(_THIS);
extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display); extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void WIN_QuitModes(_THIS); extern void WIN_QuitModes(_THIS);
......
...@@ -207,7 +207,9 @@ VideoBootStrap WIN32_bootstrap = { ...@@ -207,7 +207,9 @@ VideoBootStrap WIN32_bootstrap = {
int int
WIN_VideoInit(_THIS) WIN_VideoInit(_THIS)
{ {
WIN_InitModes(_this); if (WIN_InitModes(_this) < 0) {
return -1;
}
#if SDL_VIDEO_RENDER_D3D #if SDL_VIDEO_RENDER_D3D
D3D_AddRenderDriver(_this); D3D_AddRenderDriver(_this);
......
...@@ -118,7 +118,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) ...@@ -118,7 +118,7 @@ X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo)
return SDL_PIXELFORMAT_UNKNOWN; return SDL_PIXELFORMAT_UNKNOWN;
} }
void int
X11_InitModes(_THIS) X11_InitModes(_THIS)
{ {
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
...@@ -168,6 +168,11 @@ X11_InitModes(_THIS) ...@@ -168,6 +168,11 @@ X11_InitModes(_THIS)
display.driverdata = displaydata; display.driverdata = displaydata;
SDL_AddVideoDisplay(&display); SDL_AddVideoDisplay(&display);
} }
if (_this->num_displays == 0) {
SDL_SetError("No available displays");
return -1;
}
return 0;
} }
/* Global for the error handler */ /* Global for the error handler */
......
...@@ -54,7 +54,7 @@ typedef struct ...@@ -54,7 +54,7 @@ typedef struct
} SDL_DisplayData; } SDL_DisplayData;
extern void X11_InitModes(_THIS); extern int X11_InitModes(_THIS);
extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display); extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display);
extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode);
extern void X11_QuitModes(_THIS); extern void X11_QuitModes(_THIS);
......
...@@ -255,7 +255,9 @@ X11_VideoInit(_THIS) ...@@ -255,7 +255,9 @@ X11_VideoInit(_THIS)
data->WM_DELETE_WINDOW = data->WM_DELETE_WINDOW =
XInternAtom(data->display, "WM_DELETE_WINDOW", False); XInternAtom(data->display, "WM_DELETE_WINDOW", False);
X11_InitModes(_this); if (X11_InitModes(_this) < 0) {
return -1;
}
#if SDL_VIDEO_RENDER_X11 #if SDL_VIDEO_RENDER_X11
X11_AddRenderDriver(_this); X11_AddRenderDriver(_this);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment