|
|
@ -35,95 +35,6 @@ |
|
|
|
#include <string.h> |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Display resolution
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int width; |
|
|
|
|
|
|
|
int height; |
|
|
|
|
|
|
|
} _GLFWvidsize; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
// List available resolutions
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static _GLFWvidsize* getResolutions(_GLFWmonitor* monitor, int* found) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_GLFWvidsize* result = NULL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*found = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Build array of available resolutions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_glfwLibrary.X11.RandR.available) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
|
|
|
XRRScreenResources* sr; |
|
|
|
|
|
|
|
int i, j, count = monitor->X11.output->nmode; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sr = XRRGetScreenResources(_glfwLibrary.X11.display, |
|
|
|
|
|
|
|
_glfwLibrary.X11.root); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = (_GLFWvidsize*) malloc(sizeof(_GLFWvidsize) * count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_GLFWvidsize size; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < sr->nmode; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (sr->modes[j].id == monitor->X11.output->modes[i]) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (j == sr->nmode) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size.width = sr->modes[j].width; |
|
|
|
|
|
|
|
size.height = sr->modes[j].height; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < *found; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (result[j].width == size.width && |
|
|
|
|
|
|
|
result[j].height == size.height) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (j < *found) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// This is a duplicate, so skip it
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result[*found] = size; |
|
|
|
|
|
|
|
(*found)++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
XRRFreeScreenResources(sr); |
|
|
|
|
|
|
|
#endif /*_GLFW_HAS_XRANDR*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (result == NULL) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
*found = 1; |
|
|
|
|
|
|
|
result = (_GLFWvidsize*) malloc(sizeof(_GLFWvidsize)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result[0].width = DisplayWidth(_glfwLibrary.X11.display, |
|
|
|
|
|
|
|
_glfwLibrary.X11.screen); |
|
|
|
|
|
|
|
result[0].height = DisplayHeight(_glfwLibrary.X11.display, |
|
|
|
|
|
|
|
_glfwLibrary.X11.screen); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
////// GLFW internal API //////
|
|
|
|
////// GLFW internal API //////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
@ -423,85 +334,84 @@ void _glfwPlatformDestroyMonitor(_GLFWmonitor* monitor) |
|
|
|
|
|
|
|
|
|
|
|
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) |
|
|
|
GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found) |
|
|
|
{ |
|
|
|
{ |
|
|
|
XVisualInfo* visuals; |
|
|
|
|
|
|
|
XVisualInfo dummy; |
|
|
|
|
|
|
|
int i, j, visualCount, sizeCount, rgbCount; |
|
|
|
|
|
|
|
int* rgbs; |
|
|
|
|
|
|
|
_GLFWvidsize* sizes; |
|
|
|
|
|
|
|
GLFWvidmode* result; |
|
|
|
GLFWvidmode* result; |
|
|
|
|
|
|
|
int depth, r, g, b; |
|
|
|
|
|
|
|
|
|
|
|
visuals = XGetVisualInfo(_glfwLibrary.X11.display, 0, &dummy, &visualCount); |
|
|
|
depth = DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen); |
|
|
|
if (visuals == NULL) |
|
|
|
_glfwSplitBPP(depth, &r, &g, &b); |
|
|
|
{ |
|
|
|
|
|
|
|
_glfwSetError(GLFW_PLATFORM_ERROR, |
|
|
|
*found = 0; |
|
|
|
"X11: Failed to retrieve the available visuals"); |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rgbs = (int*) malloc(sizeof(int) * visualCount); |
|
|
|
// Build array of available resolutions
|
|
|
|
rgbCount = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_GLFW_GLX) |
|
|
|
if (_glfwLibrary.X11.RandR.available) |
|
|
|
for (i = 0; i < visualCount; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
int gl, rgba, rgb, r, g, b; |
|
|
|
#if defined(_GLFW_HAS_XRANDR) |
|
|
|
|
|
|
|
XRRScreenResources* sr; |
|
|
|
|
|
|
|
int i, j, count = monitor->X11.output->nmode; |
|
|
|
|
|
|
|
|
|
|
|
glXGetConfig(_glfwLibrary.X11.display, &visuals[i], GLX_USE_GL, &gl); |
|
|
|
sr = XRRGetScreenResources(_glfwLibrary.X11.display, |
|
|
|
glXGetConfig(_glfwLibrary.X11.display, &visuals[i], GLX_RGBA, &rgba); |
|
|
|
_glfwLibrary.X11.root); |
|
|
|
|
|
|
|
|
|
|
|
if (!gl || !rgba) |
|
|
|
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// The visual lacks OpenGL or true color, so skip it
|
|
|
|
GLFWvidmode mode; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < sr->nmode; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (sr->modes[j].id == monitor->X11.output->modes[i]) |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Convert to RGB channel depths and encode
|
|
|
|
if (j == sr->nmode) |
|
|
|
_glfwSplitBPP(visuals[i].depth, &r, &g, &b); |
|
|
|
continue; |
|
|
|
rgb = (r << 16) | (g << 8) | b; |
|
|
|
|
|
|
|
|
|
|
|
mode.width = sr->modes[j].width; |
|
|
|
|
|
|
|
mode.height = sr->modes[j].height; |
|
|
|
|
|
|
|
|
|
|
|
for (j = 0; j < rgbCount; j++) |
|
|
|
for (j = 0; j < *found; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (result[j].width == mode.width && |
|
|
|
|
|
|
|
result[j].height == mode.height) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (rgbs[j] == rgb) |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (j < rgbCount) |
|
|
|
if (j < *found) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// This channel depth is a duplicate, so skip it
|
|
|
|
// This is a duplicate, so skip it
|
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
rgbs[rgbCount] = rgb; |
|
|
|
mode.redBits = r; |
|
|
|
rgbCount++; |
|
|
|
mode.greenBits = g; |
|
|
|
} |
|
|
|
mode.blueBits = b; |
|
|
|
|
|
|
|
|
|
|
|
XFree(visuals); |
|
|
|
result[*found] = mode; |
|
|
|
#endif |
|
|
|
(*found)++; |
|
|
|
|
|
|
|
} |
|
|
|
// Build all permutations of channel depths and resolutions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sizes = getResolutions(monitor, &sizeCount); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * rgbCount * sizeCount); |
|
|
|
XRRFreeScreenResources(sr); |
|
|
|
*found = 0; |
|
|
|
#endif /*_GLFW_HAS_XRANDR*/ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < rgbCount; i++) |
|
|
|
if (result == NULL) |
|
|
|
{ |
|
|
|
|
|
|
|
for (j = 0; j < sizeCount; j++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
result[*found].width = sizes[j].width; |
|
|
|
*found = 1; |
|
|
|
result[*found].height = sizes[j].height; |
|
|
|
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode)); |
|
|
|
result[*found].redBits = (rgbs[i] >> 16) & 255; |
|
|
|
|
|
|
|
result[*found].greenBits = (rgbs[i] >> 8) & 255; |
|
|
|
|
|
|
|
result[*found].blueBits = rgbs[i] & 255; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(*found)++; |
|
|
|
result[0].width = DisplayWidth(_glfwLibrary.X11.display, |
|
|
|
} |
|
|
|
_glfwLibrary.X11.screen); |
|
|
|
|
|
|
|
result[0].height = DisplayHeight(_glfwLibrary.X11.display, |
|
|
|
|
|
|
|
_glfwLibrary.X11.screen); |
|
|
|
|
|
|
|
result[0].redBits = r; |
|
|
|
|
|
|
|
result[0].greenBits = g; |
|
|
|
|
|
|
|
result[0].blueBits = b; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
free(sizes); |
|
|
|
|
|
|
|
free(rgbs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|