XQuartz: Cleanup getGlCapabilities to avoid hardcoding the number of displays
This commit is contained in:
parent
45045eb396
commit
12f7365f1f
|
@ -425,7 +425,7 @@ static CGLError handleRendererDescriptions(CGLRendererInfoObj info, GLint r,
|
||||||
|
|
||||||
handleAccumulationModes(c, flags);
|
handleAccumulationModes(c, flags);
|
||||||
|
|
||||||
return 0;
|
return kCGLNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initCapabilities(struct glCapabilities *cap) {
|
static void initCapabilities(struct glCapabilities *cap) {
|
||||||
|
@ -491,56 +491,36 @@ void freeGlCapabilities(struct glCapabilities *cap) {
|
||||||
cap->configurations = NULL;
|
cap->configurations = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_DISPLAYS 32
|
|
||||||
|
|
||||||
/*Return true if an error occured. */
|
/*Return true if an error occured. */
|
||||||
bool getGlCapabilities(struct glCapabilities *cap) {
|
bool getGlCapabilities(struct glCapabilities *cap) {
|
||||||
CGDirectDisplayID dspys[MAX_DISPLAYS];
|
CGLRendererInfoObj info;
|
||||||
CGDisplayErr err;
|
CGLError err;
|
||||||
CGOpenGLDisplayMask displayMask;
|
GLint numRenderers = 0, r;
|
||||||
CGDisplayCount i, displayCount = 0;
|
|
||||||
|
|
||||||
initCapabilities(cap);
|
initCapabilities(cap);
|
||||||
|
|
||||||
err = CGGetActiveDisplayList(MAX_DISPLAYS, dspys, &displayCount);
|
err = CGLQueryRendererInfo((GLuint)-1, &info, &numRenderers);
|
||||||
if(err) {
|
if(err) {
|
||||||
fprintf(stderr, "CGGetActiveDisplayList error: %s\n", CGLErrorString(err));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; i < displayCount; ++i) {
|
|
||||||
displayMask = CGDisplayIDToOpenGLDisplayMask(dspys[i]);
|
|
||||||
|
|
||||||
CGLRendererInfoObj info;
|
|
||||||
GLint numRenderers = 0, r, renderCount = 0;
|
|
||||||
|
|
||||||
err = CGLQueryRendererInfo(displayMask, &info, &numRenderers);
|
|
||||||
|
|
||||||
if(err) {
|
|
||||||
fprintf(stderr, "CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
|
fprintf(stderr, "CGLQueryRendererInfo error: %s\n", CGLErrorString(err));
|
||||||
fprintf(stderr, "trying to continue...\n");
|
return err;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLDescribeRenderer(info, 0, kCGLRPRendererCount, &renderCount);
|
|
||||||
|
|
||||||
for(r = 0; r < renderCount; ++r) {
|
for(r = 0; r < numRenderers; r++) {
|
||||||
CGLError derr;
|
|
||||||
struct glCapabilitiesConfig tmpconf, *conf;
|
struct glCapabilitiesConfig tmpconf, *conf;
|
||||||
|
|
||||||
initConfig(&tmpconf);
|
initConfig(&tmpconf);
|
||||||
|
|
||||||
derr = handleRendererDescriptions(info, r, &tmpconf);
|
err = handleRendererDescriptions(info, r, &tmpconf);
|
||||||
if(derr) {
|
if(err) {
|
||||||
fprintf(stderr, "error: %s\n", CGLErrorString(derr));
|
fprintf(stderr, "handleRendererDescriptions returned error: %s\n", CGLErrorString(err));
|
||||||
fprintf(stderr, "trying to continue...\n");
|
fprintf(stderr, "trying to continue...\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = malloc(sizeof(*conf));
|
conf = malloc(sizeof(*conf));
|
||||||
if(NULL == conf) {
|
if(NULL == conf) {
|
||||||
perror("malloc");
|
perror("malloc");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the struct. */
|
/* Copy the struct. */
|
||||||
|
@ -551,9 +531,8 @@ bool getGlCapabilities(struct glCapabilities *cap) {
|
||||||
cap->configurations = conf;
|
cap->configurations = conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGLDestroyRendererInfo(info);
|
CGLDestroyRendererInfo(info);
|
||||||
}
|
|
||||||
|
|
||||||
/* No error occured. We are done. */
|
/* No error occured. We are done. */
|
||||||
return false;
|
return kCGLNoError;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user