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 - SDL_RenderSetViewport with empty SDL_Rect raises wrong error for OpenGL rendering backend
Summary: SDL_RenderSetViewport with empty SDL_Rect raises wrong error for OpenGL rende...
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-12 13:40 UTC by Marcus von Appen
Modified: 2013-05-29 06:08 UTC (History)
0 users

See Also:


Attachments
test program for empty viewports (706 bytes, text/x-csrc)
2012-10-12 13:42 UTC, Marcus von Appen
Details

Note You need to log in before you can comment on or make changes to this bug.
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