|
|
|
@ -41,21 +41,21 @@ |
|
|
|
|
// Convert BPP to RGB bits (based on "best guess")
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
static void BPP2RGB( int bpp, int *r, int *g, int *b ) |
|
|
|
|
static void BPP2RGB(int bpp, int *r, int *g, int *b) |
|
|
|
|
{ |
|
|
|
|
int delta; |
|
|
|
|
|
|
|
|
|
// Special case: BPP = 32 (I don't think this is necessary for X11??)
|
|
|
|
|
if( bpp == 32 ) |
|
|
|
|
if (bpp == 32) |
|
|
|
|
bpp = 24; |
|
|
|
|
|
|
|
|
|
// Convert "bits per pixel" to red, green & blue sizes
|
|
|
|
|
*r = *g = *b = bpp / 3; |
|
|
|
|
delta = bpp - (*r * 3); |
|
|
|
|
if( delta >= 1 ) |
|
|
|
|
if (delta >= 1) |
|
|
|
|
*g = *g + 1; |
|
|
|
|
|
|
|
|
|
if( delta == 2 ) |
|
|
|
|
if (delta == 2) |
|
|
|
|
*r = *r + 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -64,9 +64,9 @@ static void BPP2RGB( int bpp, int *r, int *g, int *b ) |
|
|
|
|
// Finds the video mode closest in size to the specified desired size
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
int _glfwGetClosestVideoMode( int screen, int *width, int *height, int *rate ) |
|
|
|
|
int _glfwGetClosestVideoMode(int screen, int *width, int *height, int *rate) |
|
|
|
|
{ |
|
|
|
|
#if defined( _GLFW_HAS_XRANDR ) |
|
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
int i, match, bestmatch; |
|
|
|
|
int sizecount, bestsize; |
|
|
|
|
int ratecount, bestrate; |
|
|
|
@ -74,107 +74,107 @@ int _glfwGetClosestVideoMode( int screen, int *width, int *height, int *rate ) |
|
|
|
|
XRRScreenConfiguration *sc; |
|
|
|
|
XRRScreenSize *sizelist; |
|
|
|
|
|
|
|
|
|
if( _glfwLibrary.XRandR.available ) |
|
|
|
|
if (_glfwLibrary.XRandR.available) |
|
|
|
|
{ |
|
|
|
|
sc = XRRGetScreenInfo( _glfwLibrary.display, |
|
|
|
|
RootWindow( _glfwLibrary.display, screen ) ); |
|
|
|
|
sc = XRRGetScreenInfo(_glfwLibrary.display, |
|
|
|
|
RootWindow(_glfwLibrary.display, screen)); |
|
|
|
|
|
|
|
|
|
sizelist = XRRConfigSizes( sc, &sizecount ); |
|
|
|
|
sizelist = XRRConfigSizes(sc, &sizecount); |
|
|
|
|
|
|
|
|
|
// Find the best matching mode
|
|
|
|
|
bestsize = -1; |
|
|
|
|
bestmatch = INT_MAX; |
|
|
|
|
for( i = 0; i < sizecount; i++ ) |
|
|
|
|
for (i = 0; i < sizecount; i++) |
|
|
|
|
{ |
|
|
|
|
match = (*width - sizelist[i].width) * |
|
|
|
|
(*width - sizelist[i].width) + |
|
|
|
|
(*height - sizelist[i].height) * |
|
|
|
|
(*height - sizelist[i].height); |
|
|
|
|
if( match < bestmatch ) |
|
|
|
|
if (match < bestmatch) |
|
|
|
|
{ |
|
|
|
|
bestmatch = match; |
|
|
|
|
bestsize = i; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( bestsize != -1 ) |
|
|
|
|
if (bestsize != -1) |
|
|
|
|
{ |
|
|
|
|
// Report width & height of best matching mode
|
|
|
|
|
*width = sizelist[bestsize].width; |
|
|
|
|
*height = sizelist[bestsize].height; |
|
|
|
|
|
|
|
|
|
if( *rate > 0 ) |
|
|
|
|
if (*rate > 0) |
|
|
|
|
{ |
|
|
|
|
ratelist = XRRConfigRates( sc, bestsize, &ratecount ); |
|
|
|
|
ratelist = XRRConfigRates(sc, bestsize, &ratecount); |
|
|
|
|
|
|
|
|
|
bestrate = -1; |
|
|
|
|
bestmatch = INT_MAX; |
|
|
|
|
for( i = 0; i < ratecount; i++ ) |
|
|
|
|
for (i = 0; i < ratecount; i++) |
|
|
|
|
{ |
|
|
|
|
match = abs( ratelist[i] - *rate ); |
|
|
|
|
if( match < bestmatch ) |
|
|
|
|
match = abs(ratelist[i] - *rate); |
|
|
|
|
if (match < bestmatch) |
|
|
|
|
{ |
|
|
|
|
bestmatch = match; |
|
|
|
|
bestrate = ratelist[i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( bestrate != -1 ) |
|
|
|
|
if (bestrate != -1) |
|
|
|
|
*rate = bestrate; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Free modelist
|
|
|
|
|
XRRFreeScreenConfigInfo( sc ); |
|
|
|
|
XRRFreeScreenConfigInfo(sc); |
|
|
|
|
|
|
|
|
|
if( bestsize != -1 ) |
|
|
|
|
if (bestsize != -1) |
|
|
|
|
return bestsize; |
|
|
|
|
} |
|
|
|
|
#elif defined( _GLFW_HAS_XF86VIDMODE ) |
|
|
|
|
#elif defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
XF86VidModeModeInfo **modelist; |
|
|
|
|
int modecount, i, bestmode, bestmatch, match; |
|
|
|
|
|
|
|
|
|
// Use the XF86VidMode extension to control video resolution
|
|
|
|
|
if( _glfwLibrary.XF86VidMode.available ) |
|
|
|
|
if (_glfwLibrary.XF86VidMode.available) |
|
|
|
|
{ |
|
|
|
|
// Get a list of all available display modes
|
|
|
|
|
XF86VidModeGetAllModeLines( _glfwLibrary.display, screen, |
|
|
|
|
&modecount, &modelist ); |
|
|
|
|
XF86VidModeGetAllModeLines(_glfwLibrary.display, screen, |
|
|
|
|
&modecount, &modelist); |
|
|
|
|
|
|
|
|
|
// Find the best matching mode
|
|
|
|
|
bestmode = -1; |
|
|
|
|
bestmatch = INT_MAX; |
|
|
|
|
for( i = 0; i < modecount; i++ ) |
|
|
|
|
for (i = 0; i < modecount; i++) |
|
|
|
|
{ |
|
|
|
|
match = (*width - modelist[i]->hdisplay) * |
|
|
|
|
(*width - modelist[i]->hdisplay) + |
|
|
|
|
(*height - modelist[i]->vdisplay) * |
|
|
|
|
(*height - modelist[i]->vdisplay); |
|
|
|
|
if( match < bestmatch ) |
|
|
|
|
if (match < bestmatch) |
|
|
|
|
{ |
|
|
|
|
bestmatch = match; |
|
|
|
|
bestmode = i; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( bestmode != -1 ) |
|
|
|
|
if (bestmode != -1) |
|
|
|
|
{ |
|
|
|
|
// Report width & height of best matching mode
|
|
|
|
|
*width = modelist[ bestmode ]->hdisplay; |
|
|
|
|
*height = modelist[ bestmode ]->vdisplay; |
|
|
|
|
*width = modelist[bestmode]->hdisplay; |
|
|
|
|
*height = modelist[bestmode]->vdisplay; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Free modelist
|
|
|
|
|
XFree( modelist ); |
|
|
|
|
XFree(modelist); |
|
|
|
|
|
|
|
|
|
if( bestmode != -1 ) |
|
|
|
|
if (bestmode != -1) |
|
|
|
|
return bestmode; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Default: Simply use the screen resolution
|
|
|
|
|
*width = DisplayWidth( _glfwLibrary.display, screen ); |
|
|
|
|
*height = DisplayHeight( _glfwLibrary.display, screen ); |
|
|
|
|
*width = DisplayWidth(_glfwLibrary.display, screen); |
|
|
|
|
*height = DisplayHeight(_glfwLibrary.display, screen); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
@ -184,85 +184,85 @@ int _glfwGetClosestVideoMode( int screen, int *width, int *height, int *rate ) |
|
|
|
|
// Change the current video mode
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwSetVideoModeMODE( int screen, int mode, int rate ) |
|
|
|
|
void _glfwSetVideoModeMODE(int screen, int mode, int rate) |
|
|
|
|
{ |
|
|
|
|
#if defined( _GLFW_HAS_XRANDR ) |
|
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
XRRScreenConfiguration *sc; |
|
|
|
|
Window root; |
|
|
|
|
|
|
|
|
|
if( _glfwLibrary.XRandR.available ) |
|
|
|
|
if (_glfwLibrary.XRandR.available) |
|
|
|
|
{ |
|
|
|
|
root = RootWindow( _glfwLibrary.display, screen ); |
|
|
|
|
sc = XRRGetScreenInfo( _glfwLibrary.display, root ); |
|
|
|
|
root = RootWindow(_glfwLibrary.display, screen); |
|
|
|
|
sc = XRRGetScreenInfo(_glfwLibrary.display, root); |
|
|
|
|
|
|
|
|
|
// Remember old size and flag that we have changed the mode
|
|
|
|
|
if( !_glfwWin.FS.modeChanged ) |
|
|
|
|
if (!_glfwWin.FS.modeChanged) |
|
|
|
|
{ |
|
|
|
|
_glfwWin.FS.oldSizeID = XRRConfigCurrentConfiguration( sc, &_glfwWin.FS.oldRotation ); |
|
|
|
|
_glfwWin.FS.oldWidth = DisplayWidth( _glfwLibrary.display, screen ); |
|
|
|
|
_glfwWin.FS.oldHeight = DisplayHeight( _glfwLibrary.display, screen ); |
|
|
|
|
_glfwWin.FS.oldSizeID = XRRConfigCurrentConfiguration(sc, &_glfwWin.FS.oldRotation); |
|
|
|
|
_glfwWin.FS.oldWidth = DisplayWidth(_glfwLibrary.display, screen); |
|
|
|
|
_glfwWin.FS.oldHeight = DisplayHeight(_glfwLibrary.display, screen); |
|
|
|
|
|
|
|
|
|
_glfwWin.FS.modeChanged = GL_TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( rate > 0 ) |
|
|
|
|
if (rate > 0) |
|
|
|
|
{ |
|
|
|
|
// Set desired configuration
|
|
|
|
|
XRRSetScreenConfigAndRate( _glfwLibrary.display, |
|
|
|
|
sc, |
|
|
|
|
root, |
|
|
|
|
mode, |
|
|
|
|
RR_Rotate_0, |
|
|
|
|
(short) rate, |
|
|
|
|
CurrentTime ); |
|
|
|
|
XRRSetScreenConfigAndRate(_glfwLibrary.display, |
|
|
|
|
sc, |
|
|
|
|
root, |
|
|
|
|
mode, |
|
|
|
|
RR_Rotate_0, |
|
|
|
|
(short) rate, |
|
|
|
|
CurrentTime); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Set desired configuration
|
|
|
|
|
XRRSetScreenConfig( _glfwLibrary.display, |
|
|
|
|
sc, |
|
|
|
|
root, |
|
|
|
|
mode, |
|
|
|
|
RR_Rotate_0, |
|
|
|
|
CurrentTime ); |
|
|
|
|
XRRSetScreenConfig(_glfwLibrary.display, |
|
|
|
|
sc, |
|
|
|
|
root, |
|
|
|
|
mode, |
|
|
|
|
RR_Rotate_0, |
|
|
|
|
CurrentTime); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
XRRFreeScreenConfigInfo( sc ); |
|
|
|
|
XRRFreeScreenConfigInfo(sc); |
|
|
|
|
} |
|
|
|
|
#elif defined( _GLFW_HAS_XF86VIDMODE ) |
|
|
|
|
#elif defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
XF86VidModeModeInfo **modelist; |
|
|
|
|
int modecount; |
|
|
|
|
|
|
|
|
|
// Use the XF86VidMode extension to control video resolution
|
|
|
|
|
if( _glfwLibrary.XF86VidMode.available ) |
|
|
|
|
if (_glfwLibrary.XF86VidMode.available) |
|
|
|
|
{ |
|
|
|
|
// Get a list of all available display modes
|
|
|
|
|
XF86VidModeGetAllModeLines( _glfwLibrary.display, screen, |
|
|
|
|
&modecount, &modelist ); |
|
|
|
|
XF86VidModeGetAllModeLines(_glfwLibrary.display, screen, |
|
|
|
|
&modecount, &modelist); |
|
|
|
|
|
|
|
|
|
// Unlock mode switch if necessary
|
|
|
|
|
if( _glfwWin.FS.modeChanged ) |
|
|
|
|
XF86VidModeLockModeSwitch( _glfwLibrary.display, screen, 0 ); |
|
|
|
|
if (_glfwWin.FS.modeChanged) |
|
|
|
|
XF86VidModeLockModeSwitch(_glfwLibrary.display, screen, 0); |
|
|
|
|
|
|
|
|
|
// Change the video mode to the desired mode
|
|
|
|
|
XF86VidModeSwitchToMode( _glfwLibrary.display, screen, |
|
|
|
|
modelist[ mode ] ); |
|
|
|
|
XF86VidModeSwitchToMode(_glfwLibrary.display, screen, |
|
|
|
|
modelist[mode]); |
|
|
|
|
|
|
|
|
|
// Set viewport to upper left corner (where our window will be)
|
|
|
|
|
XF86VidModeSetViewPort( _glfwLibrary.display, screen, 0, 0 ); |
|
|
|
|
XF86VidModeSetViewPort(_glfwLibrary.display, screen, 0, 0); |
|
|
|
|
|
|
|
|
|
// Lock mode switch
|
|
|
|
|
XF86VidModeLockModeSwitch( _glfwLibrary.display, screen, 1 ); |
|
|
|
|
XF86VidModeLockModeSwitch(_glfwLibrary.display, screen, 1); |
|
|
|
|
|
|
|
|
|
// Remember old mode and flag that we have changed the mode
|
|
|
|
|
if( !_glfwWin.FS.modeChanged ) |
|
|
|
|
if (!_glfwWin.FS.modeChanged) |
|
|
|
|
{ |
|
|
|
|
_glfwWin.FS.oldMode = *modelist[ 0 ]; |
|
|
|
|
_glfwWin.FS.oldMode = *modelist[0]; |
|
|
|
|
_glfwWin.FS.modeChanged = GL_TRUE; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Free mode list
|
|
|
|
|
XFree( modelist ); |
|
|
|
|
XFree(modelist); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
@ -272,15 +272,15 @@ void _glfwSetVideoModeMODE( int screen, int mode, int rate ) |
|
|
|
|
// Change the current video mode
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwSetVideoMode( int screen, int *width, int *height, int *rate ) |
|
|
|
|
void _glfwSetVideoMode(int screen, int *width, int *height, int *rate) |
|
|
|
|
{ |
|
|
|
|
int bestmode; |
|
|
|
|
|
|
|
|
|
// Find a best match mode
|
|
|
|
|
bestmode = _glfwGetClosestVideoMode( screen, width, height, rate ); |
|
|
|
|
bestmode = _glfwGetClosestVideoMode(screen, width, height, rate); |
|
|
|
|
|
|
|
|
|
// Change mode
|
|
|
|
|
_glfwSetVideoModeMODE( screen, bestmode, *rate ); |
|
|
|
|
_glfwSetVideoModeMODE(screen, bestmode, *rate); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -288,39 +288,39 @@ void _glfwSetVideoMode( int screen, int *width, int *height, int *rate ) |
|
|
|
|
// Restore the previously saved (original) video mode
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwRestoreVideoMode( void ) |
|
|
|
|
void _glfwRestoreVideoMode(void) |
|
|
|
|
{ |
|
|
|
|
if( _glfwWin.FS.modeChanged ) |
|
|
|
|
if (_glfwWin.FS.modeChanged) |
|
|
|
|
{ |
|
|
|
|
#if defined( _GLFW_HAS_XRANDR ) |
|
|
|
|
if( _glfwLibrary.XRandR.available ) |
|
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
if (_glfwLibrary.XRandR.available) |
|
|
|
|
{ |
|
|
|
|
XRRScreenConfiguration *sc; |
|
|
|
|
|
|
|
|
|
if( _glfwLibrary.XRandR.available ) |
|
|
|
|
if (_glfwLibrary.XRandR.available) |
|
|
|
|
{ |
|
|
|
|
sc = XRRGetScreenInfo( _glfwLibrary.display, _glfwWin.root ); |
|
|
|
|
sc = XRRGetScreenInfo(_glfwLibrary.display, _glfwWin.root); |
|
|
|
|
|
|
|
|
|
XRRSetScreenConfig( _glfwLibrary.display, |
|
|
|
|
sc, |
|
|
|
|
_glfwWin.root, |
|
|
|
|
_glfwWin.FS.oldSizeID, |
|
|
|
|
_glfwWin.FS.oldRotation, |
|
|
|
|
CurrentTime ); |
|
|
|
|
XRRSetScreenConfig(_glfwLibrary.display, |
|
|
|
|
sc, |
|
|
|
|
_glfwWin.root, |
|
|
|
|
_glfwWin.FS.oldSizeID, |
|
|
|
|
_glfwWin.FS.oldRotation, |
|
|
|
|
CurrentTime); |
|
|
|
|
|
|
|
|
|
XRRFreeScreenConfigInfo( sc ); |
|
|
|
|
XRRFreeScreenConfigInfo(sc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#elif defined( _GLFW_HAS_XF86VIDMODE ) |
|
|
|
|
if( _glfwLibrary.XF86VidMode.available ) |
|
|
|
|
#elif defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
if (_glfwLibrary.XF86VidMode.available) |
|
|
|
|
{ |
|
|
|
|
// Unlock mode switch
|
|
|
|
|
XF86VidModeLockModeSwitch( _glfwLibrary.display, _glfwWin.screen, 0 ); |
|
|
|
|
XF86VidModeLockModeSwitch(_glfwLibrary.display, _glfwWin.screen, 0); |
|
|
|
|
|
|
|
|
|
// Change the video mode back to the old mode
|
|
|
|
|
XF86VidModeSwitchToMode( _glfwLibrary.display, |
|
|
|
|
XF86VidModeSwitchToMode(_glfwLibrary.display, |
|
|
|
|
_glfwWin.screen, |
|
|
|
|
&_glfwWin.FS.oldMode ); |
|
|
|
|
&_glfwWin.FS.oldMode); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
_glfwWin.FS.modeChanged = GL_FALSE; |
|
|
|
@ -343,7 +343,7 @@ struct _glfwResolution |
|
|
|
|
// List available video modes
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) |
|
|
|
|
int _glfwPlatformGetVideoModes(GLFWvidmode *list, int maxcount) |
|
|
|
|
{ |
|
|
|
|
int count, k, l, r, g, b, rgba, gl; |
|
|
|
|
int depth, screen; |
|
|
|
@ -352,52 +352,52 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) |
|
|
|
|
int viscount, rgbcount, rescount; |
|
|
|
|
int *rgbarray; |
|
|
|
|
struct _glfwResolution *resarray; |
|
|
|
|
#if defined( _GLFW_HAS_XRANDR ) |
|
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
XRRScreenConfiguration *sc; |
|
|
|
|
XRRScreenSize *sizelist; |
|
|
|
|
int sizecount; |
|
|
|
|
#elif defined( _GLFW_HAS_XF86VIDMODE ) |
|
|
|
|
#elif defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
XF86VidModeModeInfo **modelist; |
|
|
|
|
int modecount, width, height; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Get display and screen
|
|
|
|
|
dpy = _glfwLibrary.display; |
|
|
|
|
screen = DefaultScreen( dpy ); |
|
|
|
|
screen = DefaultScreen(dpy); |
|
|
|
|
|
|
|
|
|
// Get list of visuals
|
|
|
|
|
vislist = XGetVisualInfo( dpy, 0, &dummy, &viscount ); |
|
|
|
|
if( vislist == NULL ) |
|
|
|
|
vislist = XGetVisualInfo(dpy, 0, &dummy, &viscount); |
|
|
|
|
if (vislist == NULL) |
|
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
rgbarray = (int*) malloc( sizeof(int) * viscount ); |
|
|
|
|
rgbarray = (int*) malloc(sizeof(int) * viscount); |
|
|
|
|
rgbcount = 0; |
|
|
|
|
|
|
|
|
|
// Build RGB array
|
|
|
|
|
for( k = 0; k < viscount; k++ ) |
|
|
|
|
for (k = 0; k < viscount; k++) |
|
|
|
|
{ |
|
|
|
|
// Does the visual support OpenGL & true color?
|
|
|
|
|
glXGetConfig( dpy, &vislist[k], GLX_USE_GL, &gl ); |
|
|
|
|
glXGetConfig( dpy, &vislist[k], GLX_RGBA, &rgba ); |
|
|
|
|
if( gl && rgba ) |
|
|
|
|
glXGetConfig(dpy, &vislist[k], GLX_USE_GL, &gl); |
|
|
|
|
glXGetConfig(dpy, &vislist[k], GLX_RGBA, &rgba); |
|
|
|
|
if (gl && rgba) |
|
|
|
|
{ |
|
|
|
|
// Get color depth for this visual
|
|
|
|
|
depth = vislist[k].depth; |
|
|
|
|
|
|
|
|
|
// Convert to RGB
|
|
|
|
|
BPP2RGB( depth, &r, &g, &b ); |
|
|
|
|
depth = (r<<16) | (g<<8) | b; |
|
|
|
|
BPP2RGB(depth, &r, &g, &b); |
|
|
|
|
depth = (r << 16) | (g << 8) | b; |
|
|
|
|
|
|
|
|
|
// Is this mode unique?
|
|
|
|
|
for( l = 0; l < rgbcount; l++ ) |
|
|
|
|
for (l = 0; l < rgbcount; l++) |
|
|
|
|
{ |
|
|
|
|
if( depth == rgbarray[ l ] ) |
|
|
|
|
if (depth == rgbarray[l]) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( l >= rgbcount ) |
|
|
|
|
if (l >= rgbcount) |
|
|
|
|
{ |
|
|
|
|
rgbarray[ rgbcount ] = depth; |
|
|
|
|
rgbarray[rgbcount] = depth; |
|
|
|
|
rgbcount++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -407,83 +407,83 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) |
|
|
|
|
resarray = NULL; |
|
|
|
|
|
|
|
|
|
// Build resolution array
|
|
|
|
|
#if defined( _GLFW_HAS_XRANDR ) |
|
|
|
|
if( _glfwLibrary.XRandR.available ) |
|
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
if (_glfwLibrary.XRandR.available) |
|
|
|
|
{ |
|
|
|
|
sc = XRRGetScreenInfo( dpy, RootWindow( dpy, screen ) ); |
|
|
|
|
sizelist = XRRConfigSizes( sc, &sizecount ); |
|
|
|
|
sc = XRRGetScreenInfo(dpy, RootWindow(dpy, screen)); |
|
|
|
|
sizelist = XRRConfigSizes(sc, &sizecount); |
|
|
|
|
|
|
|
|
|
resarray = (struct _glfwResolution*) malloc( sizeof(struct _glfwResolution) * sizecount ); |
|
|
|
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * sizecount); |
|
|
|
|
|
|
|
|
|
for( k = 0; k < sizecount; k++ ) |
|
|
|
|
for (k = 0; k < sizecount; k++) |
|
|
|
|
{ |
|
|
|
|
resarray[ rescount ].width = sizelist[ k ].width; |
|
|
|
|
resarray[ rescount ].height = sizelist[ k ].height; |
|
|
|
|
resarray[rescount].width = sizelist[k].width; |
|
|
|
|
resarray[rescount].height = sizelist[k].height; |
|
|
|
|
rescount++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
XRRFreeScreenConfigInfo( sc ); |
|
|
|
|
XRRFreeScreenConfigInfo(sc); |
|
|
|
|
} |
|
|
|
|
#elif defined( _GLFW_HAS_XF86VIDMODE ) |
|
|
|
|
if( _glfwLibrary.XF86VidMode.available ) |
|
|
|
|
#elif defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
if (_glfwLibrary.XF86VidMode.available) |
|
|
|
|
{ |
|
|
|
|
XF86VidModeGetAllModeLines( dpy, screen, &modecount, &modelist ); |
|
|
|
|
XF86VidModeGetAllModeLines(dpy, screen, &modecount, &modelist); |
|
|
|
|
|
|
|
|
|
resarray = (struct _glfwResolution*) malloc( sizeof(struct _glfwResolution) * modecount ); |
|
|
|
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * modecount); |
|
|
|
|
|
|
|
|
|
for( k = 0; k < modecount; k++ ) |
|
|
|
|
for (k = 0; k < modecount; k++) |
|
|
|
|
{ |
|
|
|
|
width = modelist[ k ]->hdisplay; |
|
|
|
|
height = modelist[ k ]->vdisplay; |
|
|
|
|
width = modelist[k]->hdisplay; |
|
|
|
|
height = modelist[k]->vdisplay; |
|
|
|
|
|
|
|
|
|
// Is this mode unique?
|
|
|
|
|
for( l = 0; l < rescount; l++ ) |
|
|
|
|
for (l = 0; l < rescount; l++) |
|
|
|
|
{ |
|
|
|
|
if( width == resarray[ l ].width && height == resarray[ l ].height ) |
|
|
|
|
if (width == resarray[l].width && height == resarray[l].height) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if( l >= rescount ) |
|
|
|
|
if (l >= rescount) |
|
|
|
|
{ |
|
|
|
|
resarray[ rescount ].width = width; |
|
|
|
|
resarray[ rescount ].height = height; |
|
|
|
|
resarray[rescount].width = width; |
|
|
|
|
resarray[rescount].height = height; |
|
|
|
|
rescount++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
XFree( modelist ); |
|
|
|
|
XFree(modelist); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
if( !resarray ) |
|
|
|
|
if (!resarray) |
|
|
|
|
{ |
|
|
|
|
rescount = 1; |
|
|
|
|
resarray = (struct _glfwResolution*) malloc( sizeof(struct _glfwResolution) * rescount ); |
|
|
|
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * rescount); |
|
|
|
|
|
|
|
|
|
resarray[ 0 ].width = DisplayWidth( dpy, screen ); |
|
|
|
|
resarray[ 0 ].height = DisplayHeight( dpy, screen ); |
|
|
|
|
resarray[ 0 ].width = DisplayWidth(dpy, screen); |
|
|
|
|
resarray[ 0 ].height = DisplayHeight(dpy, screen); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Build permutations of colors and resolutions
|
|
|
|
|
count = 0; |
|
|
|
|
for( k = 0; k < rgbcount && count < maxcount; k++ ) |
|
|
|
|
for (k = 0; k < rgbcount && count < maxcount; k++) |
|
|
|
|
{ |
|
|
|
|
for( l = 0; l < rescount && count < maxcount; l++ ) |
|
|
|
|
for (l = 0; l < rescount && count < maxcount; l++) |
|
|
|
|
{ |
|
|
|
|
list[count].Width = resarray[ l ].width; |
|
|
|
|
list[count].Height = resarray[ l ].height; |
|
|
|
|
list[count].RedBits = (rgbarray[ k ] >> 16) & 255; |
|
|
|
|
list[count].GreenBits = (rgbarray[ k ] >> 8) & 255; |
|
|
|
|
list[count].BlueBits = rgbarray[ k ] & 255; |
|
|
|
|
list[count].Width = resarray[l].width; |
|
|
|
|
list[count].Height = resarray[l].height; |
|
|
|
|
list[count].RedBits = (rgbarray[k] >> 16) & 255; |
|
|
|
|
list[count].GreenBits = (rgbarray[k] >> 8) & 255; |
|
|
|
|
list[count].BlueBits = rgbarray[k] & 255; |
|
|
|
|
count++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Free visuals list
|
|
|
|
|
XFree( vislist ); |
|
|
|
|
XFree(vislist); |
|
|
|
|
|
|
|
|
|
free( resarray ); |
|
|
|
|
free( rgbarray ); |
|
|
|
|
free(resarray); |
|
|
|
|
free(rgbarray); |
|
|
|
|
|
|
|
|
|
return count; |
|
|
|
|
} |
|
|
|
@ -493,39 +493,39 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount ) |
|
|
|
|
// Get the desktop video mode
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
void _glfwPlatformGetDesktopMode( GLFWvidmode *mode ) |
|
|
|
|
void _glfwPlatformGetDesktopMode(GLFWvidmode *mode) |
|
|
|
|
{ |
|
|
|
|
Display *dpy; |
|
|
|
|
int bpp, screen; |
|
|
|
|
#if defined( _GLFW_HAS_XF86VIDMODE ) |
|
|
|
|
int bpp, screen; |
|
|
|
|
#if defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
XF86VidModeModeInfo **modelist; |
|
|
|
|
int modecount; |
|
|
|
|
int modecount; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Get display and screen
|
|
|
|
|
dpy = _glfwLibrary.display; |
|
|
|
|
screen = DefaultScreen( dpy ); |
|
|
|
|
screen = DefaultScreen(dpy); |
|
|
|
|
|
|
|
|
|
// Get display depth
|
|
|
|
|
bpp = DefaultDepth( dpy, screen ); |
|
|
|
|
bpp = DefaultDepth(dpy, screen); |
|
|
|
|
|
|
|
|
|
// Convert BPP to RGB bits
|
|
|
|
|
BPP2RGB( bpp, &mode->RedBits, &mode->GreenBits, &mode->BlueBits ); |
|
|
|
|
BPP2RGB(bpp, &mode->RedBits, &mode->GreenBits, &mode->BlueBits); |
|
|
|
|
|
|
|
|
|
#if defined( _GLFW_HAS_XRANDR ) |
|
|
|
|
if( _glfwLibrary.XRandR.available ) |
|
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
if (_glfwLibrary.XRandR.available) |
|
|
|
|
{ |
|
|
|
|
if( _glfwWin.FS.modeChanged ) |
|
|
|
|
if (_glfwWin.FS.modeChanged) |
|
|
|
|
{ |
|
|
|
|
mode->Width = _glfwWin.FS.oldWidth; |
|
|
|
|
mode->Height = _glfwWin.FS.oldHeight; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#elif defined( _GLFW_HAS_XF86VIDMODE ) |
|
|
|
|
if( _glfwLibrary.XF86VidMode.available ) |
|
|
|
|
#elif defined(_GLFW_HAS_XF86VIDMODE) |
|
|
|
|
if (_glfwLibrary.XF86VidMode.available) |
|
|
|
|
{ |
|
|
|
|
if( _glfwWin.FS.modeChanged ) |
|
|
|
|
if (_glfwWin.FS.modeChanged) |
|
|
|
|
{ |
|
|
|
|
// The old (desktop) mode is stored in _glfwWin.FS.oldMode
|
|
|
|
|
mode->Width = _glfwWin.FS.oldMode.hdisplay; |
|
|
|
@ -534,15 +534,14 @@ void _glfwPlatformGetDesktopMode( GLFWvidmode *mode ) |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Use the XF86VidMode extension to get list of video modes
|
|
|
|
|
XF86VidModeGetAllModeLines( dpy, screen, &modecount, |
|
|
|
|
&modelist ); |
|
|
|
|
XF86VidModeGetAllModeLines(dpy, screen, &modecount, &modelist); |
|
|
|
|
|
|
|
|
|
// The first mode in the list is the current (desktio) mode
|
|
|
|
|
mode->Width = modelist[ 0 ]->hdisplay; |
|
|
|
|
mode->Height = modelist[ 0 ]->vdisplay; |
|
|
|
|
mode->Width = modelist[0]->hdisplay; |
|
|
|
|
mode->Height = modelist[0]->vdisplay; |
|
|
|
|
|
|
|
|
|
// Free list
|
|
|
|
|
XFree( modelist ); |
|
|
|
|
XFree(modelist); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return; |
|
|
|
@ -550,7 +549,7 @@ void _glfwPlatformGetDesktopMode( GLFWvidmode *mode ) |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Get current display width and height
|
|
|
|
|
mode->Width = DisplayWidth( dpy, screen ); |
|
|
|
|
mode->Height = DisplayHeight( dpy, screen ); |
|
|
|
|
mode->Width = DisplayWidth(dpy, screen); |
|
|
|
|
mode->Height = DisplayHeight(dpy, screen); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|