| Summary: | API to discover current desktop resolution... | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Ryan C. Gordon <icculus> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | API change | ||
| Priority: | P2 | ||
| Version: | 2.0.0 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | dm-cvs-20050124144500.diff.txt | ||
Setting Sam as "QA Contact" on all bugs (even resolved ones) so he'll definitely be in the loop to any further discussion here about SDL. --ryan. (In reply to comment #0) > My current proposal looks something like this: > int SDL_GetCurrentResolution(SDL_Rect *physical, SDL_Rect *virtual); How about SDL_GetDesktopResolution(...)? > Issues: > - What to do with multimonitor support? Punt until we have multimonitor support in SDL. We'd need to be able to enumerate the attached monitors and specify which one is used in the API calls to list video modes, set video modes, and this one. > - Is virtual resolution really useful? *shrug* > - Should this report the resolution at that moment? Should it change with a > successful call to SDL_SetVideoMode(..., SDL_FULLSCREEN)? No, it should just report the current desktop resolution, before going to fullscreen. If you're in windowed mode, and the user changes desktop resolution, it should return the new desktop resolution. > - What drivers can actually support this? Windows can, X11 can, I presume most other systems with a desktop can do this. Date: Tue, 22 Mar 2005 02:50:26 +0000 (UTC) From: Marco Tarini <tarini@isti.cnr.it> Subject: [SDL] detecting current screen resolution (again!) Let me also suggest the simplest way (from the point of view of the library-user, not the SDL-dev) to have that: make SDL_SetVideoMode(sx,sx,bpp,flags), when - flags includes SDL_FULLSCREEN and - (sx,sy,bpp)==(0,0,0) set the fullscreen mode at the _current_ screen bpp, size x, and y. Also, VideoInfo would return screen res as well. BTW isn't it peculiar that it currently doesn't? I wonder if it is that nobody though that it would be useful, or if there is problem I can't see implementing it in some system. Date: Tue, 22 Mar 2005 18:20:37 +0000 From: Jon Colverson <sdl@vcxz.co.uk> Subject: Re: [SDL] detecting current screen resolution (again!) I wrote a patch to add a function to get the current desktop resolution. Unfortunately, it's only implemented for X11 and Windows. There was a thread about it on this list which starts here: http://www.devolution.com/pipermail/sdl/2005-January/thread.html#67010 and continues in February: http://www.devolution.com/pipermail/sdl/2005-February/thread.html#67335 To summarise the thread: It was widely agreed that this would be useful functionality. Some people didn't like my API (int SDL_GetDesktopMode(int *width, int *height)), and it doesn't allow for complete binary compatibility (programs that use the new function can't run with earlier SDL 1.2 libs). Stephane Marchesin suggested adding the information to the SDL_VideoInfo structure. This can't be done without breaking binary compatibility, so will have to wait for SDL 1.3 (I don't know if there's a schedule for that yet). Simon Roby suggested the same API as you did above. I was not wild about it, because it makes it harder/more error-prone to specify a fallback default resolution, which is particularly important when the functionality isn't implemented for all the SDL platforms/video drivers. Sam Lantinga (lead developer of SDL) chimed in that he likes the idea of using 0,0 in SDL_SetVideoMode to specify the desktop resolution, which can be done now, in SDL 1.2. He also likes the idea of adding the desktop resolution to SDL_VideoInfo at a later date. So, it seems like it would be sensible for me to rewrite my patch to use the 0,0 API, make sure it's documented well to minimise problems, and accept a little ugliness in our application code which can be removed when SDL 1.3 is available. I'll get to work on it, since Ryan just made a call for patches, and that would seem like a good chance of getting my code commited and in the next release. -- Jon Created attachment 54 [details]
dm-cvs-20050124144500.diff.txt
Here's Jon's patch to add this function to the API
Ryan, is there value to adding an API function in addition to simply adding the information to the VideoInfo structure in 1.3? Adding to the structure is better, so long as it doesn't break binaries that expect it to be a certain size, which was what I was aiming to avoid...in this case, it's probably safe if you add it to the end of the struct. --ryan. (In reply to comment #7) > Adding to the structure is better, so long as it doesn't break binaries that > expect it to be a certain size, which was what I was aiming to avoid...in this > case, it's probably safe if you add it to the end of the struct. That seems reasonable. I'm tempted to add it to 1.3, since I can easily see that information followed up with requests to get/set the window position programmatically - one of the items on the 1.3 TODO list. What do you think? Yeah, I think that's a good 1.3 candidate. --ryan. Added current_w and current_h to the SDL_VideoInfo structure, which is set to the desktop resolution during video intialization, and then set to the current resolution when a video mode is set. SDL_SetVideoMode() now accepts 0 for width or height and will use the current video mode (or the desktop mode if no mode has been set.) We can add something like SDL_GetDesktopResolution() for 1.3, so I'll leave this bug open, and move it to a 1.3 API request. SDL_GetDesktopDisplayMode() is in for SDL 1.3 |
It would be nice if the application can determine what the current desktop resolution is, which can be useful as a default, or at least a known-good quantity. My current proposal looks something like this: int SDL_GetCurrentResolution(SDL_Rect *physical, SDL_Rect *virtual); On success, (physical) will be the physical resolution of the display at the time of the call, and (virtual) will be filled with the "virtual" resolution (i.e. - an X11 desktop bigger than the physical display that scrolls as the mouse moves around it, etc). Either parameter may be NULL, in which case that parameter won't receive a value. returns -1 on error (unsupported, hardware error, etc)...use SDL_GetError() for reason for failure. Returns 0 on success. Issues: - What to do with multimonitor support? - Is virtual resolution really useful? - Should this report the resolution at that moment? Should it change with a successful call to SDL_SetVideoMode(..., SDL_FULLSCREEN)? - What drivers can actually support this? --ryan.