Removed SDL_RENDERER_ACCELERATED and SDL_RENDERER_SOFTWARE

These flags are unnecessary and have always been a source of confusion.
main
Sam Lantinga 2024-04-04 12:39:24 -07:00
parent 3f8dba3713
commit 5fa87e29e7
19 changed files with 37 additions and 92 deletions

View File

@ -1064,8 +1064,6 @@ which index is the "opengl" or whatnot driver, you can just pass that string dir
here, now. Passing NULL is the same as passing -1 here in SDL2, to signify you want SDL here, now. Passing NULL is the same as passing -1 here in SDL2, to signify you want SDL
to decide for you. to decide for you.
The SDL_RENDERER_TARGETTEXTURE flag has been removed, all current renderers support target texture functionality.
Mouse and touch events are no longer filtered to change their coordinates, instead you Mouse and touch events are no longer filtered to change their coordinates, instead you
can call SDL_ConvertEventToRenderCoordinates() to explicitly map event coordinates into can call SDL_ConvertEventToRenderCoordinates() to explicitly map event coordinates into
the rendering viewport. the rendering viewport.
@ -1131,6 +1129,11 @@ The following symbols have been renamed:
* SDL_ScaleModeLinear => SDL_SCALEMODE_LINEAR * SDL_ScaleModeLinear => SDL_SCALEMODE_LINEAR
* SDL_ScaleModeNearest => SDL_SCALEMODE_NEAREST * SDL_ScaleModeNearest => SDL_SCALEMODE_NEAREST
The following symbols have been removed:
* SDL_RENDERER_ACCELERATED - all renderers except `SDL_SOFTWARE_RENDERER` are accelerated
* SDL_RENDERER_SOFTWARE - you can check whether the name of the renderer is `SDL_SOFTWARE_RENDERER`
* SDL_RENDERER_TARGETTEXTURE - all renderers support target texture functionality
## SDL_rwops.h ## SDL_rwops.h
The following symbols have been renamed: The following symbols have been renamed:

View File

@ -88,7 +88,7 @@ Here's a sample SDL snippet to verify everything is setup in your IDE:
SDL_Init(SDL_INIT_VIDEO); SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0); window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0);
renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_PRESENTVSYNC);
SDL_DestroyRenderer(renderer); SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window); SDL_DestroyWindow(window);

View File

@ -61,16 +61,17 @@
extern "C" { extern "C" {
#endif #endif
/**
* The name of the software renderer
*/
#define SDL_SOFTWARE_RENDERER "software"
/** /**
* Flags used when creating a rendering context * Flags used when creating a rendering context
*/ */
typedef enum typedef enum
{ {
SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ SDL_RENDERER_PRESENTVSYNC = 0x00000004 /**< Present is synchronized with the refresh rate */
SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware
acceleration */
SDL_RENDERER_PRESENTVSYNC = 0x00000004 /**< Present is synchronized
with the refresh rate */
} SDL_RendererFlags; } SDL_RendererFlags;
/** /**
@ -204,10 +205,6 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(int width, int height, S
* need a specific renderer, specify NULL and SDL will attempt to choose the * need a specific renderer, specify NULL and SDL will attempt to choose the
* best option for you, based on what is available on the user's system. * best option for you, based on what is available on the user's system.
* *
* If you pass SDL_RENDERER_SOFTWARE in the flags, you will get a software
* renderer, otherwise you will get a hardware accelerated renderer if
* available.
*
* By default the rendering size matches the window size in pixels, but you * By default the rendering size matches the window size in pixels, but you
* can call SDL_SetRenderLogicalPresentation() to change the content size and * can call SDL_SetRenderLogicalPresentation() to change the content size and
* scaling options. * scaling options.

View File

@ -1017,7 +1017,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
/* new textures start at zero, so we start at 1 so first render doesn't flush by accident. */ /* new textures start at zero, so we start at 1 so first render doesn't flush by accident. */
renderer->render_command_generation = 1; renderer->render_command_generation = 1;
if (renderer->info.flags & SDL_RENDERER_SOFTWARE) { if (renderer->software) {
/* Software renderer always uses line method, for speed */ /* Software renderer always uses line method, for speed */
renderer->line_method = SDL_RENDERLINEMETHOD_LINES; renderer->line_method = SDL_RENDERLINEMETHOD_LINES;
} else { } else {
@ -1085,11 +1085,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 fl
SDL_Renderer *renderer; SDL_Renderer *renderer;
SDL_PropertiesID props = SDL_CreateProperties(); SDL_PropertiesID props = SDL_CreateProperties();
SDL_SetProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, window); SDL_SetProperty(props, SDL_PROP_RENDERER_CREATE_WINDOW_POINTER, window);
if (flags & SDL_RENDERER_SOFTWARE) {
SDL_SetStringProperty(props, SDL_PROP_RENDERER_CREATE_NAME_STRING, "software");
} else {
SDL_SetStringProperty(props, SDL_PROP_RENDERER_CREATE_NAME_STRING, name); SDL_SetStringProperty(props, SDL_PROP_RENDERER_CREATE_NAME_STRING, name);
}
if (flags & SDL_RENDERER_PRESENTVSYNC) { if (flags & SDL_RENDERER_PRESENTVSYNC) {
SDL_SetBooleanProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN, SDL_TRUE); SDL_SetBooleanProperty(props, SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN, SDL_TRUE);
} }
@ -4250,7 +4246,7 @@ int SDL_RenderGeometryRawFloat(SDL_Renderer *renderer,
/* For the software renderer, try to reinterpret triangles as SDL_Rect */ /* For the software renderer, try to reinterpret triangles as SDL_Rect */
#if SDL_VIDEO_RENDER_SW #if SDL_VIDEO_RENDER_SW
if (renderer->info.flags & SDL_RENDERER_SOFTWARE) { if (renderer->software) {
return SDL_SW_RenderGeometryRaw(renderer, texture, return SDL_SW_RenderGeometryRaw(renderer, texture,
xy, xy_stride, color, color_stride, uv, uv_stride, num_vertices, xy, xy_stride, color, color_stride, uv, uv_stride, num_vertices,
indices, num_indices, size_indices); indices, num_indices, size_indices);
@ -4678,7 +4674,7 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync)
/* for the software renderer, forward eventually the call to the WindowTexture renderer */ /* for the software renderer, forward eventually the call to the WindowTexture renderer */
#if SDL_VIDEO_RENDER_SW #if SDL_VIDEO_RENDER_SW
if (renderer->info.flags & SDL_RENDERER_SOFTWARE) { if (renderer->software) {
if (SDL_SetWindowTextureVSync(renderer->window, vsync) == 0) { if (SDL_SetWindowTextureVSync(renderer->window, vsync) == 0) {
renderer->simulate_vsync = SDL_FALSE; renderer->simulate_vsync = SDL_FALSE;
return 0; return 0;

View File

@ -220,6 +220,7 @@ struct SDL_Renderer
/* The current renderer info */ /* The current renderer info */
SDL_RendererInfo info; SDL_RendererInfo info;
SDL_bool software;
/* The window associated with the renderer */ /* The window associated with the renderer */
SDL_Window *window; SDL_Window *window;

View File

@ -1631,7 +1631,6 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_pro
renderer->DestroyRenderer = D3D_DestroyRenderer; renderer->DestroyRenderer = D3D_DestroyRenderer;
renderer->SetVSync = D3D_SetVSync; renderer->SetVSync = D3D_SetVSync;
renderer->info = D3D_RenderDriver.info; renderer->info = D3D_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data; renderer->driverdata = data;
D3D_InvalidateCachedState(renderer); D3D_InvalidateCachedState(renderer);
@ -1748,7 +1747,7 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_pro
SDL_RenderDriver D3D_RenderDriver = { SDL_RenderDriver D3D_RenderDriver = {
D3D_CreateRenderer, D3D_CreateRenderer,
{ "direct3d", { "direct3d",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), SDL_RENDERER_PRESENTVSYNC,
1, 1,
{ SDL_PIXELFORMAT_ARGB8888 }, { SDL_PIXELFORMAT_ARGB8888 },
0, 0,

View File

@ -2794,7 +2794,6 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_p
renderer->DestroyTexture = D3D11_DestroyTexture; renderer->DestroyTexture = D3D11_DestroyTexture;
renderer->DestroyRenderer = D3D11_DestroyRenderer; renderer->DestroyRenderer = D3D11_DestroyRenderer;
renderer->info = D3D11_RenderDriver.info; renderer->info = D3D11_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data; renderer->driverdata = data;
D3D11_InvalidateCachedState(renderer); D3D11_InvalidateCachedState(renderer);
@ -2840,8 +2839,7 @@ SDL_RenderDriver D3D11_RenderDriver = {
D3D11_CreateRenderer, D3D11_CreateRenderer,
{ {
"direct3d11", "direct3d11",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC, /* flags. see SDL_RendererFlags */
SDL_RENDERER_PRESENTVSYNC), /* flags. see SDL_RendererFlags */
9, /* num_texture_formats */ 9, /* num_texture_formats */
{ /* texture_formats */ { /* texture_formats */
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888,

View File

@ -3232,7 +3232,6 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_p
renderer->DestroyTexture = D3D12_DestroyTexture; renderer->DestroyTexture = D3D12_DestroyTexture;
renderer->DestroyRenderer = D3D12_DestroyRenderer; renderer->DestroyRenderer = D3D12_DestroyRenderer;
renderer->info = D3D12_RenderDriver.info; renderer->info = D3D12_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data; renderer->driverdata = data;
D3D12_InvalidateCachedState(renderer); D3D12_InvalidateCachedState(renderer);
@ -3263,8 +3262,7 @@ SDL_RenderDriver D3D12_RenderDriver = {
D3D12_CreateRenderer, D3D12_CreateRenderer,
{ {
"direct3d12", "direct3d12",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC, /* flags. see SDL_RendererFlags */
SDL_RENDERER_PRESENTVSYNC), /* flags. see SDL_RendererFlags */
9, /* num_texture_formats */ 9, /* num_texture_formats */
{ /* texture_formats */ { /* texture_formats */
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888,

View File

@ -2155,7 +2155,6 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, SDL_PropertiesID c
renderer->GetMetalCommandEncoder = METAL_GetMetalCommandEncoder; renderer->GetMetalCommandEncoder = METAL_GetMetalCommandEncoder;
renderer->info = METAL_RenderDriver.info; renderer->info = METAL_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
#if (defined(SDL_PLATFORM_MACOS) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST #if (defined(SDL_PLATFORM_MACOS) && defined(MAC_OS_X_VERSION_10_13)) || TARGET_OS_MACCATALYST
if (@available(macOS 10.13, *)) { if (@available(macOS 10.13, *)) {
@ -2214,7 +2213,7 @@ SDL_RenderDriver METAL_RenderDriver = {
METAL_CreateRenderer, METAL_CreateRenderer,
{ {
"metal", "metal",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), SDL_RENDERER_PRESENTVSYNC,
10, 10,
{ SDL_PIXELFORMAT_ARGB8888, { SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888,

View File

@ -1612,32 +1612,6 @@ static int GL_SetVSync(SDL_Renderer *renderer, const int vsync)
return retval; return retval;
} }
static SDL_bool GL_IsProbablyAccelerated(const GL_RenderData *data)
{
/*const char *vendor = (const char *) data->glGetString(GL_VENDOR);*/
const char *renderer = (const char *)data->glGetString(GL_RENDERER);
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK)
if (SDL_strcmp(renderer, "GDI Generic") == 0) {
return SDL_FALSE; /* Microsoft's fallback software renderer. Fix your system! */
}
#endif
#ifdef SDL_PLATFORM_APPLE
if (SDL_strcmp(renderer, "Apple Software Renderer") == 0) {
return SDL_FALSE; /* (a probably very old) Apple software-based OpenGL. */
}
#endif
if (SDL_strcmp(renderer, "Software Rasterizer") == 0) {
return SDL_FALSE; /* (a probably very old) Software Mesa, or some other generic thing. */
}
/* !!! FIXME: swrast? llvmpipe? softpipe? */
return SDL_TRUE;
}
static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_props) static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_props)
{ {
SDL_Renderer *renderer; SDL_Renderer *renderer;
@ -1739,10 +1713,6 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, SDL_PropertiesID crea
goto error; goto error;
} }
if (GL_IsProbablyAccelerated(data)) {
renderer->info.flags |= SDL_RENDERER_ACCELERATED;
}
#ifdef SDL_PLATFORM_MACOS #ifdef SDL_PLATFORM_MACOS
/* Enable multi-threaded rendering */ /* Enable multi-threaded rendering */
/* Disabled until Ryan finishes his VBO/PBO code... /* Disabled until Ryan finishes his VBO/PBO code...
@ -1919,7 +1889,7 @@ error:
SDL_RenderDriver GL_RenderDriver = { SDL_RenderDriver GL_RenderDriver = {
GL_CreateRenderer, GL_CreateRenderer,
{ "opengl", { "opengl",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), SDL_RENDERER_PRESENTVSYNC,
4, 4,
{ SDL_PIXELFORMAT_ARGB8888, { SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888,

View File

@ -2099,7 +2099,6 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, SDL_PropertiesID c
goto error; goto error;
} }
renderer->info = GLES2_RenderDriver.info; renderer->info = GLES2_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data; renderer->driverdata = data;
GLES2_InvalidateCachedState(renderer); GLES2_InvalidateCachedState(renderer);
renderer->window = window; renderer->window = window;
@ -2264,7 +2263,7 @@ error:
SDL_RenderDriver GLES2_RenderDriver = { SDL_RenderDriver GLES2_RenderDriver = {
GLES2_CreateRenderer, GLES2_CreateRenderer,
{ "opengles2", { "opengles2",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), SDL_RENDERER_PRESENTVSYNC,
4, 4,
{ SDL_PIXELFORMAT_RGBA32, { SDL_PIXELFORMAT_RGBA32,
SDL_PIXELFORMAT_BGRA32, SDL_PIXELFORMAT_BGRA32,

View File

@ -704,7 +704,6 @@ static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, SDL_PropertiesID cre
renderer->DestroyRenderer = PS2_DestroyRenderer; renderer->DestroyRenderer = PS2_DestroyRenderer;
renderer->SetVSync = PS2_SetVSync; renderer->SetVSync = PS2_SetVSync;
renderer->info = PS2_RenderDriver.info; renderer->info = PS2_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data; renderer->driverdata = data;
PS2_InvalidateCachedState(renderer); PS2_InvalidateCachedState(renderer);
renderer->window = window; renderer->window = window;
@ -719,7 +718,7 @@ SDL_RenderDriver PS2_RenderDriver = {
.CreateRenderer = PS2_CreateRenderer, .CreateRenderer = PS2_CreateRenderer,
.info = { .info = {
.name = "PS2 gsKit", .name = "PS2 gsKit",
.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), .flags = SDL_RENDERER_PRESENTVSYNC,
.num_texture_formats = 2, .num_texture_formats = 2,
.texture_formats = { .texture_formats = {
[0] = SDL_PIXELFORMAT_ABGR1555, [0] = SDL_PIXELFORMAT_ABGR1555,

View File

@ -1336,7 +1336,6 @@ SDL_Renderer *PSP_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_pro
renderer->DestroyRenderer = PSP_DestroyRenderer; renderer->DestroyRenderer = PSP_DestroyRenderer;
renderer->SetVSync = PSP_SetVSync; renderer->SetVSync = PSP_SetVSync;
renderer->info = PSP_RenderDriver.info; renderer->info = PSP_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data; renderer->driverdata = data;
PSP_InvalidateCachedState(renderer); PSP_InvalidateCachedState(renderer);
renderer->window = window; renderer->window = window;
@ -1414,7 +1413,7 @@ SDL_RenderDriver PSP_RenderDriver = {
.CreateRenderer = PSP_CreateRenderer, .CreateRenderer = PSP_CreateRenderer,
.info = { .info = {
.name = "PSP", .name = "PSP",
.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), .flags = SDL_RENDERER_PRESENTVSYNC,
.num_texture_formats = 4, .num_texture_formats = 4,
.texture_formats = { .texture_formats = {
[0] = SDL_PIXELFORMAT_BGR565, [0] = SDL_PIXELFORMAT_BGR565,

View File

@ -1131,6 +1131,7 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface, SDL_PropertiesID
return NULL; return NULL;
} }
renderer->magic = &SDL_renderer_magic; renderer->magic = &SDL_renderer_magic;
renderer->software = SDL_TRUE;
data = (SW_RenderData *)SDL_calloc(1, sizeof(*data)); data = (SW_RenderData *)SDL_calloc(1, sizeof(*data));
if (!data) { if (!data) {
@ -1217,8 +1218,8 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, SDL_PropertiesID crea
SDL_RenderDriver SW_RenderDriver = { SDL_RenderDriver SW_RenderDriver = {
SW_CreateRenderer, SW_CreateRenderer,
{ "software", { SDL_SOFTWARE_RENDERER,
(SDL_RENDERER_SOFTWARE | SDL_RENDERER_PRESENTVSYNC), SDL_RENDERER_PRESENTVSYNC,
0, 0,
{ /* formats filled in later */ { /* formats filled in later */
SDL_PIXELFORMAT_UNKNOWN }, SDL_PIXELFORMAT_UNKNOWN },

View File

@ -103,7 +103,7 @@ SDL_RenderDriver VITA_GXM_RenderDriver = {
.CreateRenderer = VITA_GXM_CreateRenderer, .CreateRenderer = VITA_GXM_CreateRenderer,
.info = { .info = {
.name = "VITA gxm", .name = "VITA gxm",
.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), .flags = SDL_RENDERER_PRESENTVSYNC,
.num_texture_formats = 8, .num_texture_formats = 8,
.texture_formats = { .texture_formats = {
[0] = SDL_PIXELFORMAT_ABGR8888, [0] = SDL_PIXELFORMAT_ABGR8888,
@ -261,7 +261,6 @@ SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, SDL_PropertiesID creat
renderer->SetVSync = VITA_GXM_SetVSync; renderer->SetVSync = VITA_GXM_SetVSync;
renderer->info = VITA_GXM_RenderDriver.info; renderer->info = VITA_GXM_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data; renderer->driverdata = data;
VITA_GXM_InvalidateCachedState(renderer); VITA_GXM_InvalidateCachedState(renderer);
renderer->window = window; renderer->window = window;

View File

@ -4094,7 +4094,6 @@ SDL_Renderer *VULKAN_CreateRenderer(SDL_Window *window, SDL_PropertiesID create_
renderer->DestroyTexture = VULKAN_DestroyTexture; renderer->DestroyTexture = VULKAN_DestroyTexture;
renderer->DestroyRenderer = VULKAN_DestroyRenderer; renderer->DestroyRenderer = VULKAN_DestroyRenderer;
renderer->info = VULKAN_RenderDriver.info; renderer->info = VULKAN_RenderDriver.info;
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = rendererData; renderer->driverdata = rendererData;
VULKAN_InvalidateCachedState(renderer); VULKAN_InvalidateCachedState(renderer);
@ -4135,8 +4134,7 @@ SDL_RenderDriver VULKAN_RenderDriver = {
VULKAN_CreateRenderer, VULKAN_CreateRenderer,
{ {
"vulkan", "vulkan",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC, /* flags. see SDL_RendererFlags */
SDL_RENDERER_PRESENTVSYNC), /* flags. see SDL_RendererFlags */
4, /* num_texture_formats */ 4, /* num_texture_formats */
{ /* texture_formats */ { /* texture_formats */
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888,

View File

@ -955,12 +955,6 @@ static void SDLTest_PrintButtonMask(char *text, size_t maxlen, Uint32 flags)
static void SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag) static void SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag)
{ {
switch (flag) { switch (flag) {
case SDL_RENDERER_SOFTWARE:
SDL_snprintfcat(text, maxlen, "Software");
break;
case SDL_RENDERER_ACCELERATED:
SDL_snprintfcat(text, maxlen, "Accelerated");
break;
case SDL_RENDERER_PRESENTVSYNC: case SDL_RENDERER_PRESENTVSYNC:
SDL_snprintfcat(text, maxlen, "PresentVSync"); SDL_snprintfcat(text, maxlen, "PresentVSync");
break; break;

View File

@ -253,7 +253,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S
const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' && const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' &&
SDL_strcasecmp(hint, "true") != 0 && SDL_strcasecmp(hint, "true") != 0 &&
SDL_strcasecmp(hint, "false") != 0 && SDL_strcasecmp(hint, "false") != 0 &&
SDL_strcasecmp(hint, "software") != 0); SDL_strcasecmp(hint, SDL_SOFTWARE_RENDERER) != 0);
/* Check to see if there's a specific driver requested */ /* Check to see if there's a specific driver requested */
if (specific_accelerated_renderer) { if (specific_accelerated_renderer) {
@ -264,20 +264,15 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, S
} }
return SDL_SetError("Requested renderer for " SDL_HINT_FRAMEBUFFER_ACCELERATION " is not available"); return SDL_SetError("Requested renderer for " SDL_HINT_FRAMEBUFFER_ACCELERATION " is not available");
} }
/* if it was specifically requested, even if SDL_RENDERER_ACCELERATED isn't set, we'll accept this renderer. */
} else { } else {
const int total = SDL_GetNumRenderDrivers(); const int total = SDL_GetNumRenderDrivers();
for (i = 0; i < total; ++i) { for (i = 0; i < total; ++i) {
const char *name = SDL_GetRenderDriver(i); const char *name = SDL_GetRenderDriver(i);
if (name && (SDL_strcmp(name, "software") != 0)) { if (name && (SDL_strcmp(name, SDL_SOFTWARE_RENDERER) != 0)) {
renderer = SDL_CreateRenderer(window, name, 0); renderer = SDL_CreateRenderer(window, name, 0);
if (renderer && (SDL_GetRendererInfo(renderer, &info) == 0) && (info.flags & SDL_RENDERER_ACCELERATED)) { if (renderer) {
break; /* this will work. */ break; /* this will work. */
} }
if (renderer) { /* wasn't accelerated, etc, skip it. */
SDL_DestroyRenderer(renderer);
renderer = NULL;
}
} }
} }
if (!renderer) { if (!renderer) {
@ -3049,7 +3044,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window)
/* See if the user or application wants to specifically disable the framebuffer */ /* See if the user or application wants to specifically disable the framebuffer */
const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION);
if (hint) { if (hint) {
if ((*hint == '0') || (SDL_strcasecmp(hint, "false") == 0) || (SDL_strcasecmp(hint, "software") == 0)) { if ((*hint == '0') || (SDL_strcasecmp(hint, "false") == 0) || (SDL_strcasecmp(hint, SDL_SOFTWARE_RENDERER) == 0)) {
attempt_texture_framebuffer = SDL_FALSE; attempt_texture_framebuffer = SDL_FALSE;
} }
} }

View File

@ -49,7 +49,7 @@ static int isSupported(int code);
static void InitCreateRenderer(void *arg) static void InitCreateRenderer(void *arg)
{ {
int width = 320, height = 240; int width = 320, height = 240;
int renderer_flags = SDL_RENDERER_ACCELERATED; const char *renderer_name = NULL;
renderer = NULL; renderer = NULL;
window = SDL_CreateWindow("render_testCreateRenderer", width, height, 0); window = SDL_CreateWindow("render_testCreateRenderer", width, height, 0);
SDLTest_AssertPass("SDL_CreateWindow()"); SDLTest_AssertPass("SDL_CreateWindow()");
@ -59,10 +59,10 @@ static void InitCreateRenderer(void *arg)
} }
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) { if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) {
renderer_flags = 0; renderer_name = SDL_SOFTWARE_RENDERER;
} }
renderer = SDL_CreateRenderer(window, NULL, renderer_flags); renderer = SDL_CreateRenderer(window, renderer_name, 0);
SDLTest_AssertPass("SDL_CreateRenderer()"); SDLTest_AssertPass("SDL_CreateRenderer()");
SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result: %s", renderer != NULL ? "success" : SDL_GetError()); SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result: %s", renderer != NULL ? "success" : SDL_GetError());
if (renderer == NULL) { if (renderer == NULL) {