PDA

View Full Version : get available screen resolution ?



Yogix
03-22-2002, 01:43 AM
me = Linux newbie ;P

How can I get the availables resolutions supported by my 3D card under Linux ?
(with C++ code)

martin_marinov
03-22-2002, 09:50 AM
Hi,
Probably one way to do this is to scan the XF86Config file, which can be found in /etc/X11/. But this doesn't seem very nice solution for me. Try searching www.xfree.org (http://www.xfree.org) for additional info.
Regards
Martin

[This message has been edited by martin_marinov (edited 03-22-2002).]

03-23-2002, 03:04 PM
there was aa news entry about clanlib -> clanlib.org...

wathc out there, load the sources and then look for file x11_resolution.cpp
-> there are 3 functions of XF86, which are used to get the extension-availability, the modes and to switch the mode...

hope i could help you

03-24-2002, 05:59 AM
You can only switch to resolutions that is mentioned in the XF86Config-4 file. This is an xfree86 extensions so it will not be portable. In the extension header file do you also find functions for other things like gamma correction.

The GLX ports of NeHes tutorials shows how to use the XFree86-VidModeExtension. Use the XF86VidModeGetAllModeLines function to get the available resolutions. Here is a little program :



#include <stdio.h>
#include <X11/Xlib.h>
#include <X11/extensions/xf86vmode.h>

int main()
{
Display *dpy;
XF86VidModeModeInfo **modes;
int nr_modes, i;

dpy=XOpenDisplay(0);
XF86VidModeGetAllModeLines(dpy, DefaultScreen(dpy), &amp;nr_modes, &amp;modes);
for (i=0; i<nr_modes; i++) {
printf("%dx%d\n", modes[i]->hdisplay, modes[i]->vdisplay);
}
XFree(modes);
return 0;
}

Yogix
03-25-2002, 01:29 AM
it works fine !

Thanks !