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 1622

Summary: SDL_RenderSetViewport with empty SDL_Rect raises wrong error for OpenGL rendering backend
Product: SDL Reporter: Marcus von Appen <mva>
Component: videoAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: HG 2.0   
Hardware: All   
OS: All   
Attachments: test program for empty viewports

Description Marcus von Appen 2012-10-12 13:40:44 UTC
Passing an empty SDL_Rect {0, 0, 0, 0} to SDL_RenderSetViewport() raises a SDL_Error for OpenGL, but fails to set an appropriate error message, leading to confusing output for the developer.

The issue can be found in GL_UpdateViewport:


if (!renderer->viewport.w || !renderer->viewport.h) {
   /* The viewport isn't set up yet, ignore it */
   return -1;
}
  
The return value is passed back to SDL_RenderSetViewport(), which returns it without any additional error message setting.

Ideally, the above code is changed in a way that it supports empty viewports or it sets the appropriate error message:

if (!renderer->viewport.w || !renderer->viewport.h) {
   /* The viewport isn't set up yet, ignore it */
   SDL_SetError("empty viewports are not supported for the OpenGL renderer")
   return -1;
}

Find attached a small test case, which tries to apply an empty SDL_Rect as viewport to all renderers found on the system.

On a side note: a render component in bugzilla would be nice ;-).
Comment 1 Marcus von Appen 2012-10-12 13:42:03 UTC
Created attachment 970 [details]
test program for empty viewports
Comment 2 Marcus von Appen 2013-04-24 05:32:37 UTC
Are there any news on this bug?
Comment 3 Sam Lantinga 2013-05-29 06:08:47 UTC
Fixed!  You can now legally set an empty viewport rect.
http://hg.libsdl.org/SDL/rev/04dda95ba22c