We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1302

Summary: SDL_RenderSetViewport() sets an invalid width/height
Product: SDL Reporter: ng <nicolas.guillaume>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED WORKSFORME QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: icculus
Version: HG 2.0   
Hardware: All   
OS: Android (All)   

Description ng 2011-09-06 06:09:10 UTC
This bug was seen on Android but may concern other platforms.


By setting the width/height directly in the structure the viewport has the expected size:

    SDL_Renderer * renderer = SDL_GetRenderer(...);
    renderer->viewport.w = w;
    renderer->viewport.h = h;
    renderer->viewport.x = 0;
    renderer->viewport.y = 0;

But when using SDL_RenderSetViewport like this:

    SDL_Renderer * renderer = SDL_GetRenderer(...);
    SDL_Rect r = {.x = 0, .y = 0, .w = w, .h = h};
    SDL_RenderSetViewport(renderer, &r);

The observed viewport is larger than expected.
Comment 1 ng 2011-09-06 06:37:50 UTC
(In reply to comment #0)
For example the following code has the expected behaviour:

    SDL_Renderer * renderer = SDL_GetRenderer(...);
    SDL_Rect r = {.x = x, .y = y, .w = ow, .h = oh};
    SDL_RenderSetViewport(renderer, &r);
    renderer->viewport.w = w;
    renderer->viewport.h = h;

(ow and oh are the original width & height)
Comment 2 Sam Lantinga 2012-01-07 21:46:45 UTC
I don't see anywhere in the code that the viewport isn't set to the values you give it.
Can you attach a small test program and show the output of the viewport size before and after the call to SDL_RenderSetViewport()?

Thanks!
Comment 3 Ryan C. Gordon 2015-02-18 03:32:04 UTC
I'll assume this is working okay now. Please reopen the bug if it's still giving you problems!

Thanks,
--ryan.