1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3*4882a593Smuzhiyun * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Permission is hereby granted, free of charge, to any person obtaining a
6*4882a593Smuzhiyun * copy of this software and associated documentation files (the "Software"),
7*4882a593Smuzhiyun * to deal in the Software without restriction, including without limitation
8*4882a593Smuzhiyun * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9*4882a593Smuzhiyun * and/or sell copies of the Software, and to permit persons to whom the
10*4882a593Smuzhiyun * Software is furnished to do so, subject to the following conditions:
11*4882a593Smuzhiyun *
12*4882a593Smuzhiyun * The above copyright notice including the dates of first publication and
13*4882a593Smuzhiyun * either this permission notice or a reference to
14*4882a593Smuzhiyun * http://oss.sgi.com/projects/FreeB/
15*4882a593Smuzhiyun * shall be included in all copies or substantial portions of the Software.
16*4882a593Smuzhiyun *
17*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18*4882a593Smuzhiyun * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19*4882a593Smuzhiyun * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20*4882a593Smuzhiyun * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21*4882a593Smuzhiyun * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22*4882a593Smuzhiyun * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23*4882a593Smuzhiyun * SOFTWARE.
24*4882a593Smuzhiyun *
25*4882a593Smuzhiyun * Except as contained in this notice, the name of Silicon Graphics, Inc.
26*4882a593Smuzhiyun * shall not be used in advertising or otherwise to promote the sale, use or
27*4882a593Smuzhiyun * other dealings in this Software without prior written authorization from
28*4882a593Smuzhiyun * Silicon Graphics, Inc.
29*4882a593Smuzhiyun */
30*4882a593Smuzhiyun
31*4882a593Smuzhiyun #include "glxfbconfig.h"
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun int
AreFBConfigsMatch(__GLXFBConfig * c1,__GLXFBConfig * c2)34*4882a593Smuzhiyun AreFBConfigsMatch(__GLXFBConfig * c1, __GLXFBConfig * c2)
35*4882a593Smuzhiyun {
36*4882a593Smuzhiyun int match;
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun match = ((c1->visualType == c2->visualType) &&
39*4882a593Smuzhiyun (c1->transparentType == c2->transparentType) &&
40*4882a593Smuzhiyun (c1->transparentRed == c2->transparentRed) &&
41*4882a593Smuzhiyun (c1->transparentGreen == c2->transparentGreen) &&
42*4882a593Smuzhiyun (c1->transparentBlue == c2->transparentBlue) &&
43*4882a593Smuzhiyun (c1->transparentAlpha == c2->transparentAlpha) &&
44*4882a593Smuzhiyun (c1->transparentIndex == c2->transparentIndex) &&
45*4882a593Smuzhiyun (c1->visualCaveat == c2->visualCaveat) &&
46*4882a593Smuzhiyun (c1->drawableType == c2->drawableType) &&
47*4882a593Smuzhiyun (c1->renderType == c2->renderType) &&
48*4882a593Smuzhiyun #if 0
49*4882a593Smuzhiyun (c1->maxPbufferWidth == c2->maxPbufferWidth) &&
50*4882a593Smuzhiyun (c1->maxPbufferHeight == c2->maxPbufferHeight) &&
51*4882a593Smuzhiyun (c1->maxPbufferPixels == c2->maxPbufferPixels) &&
52*4882a593Smuzhiyun (c1->optimalPbufferWidth == c2->optimalPbufferWidth) &&
53*4882a593Smuzhiyun (c1->optimalPbufferHeight == c2->optimalPbufferHeight) &&
54*4882a593Smuzhiyun #endif
55*4882a593Smuzhiyun (c1->visualSelectGroup == c2->visualSelectGroup) &&
56*4882a593Smuzhiyun (c1->rgbMode == c2->rgbMode) &&
57*4882a593Smuzhiyun (c1->colorIndexMode == c2->colorIndexMode) &&
58*4882a593Smuzhiyun (c1->doubleBufferMode == c2->doubleBufferMode) &&
59*4882a593Smuzhiyun (c1->stereoMode == c2->stereoMode) &&
60*4882a593Smuzhiyun (c1->haveAccumBuffer == c2->haveAccumBuffer) &&
61*4882a593Smuzhiyun (c1->haveDepthBuffer == c2->haveDepthBuffer) &&
62*4882a593Smuzhiyun (c1->haveStencilBuffer == c2->haveStencilBuffer) &&
63*4882a593Smuzhiyun (c1->accumRedBits == c2->accumRedBits) &&
64*4882a593Smuzhiyun (c1->accumGreenBits == c2->accumGreenBits) &&
65*4882a593Smuzhiyun (c1->accumBlueBits == c2->accumBlueBits) &&
66*4882a593Smuzhiyun (c1->accumAlphaBits == c2->accumAlphaBits) &&
67*4882a593Smuzhiyun (c1->depthBits == c2->depthBits) &&
68*4882a593Smuzhiyun (c1->stencilBits == c2->stencilBits) &&
69*4882a593Smuzhiyun (c1->indexBits == c2->indexBits) &&
70*4882a593Smuzhiyun (c1->redBits == c2->redBits) &&
71*4882a593Smuzhiyun (c1->greenBits == c2->greenBits) &&
72*4882a593Smuzhiyun (c1->blueBits == c2->blueBits) &&
73*4882a593Smuzhiyun (c1->alphaBits == c2->alphaBits) &&
74*4882a593Smuzhiyun (c1->redMask == c2->redMask) &&
75*4882a593Smuzhiyun (c1->greenMask == c2->greenMask) &&
76*4882a593Smuzhiyun (c1->blueMask == c2->blueMask) &&
77*4882a593Smuzhiyun (c1->alphaMask == c2->alphaMask) &&
78*4882a593Smuzhiyun (c1->multiSampleSize == c2->multiSampleSize) &&
79*4882a593Smuzhiyun (c1->nMultiSampleBuffers == c2->nMultiSampleBuffers) &&
80*4882a593Smuzhiyun (c1->maxAuxBuffers == c2->maxAuxBuffers) &&
81*4882a593Smuzhiyun (c1->level == c2->level) &&
82*4882a593Smuzhiyun (c1->extendedRange == c2->extendedRange) &&
83*4882a593Smuzhiyun (c1->minRed == c2->minRed) &&
84*4882a593Smuzhiyun (c1->maxRed == c2->maxRed) &&
85*4882a593Smuzhiyun (c1->minGreen == c2->minGreen) &&
86*4882a593Smuzhiyun (c1->maxGreen == c2->maxGreen) &&
87*4882a593Smuzhiyun (c1->minBlue == c2->minBlue) &&
88*4882a593Smuzhiyun (c1->maxBlue == c2->maxBlue) &&
89*4882a593Smuzhiyun (c1->minAlpha == c2->minAlpha) && (c1->maxAlpha == c2->maxAlpha)
90*4882a593Smuzhiyun );
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun return match;
93*4882a593Smuzhiyun }
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun __GLXFBConfig *
FindMatchingFBConfig(__GLXFBConfig * c,__GLXFBConfig * configs,int nconfigs)96*4882a593Smuzhiyun FindMatchingFBConfig(__GLXFBConfig * c, __GLXFBConfig * configs, int nconfigs)
97*4882a593Smuzhiyun {
98*4882a593Smuzhiyun int i;
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun for (i = 0; i < nconfigs; i++) {
101*4882a593Smuzhiyun if (AreFBConfigsMatch(c, configs + i))
102*4882a593Smuzhiyun return configs + i;
103*4882a593Smuzhiyun }
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun return 0;
106*4882a593Smuzhiyun }
107