Error in SDL_SetRenderTarget

The SDL_RenderGetLogicalSize function should always return the amount of pixels that are currently available for rendering to.? But after updating to the latest SDL2, I started getting crashes because it was returning (0,0) as the logical size!? After a bit of debugging, I tracked it down to the following code in SDL_SetRenderTarget:

??? if (texture) {
??? renderer->viewport.x = 0;
??? renderer->viewport.y = 0;
??? renderer->viewport.w = texture->w;
??? renderer->viewport.h = texture->h;
??? renderer->scale.x = 1.0f;
??? renderer->scale.y = 1.0f;
??? renderer->logical_w = 0;
??? renderer->logical_h = 0;
? ? }

This is obviously wrong; 0 is never the correct value for a valid renderer.? Those last two lines should read:

??? renderer->logical_w = texture->w;
??? renderer->logical_h = texture->w;

Mason

Ahem.? The lines should be:

??? renderer->logical_w = texture->w;
??? renderer->logical_h = texture->h;

grumble Stupid copy-paste errors…

Mason________________________________
From: Mason Wheeler <@Mason_Wheeler>
To: sdl
Sent: Saturday, June 29, 2013 1:42 PM
Subject: [SDL] Error in SDL_SetRenderTarget

The SDL_RenderGetLogicalSize function should always return the amount of pixels that are currently available for rendering to.? But after updating to the latest SDL2, I started getting crashes because it was returning (0,0) as the logical size!? After a bit of debugging, I tracked it down to the following code in SDL_SetRenderTarget:

??? if (texture) {
??? renderer->viewport.x = 0;
??? renderer->viewport.y = 0;
??? renderer->viewport.w = texture->w;
???
renderer->viewport.h = texture->h;
??? renderer->scale.x = 1.0f;
??? renderer->scale.y = 1.0f;
??? renderer->logical_w = 0;
??? renderer->logical_h = 0;
? ? }

This is obviously wrong; 0 is never the correct value for a valid renderer.? Those last two lines should read:

??? renderer->logical_w = texture->w;
??? renderer->logical_h = texture->w;

Mason


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Fixed, thanks!On Sat, Jun 29, 2013 at 1:42 PM, Mason Wheeler wrote:

The SDL_RenderGetLogicalSize function should always return the amount of
pixels that are currently available for rendering to. But after updating
to the latest SDL2, I started getting crashes because it was returning
(0,0) as the logical size! After a bit of debugging, I tracked it down to
the following code in SDL_SetRenderTarget:

if (texture) {
    renderer->viewport.x = 0;
    renderer->viewport.y = 0;
    renderer->viewport.w = texture->w;
    renderer->viewport.h = texture->h;
    renderer->scale.x = 1.0f;
    renderer->scale.y = 1.0f;
    renderer->logical_w = 0;
    renderer->logical_h = 0;
}

This is obviously wrong; 0 is never the correct value for a valid
renderer. Those last two lines should read:

    renderer->logical_w = texture->w;
    renderer->logical_h = texture->w;

Mason


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org