src/render/SDL_render.c
changeset 7109 003d40e446f5
parent 7073 873715d91f83
child 7141 e276777b4247
equal deleted inserted replaced
7108:732d2cac80c0 7109:003d40e446f5
    42         SDL_SetError("Invalid texture"); \
    42         SDL_SetError("Invalid texture"); \
    43         return retval; \
    43         return retval; \
    44     }
    44     }
    45 
    45 
    46 
    46 
       
    47 #if !SDL_RENDER_DISABLED
    47 static const SDL_RenderDriver *render_drivers[] = {
    48 static const SDL_RenderDriver *render_drivers[] = {
    48 #if !SDL_RENDER_DISABLED
       
    49 #if SDL_VIDEO_RENDER_D3D
    49 #if SDL_VIDEO_RENDER_D3D
    50     &D3D_RenderDriver,
    50     &D3D_RenderDriver,
    51 #endif
    51 #endif
    52 #if SDL_VIDEO_RENDER_OGL
    52 #if SDL_VIDEO_RENDER_OGL
    53     &GL_RenderDriver,
    53     &GL_RenderDriver,
    63 #endif
    63 #endif
    64 #if SDL_VIDEO_RENDER_PSP
    64 #if SDL_VIDEO_RENDER_PSP
    65     &PSP_RenderDriver,
    65     &PSP_RenderDriver,
    66 #endif
    66 #endif
    67     &SW_RenderDriver
    67     &SW_RenderDriver
       
    68 };
    68 #endif /* !SDL_RENDER_DISABLED */
    69 #endif /* !SDL_RENDER_DISABLED */
    69 };
    70 
    70 static char renderer_magic;
    71 static char renderer_magic;
    71 static char texture_magic;
    72 static char texture_magic;
    72 
    73 
    73 static int UpdateLogicalSize(SDL_Renderer *renderer);
    74 static int UpdateLogicalSize(SDL_Renderer *renderer);
    74 
    75 
    75 int
    76 int
    76 SDL_GetNumRenderDrivers(void)
    77 SDL_GetNumRenderDrivers(void)
    77 {
    78 {
       
    79 #if !SDL_RENDER_DISABLED
    78     return SDL_arraysize(render_drivers);
    80     return SDL_arraysize(render_drivers);
       
    81 #else
       
    82     return 0;
       
    83 #endif
    79 }
    84 }
    80 
    85 
    81 int
    86 int
    82 SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
    87 SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info)
    83 {
    88 {
       
    89 #if !SDL_RENDER_DISABLED
    84     if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
    90     if (index < 0 || index >= SDL_GetNumRenderDrivers()) {
    85         return SDL_SetError("index must be in the range of 0 - %d",
    91         return SDL_SetError("index must be in the range of 0 - %d",
    86                             SDL_GetNumRenderDrivers() - 1);
    92                             SDL_GetNumRenderDrivers() - 1);
    87     }
    93     }
    88     *info = render_drivers[index]->info;
    94     *info = render_drivers[index]->info;
    89     return 0;
    95     return 0;
       
    96 #else
       
    97     return SDL_SetError("SDL not built with rendering support");
       
    98 #endif
    90 }
    99 }
    91 
   100 
    92 static int
   101 static int
    93 SDL_RendererEventWatch(void *userdata, SDL_Event *event)
   102 SDL_RendererEventWatch(void *userdata, SDL_Event *event)
    94 {
   103 {
   195 }
   204 }
   196 
   205 
   197 SDL_Renderer *
   206 SDL_Renderer *
   198 SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
   207 SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags)
   199 {
   208 {
       
   209 #if !SDL_RENDER_DISABLED
   200     SDL_Renderer *renderer = NULL;
   210     SDL_Renderer *renderer = NULL;
   201     int n = SDL_GetNumRenderDrivers();
   211     int n = SDL_GetNumRenderDrivers();
   202     const char *hint;
   212     const char *hint;
   203 
   213 
   204     if (!window) {
   214     if (!window) {
   282 
   292 
   283         SDL_LogInfo(SDL_LOG_CATEGORY_RENDER,
   293         SDL_LogInfo(SDL_LOG_CATEGORY_RENDER,
   284                     "Created renderer: %s", renderer->info.name);
   294                     "Created renderer: %s", renderer->info.name);
   285     }
   295     }
   286     return renderer;
   296     return renderer;
       
   297 #else
       
   298     SDL_SetError("SDL not built with rendering support");
       
   299     return NULL;
       
   300 #endif
   287 }
   301 }
   288 
   302 
   289 SDL_Renderer *
   303 SDL_Renderer *
   290 SDL_CreateSoftwareRenderer(SDL_Surface * surface)
   304 SDL_CreateSoftwareRenderer(SDL_Surface * surface)
   291 {
   305 {