Get available screen resolution?

me = Linux newbie :stuck_out_tongue_winking_eye:

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

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 for additional info.
Regards
Martin

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

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

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), &nr_modes, &modes);
for (i=0; i<nr_modes; i++) {
printf("%dx%d
", modes[i]->hdisplay, modes[i]->vdisplay);
}
XFree(modes);
return 0;
}

it works fine !

Thanks !

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.