Screen size (win/unix)
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
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
On Mac OS 9 and OS X, you probably want to use the Carbon APIs via functions such as CGDisplayPixelsWide or CGDisplayPixelsHigh
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
hope that helps
-Dan
EDIT: Wikipedia has a good overview And there is the "Xlib manual" down in the works cited
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
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
cheers
-Dan
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 !
XLib is very hard to code for, but simply getting the display size shouldn't be that hard.
hope that helps !
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement