58
58
#include "darwinfb.h"
59
59
60
60
/* Based originally on code from indirect.c which was based on code from i830_dri.c. */
61
- __GLXconfig *
62
- __glXAquaCreateVisualConfigs (int * numConfigsPtr , int screenNumber )
63
- {
61
+ __GLXconfig * __glXAquaCreateVisualConfigs (int * numConfigsPtr , int screenNumber ) {
64
62
int numConfigs = 0 ;
65
63
__GLXconfig * visualConfigs , * c ;
66
64
struct glCapabilities caps ;
67
65
struct glCapabilitiesConfig * conf ;
68
66
int stereo , depth , aux , buffers , stencil , accum , color , msample ;
69
67
70
- if (getGlCapabilities (& caps )) {
68
+ if (getGlCapabilities (& caps )) {
71
69
ErrorF ("error from getGlCapabilities()!\n" );
72
70
return NULL ;
73
71
}
74
72
75
73
/*
76
- conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
77
- so we treat a true conf->stereo as 2.
74
+ conf->stereo is 0 or 1, but we need at least 1 iteration of the loop,
75
+ so we treat a true conf->stereo as 2.
78
76
79
- The depth size is 0 or 24. Thus we do 2 iterations for that.
77
+ The depth size is 0 or 24. Thus we do 2 iterations for that.
80
78
81
- conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
79
+ conf->aux_buffers (when available/non-zero) result in 2 iterations instead of 1.
82
80
83
- conf->buffers indicates whether we have single or double buffering.
81
+ conf->buffers indicates whether we have single or double buffering.
84
82
85
- conf->total_stencil_bit_depths
83
+ conf->total_stencil_bit_depths
86
84
87
- conf->total_color_buffers indicates the RGB/RGBA color depths.
85
+ conf->total_color_buffers indicates the RGB/RGBA color depths.
88
86
89
- conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
87
+ conf->total_accum_buffers iterations for accum (with at least 1 if equal to 0)
90
88
91
- conf->total_depth_buffer_depths
89
+ conf->total_depth_buffer_depths
92
90
93
- conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
94
- for the 0 multisampling config.
91
+ conf->multisample_buffers iterations (with at least 1 if equal to 0). We add 1
92
+ for the 0 multisampling config.
95
93
96
94
*/
97
95
98
96
assert (NULL != caps .configurations );
99
97
100
98
numConfigs = 0 ;
101
99
102
- for (conf = caps .configurations ; conf ; conf = conf -> next ) {
103
- if (conf -> total_color_buffers <= 0 )
100
+ for (conf = caps .configurations ; conf ; conf = conf -> next ) {
101
+ if (conf -> total_color_buffers <= 0 )
104
102
continue ;
105
103
106
104
numConfigs += (conf -> stereo ? 2 : 1 )
107
- * (conf -> aux_buffers ? 2 : 1 )
108
- * conf -> buffers
109
- * ((conf -> total_stencil_bit_depths >
110
- 0 ) ? conf -> total_stencil_bit_depths : 1 )
111
- * conf -> total_color_buffers
112
- * ((conf -> total_accum_buffers >
113
- 0 ) ? conf -> total_accum_buffers : 1 )
114
- * conf -> total_depth_buffer_depths
115
- * (conf -> multisample_buffers + 1 );
105
+ * (conf -> aux_buffers ? 2 : 1 )
106
+ * conf -> buffers
107
+ * ((conf -> total_stencil_bit_depths > 0 ) ? conf -> total_stencil_bit_depths : 1 )
108
+ * conf -> total_color_buffers
109
+ * ((conf -> total_accum_buffers > 0 ) ? conf -> total_accum_buffers : 1 )
110
+ * conf -> total_depth_buffer_depths
111
+ * (conf -> multisample_buffers + 1 );
116
112
}
117
113
118
- if (numConfigsPtr )
114
+ if (numConfigsPtr )
119
115
* numConfigsPtr = numConfigs ;
120
116
121
117
visualConfigs = calloc (sizeof (* visualConfigs ), numConfigs );
122
118
123
- if (NULL == visualConfigs ) {
119
+ if (NULL == visualConfigs ) {
124
120
ErrorF ("xcalloc failure when allocating visualConfigs\n" );
125
121
freeGlCapabilities (& caps );
126
122
return NULL ;
127
123
}
128
124
129
125
c = visualConfigs ; /* current buffer */
130
- for (conf = caps .configurations ; conf ; conf = conf -> next ) {
131
- for (stereo = 0 ; stereo < (conf -> stereo ? 2 : 1 ); ++ stereo ) {
132
- for (aux = 0 ; aux < (conf -> aux_buffers ? 2 : 1 ); ++ aux ) {
133
- for (buffers = 0 ; buffers < conf -> buffers ; ++ buffers ) {
134
- for (stencil = 0 ;
135
- stencil < ((conf -> total_stencil_bit_depths > 0 ) ?
136
- conf ->
137
- total_stencil_bit_depths : 1 );
138
- ++ stencil ) {
139
- for (color = 0 ; color < conf -> total_color_buffers ;
140
- ++ color ) {
141
- for (accum = 0 ;
142
- accum < ((conf -> total_accum_buffers > 0 ) ?
143
- conf ->
144
- total_accum_buffers : 1 );
145
- ++ accum ) {
146
- for (depth = 0 ;
147
- depth < conf -> total_depth_buffer_depths ;
148
- ++ depth ) {
149
- for (msample = 0 ;
150
- msample <
151
- (conf -> multisample_buffers + 1 );
152
- ++ msample ) {
126
+ for (conf = caps .configurations ; conf ; conf = conf -> next ) {
127
+ for (stereo = 0 ; stereo < (conf -> stereo ? 2 : 1 ); ++ stereo ) {
128
+ for (aux = 0 ; aux < (conf -> aux_buffers ? 2 : 1 ); ++ aux ) {
129
+ for (buffers = 0 ; buffers < conf -> buffers ; ++ buffers ) {
130
+ for (stencil = 0 ; stencil < ((conf -> total_stencil_bit_depths > 0 ) ?
131
+ conf -> total_stencil_bit_depths : 1 ); ++ stencil ) {
132
+ for (color = 0 ; color < conf -> total_color_buffers ; ++ color ) {
133
+ for (accum = 0 ; accum < ((conf -> total_accum_buffers > 0 ) ?
134
+ conf -> total_accum_buffers : 1 ); ++ accum ) {
135
+ for (depth = 0 ; depth < conf -> total_depth_buffer_depths ; ++ depth ) {
136
+ for (msample = 0 ; msample < (conf -> multisample_buffers + 1 ); ++ msample ) {
153
137
154
138
// Global
155
139
c -> visualID = -1 ;
@@ -162,12 +146,10 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
162
146
c -> indexBits = 0 ;
163
147
c -> pixmapMode = 0 ; // TODO: What should this be?
164
148
165
- if (conf -> accelerated ) {
149
+ if (conf -> accelerated ) {
166
150
c -> visualRating = GLX_NONE ;
167
- }
168
- else {
169
- c -> visualRating =
170
- GLX_SLOW_VISUAL_EXT ;
151
+ } else {
152
+ c -> visualRating = GLX_SLOW_VISUAL_EXT ;
171
153
}
172
154
173
155
c -> transparentPixel = GLX_NONE ;
@@ -179,109 +161,66 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
179
161
180
162
c -> visualSelectGroup = 0 ;
181
163
182
- c -> swapMethod =
183
- GLX_SWAP_UNDEFINED_OML ;
164
+ c -> swapMethod = GLX_SWAP_UNDEFINED_OML ;
184
165
185
166
// Stereo
186
167
c -> stereoMode = stereo ? TRUE : FALSE;
187
168
188
169
// Aux buffers
189
- c -> numAuxBuffers =
190
- aux ? conf -> aux_buffers : 0 ;
170
+ c -> numAuxBuffers = aux ? conf -> aux_buffers : 0 ;
191
171
192
172
// Double Buffered
193
- c -> doubleBufferMode =
194
- buffers ? TRUE : FALSE;
173
+ c -> doubleBufferMode = buffers ? TRUE : FALSE;
195
174
196
175
// Stencil Buffer
197
- if (conf -> total_stencil_bit_depths >
198
- 0 ) {
199
- c -> stencilBits =
200
- conf -> stencil_bit_depths [
201
- stencil ];
202
- }
203
- else {
176
+ if (conf -> total_stencil_bit_depths > 0 ) {
177
+ c -> stencilBits = conf -> stencil_bit_depths [stencil ];
178
+ } else {
204
179
c -> stencilBits = 0 ;
205
180
}
206
181
207
182
// Color
208
- if (GLCAPS_COLOR_BUF_INVALID_VALUE !=
209
- conf -> color_buffers [color ].a ) {
210
- c -> alphaBits =
211
- conf -> color_buffers [color ].a ;
212
- }
213
- else {
183
+ if (GLCAPS_COLOR_BUF_INVALID_VALUE != conf -> color_buffers [color ].a ) {
184
+ c -> alphaBits = conf -> color_buffers [color ].a ;
185
+ } else {
214
186
c -> alphaBits = 0 ;
215
187
}
216
- c -> redBits =
217
- conf -> color_buffers [color ].r ;
218
- c -> greenBits =
219
- conf -> color_buffers [color ].g ;
220
- c -> blueBits =
221
- conf -> color_buffers [color ].b ;
222
-
223
- c -> rgbBits = c -> alphaBits +
224
- c -> redBits +
225
- c -> greenBits +
226
- c -> blueBits ;
227
-
228
- c -> alphaMask =
229
- AM_ARGB (c -> alphaBits , c -> redBits ,
230
- c -> greenBits ,
231
- c -> blueBits );
232
- c -> redMask =
233
- RM_ARGB (c -> alphaBits , c -> redBits ,
234
- c -> greenBits ,
235
- c -> blueBits );
236
- c -> greenMask =
237
- GM_ARGB (c -> alphaBits , c -> redBits ,
238
- c -> greenBits ,
239
- c -> blueBits );
240
- c -> blueMask =
241
- BM_ARGB (c -> alphaBits , c -> redBits ,
242
- c -> greenBits ,
243
- c -> blueBits );
188
+ c -> redBits = conf -> color_buffers [color ].r ;
189
+ c -> greenBits = conf -> color_buffers [color ].g ;
190
+ c -> blueBits = conf -> color_buffers [color ].b ;
191
+
192
+ c -> rgbBits = c -> alphaBits + c -> redBits + c -> greenBits + c -> blueBits ;
193
+
194
+ c -> alphaMask = AM_ARGB (c -> alphaBits , c -> redBits , c -> greenBits , c -> blueBits );
195
+ c -> redMask = RM_ARGB (c -> alphaBits , c -> redBits , c -> greenBits , c -> blueBits );
196
+ c -> greenMask = GM_ARGB (c -> alphaBits , c -> redBits , c -> greenBits , c -> blueBits );
197
+ c -> blueMask = BM_ARGB (c -> alphaBits , c -> redBits , c -> greenBits , c -> blueBits );
244
198
245
199
// Accumulation Buffers
246
- if (conf -> total_accum_buffers > 0 ) {
247
- c -> accumRedBits =
248
- conf -> accum_buffers [accum ].r ;
249
- c -> accumGreenBits =
250
- conf -> accum_buffers [accum ].g ;
251
- c -> accumBlueBits =
252
- conf -> accum_buffers [accum ].b ;
253
- if (
254
- GLCAPS_COLOR_BUF_INVALID_VALUE
255
- !=
256
- conf -> accum_buffers [accum ].a )
257
- {
258
- c -> accumAlphaBits =
259
- conf -> accum_buffers [accum
260
- ].a ;
261
- }
262
- else {
200
+ if (conf -> total_accum_buffers > 0 ) {
201
+ c -> accumRedBits = conf -> accum_buffers [accum ].r ;
202
+ c -> accumGreenBits = conf -> accum_buffers [accum ].g ;
203
+ c -> accumBlueBits = conf -> accum_buffers [accum ].b ;
204
+ if (GLCAPS_COLOR_BUF_INVALID_VALUE != conf -> accum_buffers [accum ].a ) {
205
+ c -> accumAlphaBits = conf -> accum_buffers [accum ].a ;
206
+ } else {
263
207
c -> accumAlphaBits = 0 ;
264
208
}
265
- }
266
- else {
209
+ } else {
267
210
c -> accumRedBits = 0 ;
268
211
c -> accumGreenBits = 0 ;
269
212
c -> accumBlueBits = 0 ;
270
213
c -> accumAlphaBits = 0 ;
271
214
}
272
215
273
216
// Depth
274
- c -> depthBits =
275
- conf -> depth_buffers [depth ];
217
+ c -> depthBits = conf -> depth_buffers [depth ];
276
218
277
219
// MultiSample
278
- if (msample > 0 ) {
279
- c -> samples =
280
- conf -> multisample_samples ;
281
- c -> sampleBuffers =
282
- conf -> multisample_buffers ;
283
- }
284
- else {
220
+ if (msample > 0 ) {
221
+ c -> samples = conf -> multisample_samples ;
222
+ c -> sampleBuffers = conf -> multisample_buffers ;
223
+ } else {
285
224
c -> samples = 0 ;
286
225
c -> sampleBuffers = 0 ;
287
226
}
@@ -291,9 +230,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
291
230
* GLXPbuffers in direct mode.
292
231
*/
293
232
/* SGIX_fbconfig / GLX 1.3 */
294
- c -> drawableType = GLX_WINDOW_BIT |
295
- GLX_PIXMAP_BIT |
296
- GLX_PBUFFER_BIT ;
233
+ c -> drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT ;
297
234
c -> renderType = GLX_RGBA_BIT ;
298
235
c -> xRenderable = GL_TRUE ;
299
236
c -> fbconfigID = -1 ;
@@ -310,8 +247,7 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
310
247
*/
311
248
c -> maxPbufferWidth = 8192 ;
312
249
c -> maxPbufferHeight = 8192 ;
313
- c -> maxPbufferPixels =
314
- /*Do we need this?*/ 0 ;
250
+ c -> maxPbufferPixels = /*Do we need this?*/ 0 ;
315
251
/*
316
252
* There is no introspection for this sort of thing
317
253
* with CGL. What should we do realistically?
@@ -337,12 +273,10 @@ __glXAquaCreateVisualConfigs(int *numConfigsPtr, int screenNumber)
337
273
}
338
274
}
339
275
340
- (c - 1 )-> next = NULL ;
276
+ (c - 1 )-> next = NULL ;
341
277
342
278
if (c - visualConfigs != numConfigs ) {
343
- FatalError (
344
- "numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n" ,
345
- numConfigs , (int )(c - visualConfigs ));
279
+ FatalError ("numConfigs calculation error in setVisualConfigs! numConfigs is %d i is %d\n" , numConfigs , (int )(c - visualConfigs ));
346
280
}
347
281
348
282
freeGlCapabilities (& caps );
0 commit comments