Screen size (win/unix)

Started by
6 comments, last by rechmbrs 17 years, 8 months ago
Under Windows I'm using the following: if ( EnumDisplaySettings ( NULL, ENUM_CURRENT_SETTINGS, &devmode ) ) { screen_width = devmode.dmPelsWidth; screen_height = devmode.dmPelsHeight; } to get the display screen size. Is it possible to get the display screen size on a MAC or Unix/Linux system? If so, how? Someplace I should look? Thanks, RON C
Advertisement
The code is platform-specific.

On Mac OS 9 and OS X, you probably want to use the Carbon APIs via functions such as CGDisplayPixelsWide or CGDisplayPixelsHigh

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Thanks. The reference is very useful.
Now for the UNIX side.

RON C
Unfortunately I think you would have to interact with X11, the library that contains what you want i believe is called Xlib. Although, what are you trying to do? because if you're trying to go fullscreen, I highly reccomend just using SDL, its cross platform and will do what you want.

hope that helps
-Dan

EDIT: Wikipedia has a good overview And there is the "Xlib manual" down in the works cited
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
Dan,

Thanks for the response.

I'm using the width/height to make sure the windows I open in opengl will fit. I rearrange if not.

What is needed in x11?

RON C
I asked around and apprently gdk_screen_get_width() gtk_screen_get_height() is probably your best bet, but that assumes gtk is present (as opposed to Qt) which means that people running GNOME will certainly have the function, wheras people on KDE won't necessarily (though its probably still a good bet). There IS a way to do it with X11 which everyone is GUARANTEED to have. I'm still looking for it though.

cheers
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out his new home he rounded a corner and saw someone in Marine Dress Blues. He ran back to St. Peter and yelled "You lied to me! There are Marines in heaven!" St. Peter said "Who him? That's just God. He wishes he were a Marine."
I don't think you should add GTK to your application only for display size. Take a look at XDisplayWidth, XDisplayHeight, GetDefaultDisplay, GetDefaultScreen functions of XLib (you can try `man XDisplayWidth` or google)

XLib is very hard to code for, but simply getting the display size shouldn't be that hard.

hope that helps !
Matt
lemurion,

Thanks.

I have it all coded and now will pass to the programmers on the specific systems.

You guys have been very helpful and especially quick.

RON C

This topic is closed to new replies.

Advertisement