Fixed bug 1583 - Fix build for disabled SDL render subsystem
authorSam Lantinga <slouken@libsdl.org>
Thu, 25 Apr 2013 00:15:09 -0700
changeset 7109003d40e446f5
parent 7108 732d2cac80c0
child 7110 2a98852fd58d
Fixed bug 1583 - Fix build for disabled SDL render subsystem

Marcus von Appen

If one wants to disable the SDL render subsystem, the build breaks on several platforms due to an empty render_drivers array in SDL_render.c.
src/render/SDL_render.c
     1.1 --- a/src/render/SDL_render.c	Wed Apr 24 23:11:48 2013 -0400
     1.2 +++ b/src/render/SDL_render.c	Thu Apr 25 00:15:09 2013 -0700
     1.3 @@ -44,8 +44,8 @@
     1.4      }
     1.5  
     1.6  
     1.7 +#if !SDL_RENDER_DISABLED
     1.8  static const SDL_RenderDriver *render_drivers[] = {
     1.9 -#if !SDL_RENDER_DISABLED
    1.10  #if SDL_VIDEO_RENDER_D3D
    1.11      &D3D_RenderDriver,
    1.12  #endif
    1.13 @@ -65,8 +65,9 @@
    1.14      &PSP_RenderDriver,
    1.15  #endif
    1.16      &SW_RenderDriver
    1.17 +};
    1.18  #endif /* !SDL_RENDER_DISABLED */
    1.19 -};
    1.20 +
    1.21  static char renderer_magic;
    1.22  static char texture_magic;
    1.23  
    1.24 @@ -75,18 +76,26 @@
    1.25  int
    1.26  SDL_GetNumRenderDrivers(void)
    1.27  {
    1.28 +#if !SDL_RENDER_DISABLED
    1.29      return SDL_arraysize(render_drivers);
    1.30 +#else
    1.31 +    return 0;
    1.32 +#endif
    1.33  }
    1.34  
    1.35  int
    1.36  SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
    1.37  {
    1.38 +#if !SDL_RENDER_DISABLED
    1.39      if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
    1.40          return SDL_SetError("index must be in the range of 0 - %d",
    1.41                              SDL_GetNumRenderDrivers() - 1);
    1.42      }
    1.43      *info = render_drivers[index]->info;
    1.44      return 0;
    1.45 +#else
    1.46 +    return SDL_SetError("SDL not built with rendering support");
    1.47 +#endif
    1.48  }
    1.49  
    1.50  static int
    1.51 @@ -197,6 +206,7 @@
    1.52  SDL_Renderer *
    1.53  SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
    1.54  {
    1.55 +#if !SDL_RENDER_DISABLED
    1.56      SDL_Renderer *renderer = NULL;
    1.57      int n = SDL_GetNumRenderDrivers();
    1.58      const char *hint;
    1.59 @@ -284,6 +294,10 @@
    1.60                      "Created renderer: %s", renderer->info.name);
    1.61      }
    1.62      return renderer;
    1.63 +#else
    1.64 +    SDL_SetError("SDL not built with rendering support");
    1.65 +    return NULL;
    1.66 +#endif
    1.67  }
    1.68  
    1.69  SDL_Renderer *