Screen size (win/unix)

This topic is 4328 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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

Share on other sites
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

Share on other sites
Thanks. The reference is very useful.
Now for the UNIX side.

RON C

Share on other sites
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

Share on other sites
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

Share on other sites
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

Share on other sites
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 !

Share on other sites
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

• 38
• 12
• 10
• 10
• 9
• Forum Statistics

• Total Topics
631365
• Total Posts
2999585
×