LimitScreenUpdates(FALSE);
+#if 0
+ {
+ static int LastFrameCounter = 0;
+ boolean changed = (FrameCounter != LastFrameCounter);
+
+ printf("::: FrameCounter == %d [%s]\n", FrameCounter,
+ (changed ? "-" : "SAME FRAME UPDATED"));
+
+ LastFrameCounter = FrameCounter;
+
+ /*
+ if (FrameCounter % 2)
+ return;
+ */
+ }
+#endif
+
#if defined(TARGET_SDL2)
#if USE_RENDERER
SDL_Surface *screen = backbuffer->surface;
new_surface = SDL_ConvertSurface(*surface, backbuffer->surface->format, 0);
+ if (new_surface == NULL)
+ Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
+
SDL_FreeSurface(*surface);
*surface = new_surface;
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
+ SDL_Surface *new_surface;
+
if (surface == NULL)
return NULL;
- if (backbuffer == NULL ||
- backbuffer->surface == NULL)
- return SDL_ConvertSurface(surface, surface->format, 0);
+ if (backbuffer && backbuffer->surface)
+ new_surface = SDL_ConvertSurface(surface, backbuffer->surface->format, 0);
+ else
+ new_surface = SDL_ConvertSurface(surface, surface->format, 0);
- return SDL_ConvertSurface(surface, backbuffer->surface->format, 0);
+ if (new_surface == NULL)
+ Error(ERR_EXIT, "SDL_ConvertSurface() failed: %s", SDL_GetError());
+
+ return new_surface;
}
#else
{
SDL_Surface *new_surface;
- if (surface == NULL)
+ if (surface == NULL ||
+ *surface == NULL ||
+ !video.initialized)
return FALSE;
new_surface = SDL_DisplayFormat(*surface);
SDL_Surface *SDLGetNativeSurface(SDL_Surface *surface)
{
- SDL_Surface *new_surface = SDL_DisplayFormat(surface);
+ SDL_Surface *new_surface;
+
+ if (video.initialized)
+ new_surface = SDL_DisplayFormat(surface);
+ else
+ new_surface = SDL_ConvertSurface(surface, surface->format, SURFACE_FLAGS);
if (new_surface == NULL)
- Error(ERR_EXIT, "SDL_DisplayFormat() failed: %s", SDL_GetError());
+ Error(ERR_EXIT, "%s() failed: %s",
+ (video.initialized ? "SDL_DisplayFormat" : "SDL_ConvertSurface"),
+ SDL_GetError());
return new_surface;
}
/* !!! SDL2 can only set the window icon if the window already exists !!! */
/* set window icon */
- SDLSetWindowIcon(program.sdl_icon_filename);
+ SDLSetWindowIcon(program.icon_filename);
/* set window and icon title */
#if defined(TARGET_SDL2)
SDLRedrawWindow(); // map window
#endif
+#ifdef DEBUG
+#if defined(PLATFORM_WIN32)
+ // experimental drag and drop code
+
SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
-#if defined(PLATFORM_WIN32)
{
SDL_SysWMinfo wminfo;
HWND hwnd;
DragAcceptFiles(hwnd, TRUE);
}
}
+#endif
#endif
return success;
void SDLHandleWindowManagerEvent(Event *event)
{
+#ifdef DEBUG
#if defined(PLATFORM_WIN32)
+ // experimental drag and drop code
+
SDL_SysWMEvent *syswmevent = (SDL_SysWMEvent *)event;
SDL_SysWMmsg *syswmmsg = (SDL_SysWMmsg *)(syswmevent->msg);
#endif
}
#endif
+#endif
}