Skip to content

Commit

Permalink
Add a work-around for SDL_GetVideoSurface in SDL2.
Browse files Browse the repository at this point in the history
For now simply assume the surface returned is NULL and everything
compiles nicely.
  • Loading branch information
mordante committed Mar 2, 2014
1 parent 41b316d commit 80636af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/font.cpp
Expand Up @@ -1139,7 +1139,11 @@ SDL_Rect get_floating_label_rect(int handle)

floating_label_context::floating_label_context()
{
#if SDL_VERSION_ATLEAST(2, 0, 0)
surface const screen = NULL;
#else
surface const screen = SDL_GetVideoSurface();
#endif
if(screen != NULL) {
draw_floating_labels(screen);
}
Expand All @@ -1156,7 +1160,11 @@ floating_label_context::~floating_label_context()

label_contexts.pop();

#if SDL_VERSION_ATLEAST(2, 0, 0)
surface const screen = NULL;
#else
surface const screen = SDL_GetVideoSurface();
#endif
if(screen != NULL) {
undraw_floating_labels(screen);
}
Expand Down
10 changes: 10 additions & 0 deletions src/video.cpp
Expand Up @@ -223,16 +223,22 @@ bool non_interactive()
{
if (fake_interactive)
return false;
#if SDL_VERSION_ATLEAST(2, 0, 0)
return false;
#else
return SDL_GetVideoSurface() == NULL;
#endif
}

surface display_format_alpha(surface surf)
{
#if !SDL_VERSION_ATLEAST(2, 0, 0)
if(SDL_GetVideoSurface() != NULL)
return SDL_DisplayFormatAlpha(surf);
else if(frameBuffer != NULL)
return SDL_ConvertSurface(surf,frameBuffer->format,0);
else
#endif
return NULL;
}

Expand All @@ -258,7 +264,11 @@ void update_rect(const SDL_Rect& rect_value)

SDL_Rect rect = rect_value;

#if SDL_VERSION_ATLEAST(2, 0, 0)
surface const fb = NULL;
#else
surface const fb = SDL_GetVideoSurface();
#endif
if(fb != NULL) {
if(rect.x < 0) {
if(rect.x*-1 >= int(rect.w))
Expand Down

0 comments on commit 80636af

Please sign in to comment.