I suppose it would be better as such (note: SDL’s event pump should be able
to handle the number of monitors and their respective rectangles):
int SDL_GetNumMonitors( void );
int SDL_GetMonitorRect( int monitor, SDL_Rect *rect );
int num = SDL_GetNumMonitors();
SDL_Rect monitor2;
if( SDL_GetMonitorRect( 2, &monitor2 ) )
printf( “Monitor 2: position=%d,%d size=%d,%d\r\n”, monitor2.x,
monitor2.y, monitor2.w, monitor2.h );
So, as an improvement from my original suggestion:
Internally, SDL should be able to track and store information about the
number of monitors and their resolutions. As Serjan noted, ya, this is also
good for irregular monitor setups (maybe two monitors side-by-side and one
monitor above the two).
It would be easy to implement a function that converts coordinates relative
to a monitor rectangle - maybe that should be left on the individual
programmer’s end, though.
This shouldn’t be overly intrustive on SDL’s already implemented API, and is
fairly simple. I have some old code for windows that could be repurposed,
but I’m not overly familiar with linux/mac code for that, though.
Thoughts?On Fri, Jan 7, 2011 at 3:50 PM, SmartUser wrote:
I think the suggestion of Alex makes sense due to the fact that monitors
can be in either horizontal or vertical positions and can be even mixed.
Also an advantage of his system is that monitors don’t need to be positioned
next to each other (a thing that might occur if you have multiple machines).
At work we have had up to 13 monitor setups with multiple machines and
sometimes monitors where scrambled (not sure if it needs to be taken into
account). On the other hand why not take these things into account when you
can (as is already the case with the system of Alex). It might be usefull to
have one big rectangle for ease of use but in some occations things might
end up outside some monitor its co?rdinates.
I’ll hope this helps you to advance your great library.
Regards,
Serjan
On Fri, Jan 7, 2011 at 8:14 PM, Terry Welsh wrote:
Message: 3
Date: Fri, 7 Jan 2011 07:50:29 -0800
From: Sam Lantinga
To: SDL
Subject: [SDL] Multi-monitor window coordinates
Message-ID:
<AANLkTi=AeZGjQgOrqe8bW1g3sf8Hk_s=B-A1xqLM4SS- at mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Right now SDL treats each display as a separate object with its own
coordinate system. SDL windows are strictly tied to a particular
display and have a renderer associated with that display.
Windows and Mac treat the displays as a unified coordinate system with
the upper left of the primary display being 0,0. Windows can be moved
freely between displays and the graphics drivers have to potentially
manage the complex task of resource management if a window spans
multiple displays and multiple video cards.
I’m thinking that unifying the display coordinate system is the way to
go, but I wanted to see if anyone had any thoughts on this.
My many Windows screensavers use Windows’s unified coordinate system.
It’s very simple code using just the x,y,w,h values that Windows gives
you. This seems to work well on most computers, but I still get
plenty of emails saying that the saver window opens up on only 1
monitor or across 1.5 or 2.5 monitors or just 1 row of pixels is
wrong. It’s all very random. I still don’t know a better or more
universal way to do multiple monitors, but I question its reliability.
I haven’t seen any of these problems on my own computers, so maybe
with all the developers here some of this will get figured out…
And having all the individual monitor coordinate systems is still a
must. Having GUI elements and other things that span monitors would
look really weird.
See ya!
? ? -Sam Lantinga, Founder and President, Galaxy Gameworks LLC
–
Terry Welsh
mogumbo ‘at’ gmail.com
www.reallyslick.com
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org