oh, it’s already there.
But it doesn’t work without having any graphics context, ie. before opening any window, or using “window-type none” config.
On win32, the following works without involving any graphics API :
(adapted from gamedev.net/reference/articl … le1009.asp)
#include <windows.h>
#include <iostream>
#include <Python.h>
using namespace std;
static PyObject*
GetResolutions(PyObject* self, PyObject* args)
{
int minWidth=0, minHeight=0, minBitDepth=0, nModeExist;
if (PyTuple_Size(args)>0)
PyArg_ParseTuple(args,"iii", &minWidth, &minHeight, &minBitDepth);
cout <<"Checking for min resolution : "<<minWidth<<" x "<<minHeight<<" "<<minBitDepth
<<" bpp\nChecking for 60 Hz only\n\n";
DEVMODE devMode;
PyObject* modesList=PyList_New(0);
for (int i=0; ;i++)
{
nModeExist = EnumDisplaySettings(NULL, i, &devMode);
if (nModeExist != 1)
// End of modes. bail out.
break;
else if (devMode.dmPelsWidth>=minWidth &&
devMode.dmPelsHeight>=minHeight &&
devMode.dmBitsPerPel>=minBitDepth &&
devMode.dmDisplayFrequency==60 // <--- 60 Hz hard-coded
) {
// pack the bitdepth, width, height in a tuple
PyObject* mode =
PyTuple_Pack(3,
PyInt_FromLong(devMode.dmBitsPerPel),
PyInt_FromLong(devMode.dmPelsWidth),
PyInt_FromLong(devMode.dmPelsHeight)
);
// and add the tuple to the list
PyList_Append(modesList,mode);
}
}
// sort it prior to bitdepth, then resolution
PyList_Sort(modesList);
// reverse it so we get descending list
PyList_Reverse(modesList);
return modesList;
}
static PyMethodDef module_methods[ ] = {
{ "GetResolutions", ( PyCFunction ) GetResolutions, METH_VARARGS, "" },
{ NULL }
};
PyMODINIT_FUNC initVideoModes( void )
{
( void ) Py_InitModule( "VideoModes", module_methods );
}
ynjh.panda3dprojects.com/VideoMo … oModes.zip (it’s newbish C++ attempt)
usage :
import VideoModes
# result : a list of (bitdepth, width, height) tuples
vidModesList=VideoModes.GetResolutions( 640, 480, 16 ) # pass the minimum width, height, bitdepth
for m in vidModesList:
print '%i x %i (%i bpp)' %(m[1], m[2], m[0])
print '\n %i video resolutions available' %len(vidModesList)
[EDIT]:
1 more tiny thing, there is DisplaySearchParameters class.
Description : Parameters used for searching display capabilities.
How should I use it ?
I read the src and ShowBase.py, it doesn’t seem to be used anywhere.