14 static int best, best_score;
17 #define target allegro_gl_display_info 18 #define req __allegro_gl_required_settings 19 #define sug __allegro_gl_suggested_settings 21 #define PREFIX_I "agl-scorer INFO: " 28 void __allegro_gl_fill_in_info() {
35 && (((req | sug) & all_components) == all_components)) {
37 target.colour_depth = target.pixel_size.rgba.r
38 + target.pixel_size.rgba.g
39 + target.pixel_size.rgba.b
40 + target.pixel_size.rgba.a;
43 target.colour_depth = (target.colour_depth + 7) / 8;
46 else if ((req | sug) & all_components) {
48 int avg = ((req | sug) &
AGL_RED_DEPTH ? target.pixel_size.rgba.r: 0)
54 + ((req | sug) & AGL_GREEN_DEPTH ? 1 : 0)
55 + ((req | sug) & AGL_BLUE_DEPTH ? 1 : 0)
56 + ((req | sug) & AGL_ALPHA_DEPTH ? 1 : 0);
58 avg /= (num ? num : 1);
62 target.pixel_size.rgba.r = avg;
66 target.pixel_size.rgba.g = avg;
70 target.pixel_size.rgba.b = avg;
74 target.pixel_size.rgba.a = avg;
79 __allegro_gl_fill_in_info();
86 if ((((req | sug) & AGL_COLOR_DEPTH) == 0) && (target.colour_depth == 0)) {
87 BITMAP *temp = create_bitmap(1, 1);
125 void __allegro_gl_reset_scorer(
void)
133 static int get_score(
struct allegro_gl_display_info *dinfo)
137 if (dinfo->colour_depth != target.colour_depth) {
138 if (req & AGL_COLOR_DEPTH) {
139 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
140 get_config_text(
"Color depth requirement not met."));
150 if (sug & AGL_COLOR_DEPTH) {
151 if (dinfo->colour_depth < target.colour_depth)
152 score += (96 * dinfo->colour_depth) / target.colour_depth;
154 score += 96 + 96 / (1 + dinfo->colour_depth - target.colour_depth);
160 && (dinfo->pixel_size.rgba.r != target.pixel_size.rgba.r)) {
162 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
163 get_config_text(
"Red depth requirement not met."));
167 if (sug & AGL_RED_DEPTH) {
168 if (dinfo->pixel_size.rgba.r < target.pixel_size.rgba.r) {
169 score += (16 * dinfo->pixel_size.rgba.r) / target.pixel_size.rgba.r;
173 + 16 / (1 + dinfo->pixel_size.rgba.r - target.pixel_size.rgba.r);
177 if ((req & AGL_GREEN_DEPTH)
178 && (dinfo->pixel_size.rgba.g != target.pixel_size.rgba.g)) {
180 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
181 get_config_text(
"Green depth requirement not met."));
185 if (sug & AGL_GREEN_DEPTH) {
186 if (dinfo->pixel_size.rgba.g < target.pixel_size.rgba.g) {
187 score += (16 * dinfo->pixel_size.rgba.g) / target.pixel_size.rgba.g;
191 + 16 / (1 + dinfo->pixel_size.rgba.g - target.pixel_size.rgba.g);
195 if ((req & AGL_BLUE_DEPTH)
196 && (dinfo->pixel_size.rgba.b != target.pixel_size.rgba.b)) {
198 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
199 get_config_text(
"Blue depth requirement not met."));
203 if (sug & AGL_BLUE_DEPTH) {
204 if (dinfo->pixel_size.rgba.b < target.pixel_size.rgba.b) {
205 score += (16 * dinfo->pixel_size.rgba.b) / target.pixel_size.rgba.b;
209 + 16 / (1 + dinfo->pixel_size.rgba.b - target.pixel_size.rgba.b);
213 if ((req & AGL_ALPHA_DEPTH)
214 && (dinfo->pixel_size.rgba.a != target.pixel_size.rgba.a)) {
216 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
217 get_config_text(
"Alpha depth requirement not met."));
221 if (sug & AGL_ALPHA_DEPTH) {
222 if (dinfo->pixel_size.rgba.a < target.pixel_size.rgba.a) {
223 score += (16 * dinfo->pixel_size.rgba.a) / target.pixel_size.rgba.a;
227 + 16 / (1 + dinfo->pixel_size.rgba.a - target.pixel_size.rgba.a);
233 && (dinfo->accum_size.rgba.r != target.accum_size.rgba.r)) {
235 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
236 get_config_text(
"Accumulator Red depth requirement not met."));
240 if (sug & AGL_ACC_RED_DEPTH) {
241 if (dinfo->accum_size.rgba.r < target.accum_size.rgba.r) {
242 score += (16 * dinfo->accum_size.rgba.r) / target.accum_size.rgba.r;
246 + 16 / (1 + dinfo->accum_size.rgba.r - target.accum_size.rgba.r);
251 && (dinfo->accum_size.rgba.g != target.accum_size.rgba.g)) {
253 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
254 get_config_text(
"Accumulator Green depth requirement not met."));
258 if (sug & AGL_ACC_GREEN_DEPTH) {
259 if (dinfo->accum_size.rgba.g < target.accum_size.rgba.g) {
260 score += (16 * dinfo->accum_size.rgba.g) / target.accum_size.rgba.g;
264 + 16 / (1 + dinfo->accum_size.rgba.g - target.accum_size.rgba.g);
269 && (dinfo->accum_size.rgba.b != target.accum_size.rgba.b)) {
271 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
272 get_config_text(
"Accumulator Blue depth requirement not met."));
276 if (sug & AGL_ACC_BLUE_DEPTH) {
277 if (dinfo->accum_size.rgba.b < target.accum_size.rgba.b) {
278 score += (16 * dinfo->accum_size.rgba.b) / target.accum_size.rgba.b;
282 + 16 / (1 + dinfo->accum_size.rgba.b - target.accum_size.rgba.b);
287 && (dinfo->accum_size.rgba.a != target.accum_size.rgba.a)) {
289 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
290 get_config_text(
"Accumulator Alpha depth requirement not met."));
294 if (sug & AGL_ACC_ALPHA_DEPTH) {
295 if (dinfo->accum_size.rgba.a < target.accum_size.rgba.a) {
296 score += (16 * dinfo->accum_size.rgba.a) / target.accum_size.rgba.a;
300 + 16 / (1 + dinfo->accum_size.rgba.a - target.accum_size.rgba.a);
306 if (!dinfo->doublebuffered != !target.doublebuffered) {
307 if (req & AGL_DOUBLEBUFFER) {
308 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
309 get_config_text(
"Double Buffer requirement not met."));
317 if (!dinfo->stereo != !target.stereo) {
318 if (req & AGL_STEREO) {
319 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
320 get_config_text(
"Stereo Buffer requirement not met."));
325 if (sug & AGL_STEREO) {
330 if ((req &
AGL_AUX_BUFFERS) && (dinfo->aux_buffers < target.aux_buffers)) {
331 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
332 get_config_text(
"Aux Buffer requirement not met."));
336 if (sug & AGL_AUX_BUFFERS) {
337 if (dinfo->aux_buffers < target.aux_buffers) {
338 score += (64 * dinfo->aux_buffers) / target.aux_buffers;
341 score += 64 + 64 / (1 + dinfo->aux_buffers - target.aux_buffers);
345 if ((req &
AGL_Z_DEPTH) && (dinfo->depth_size != target.depth_size)) {
346 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
347 get_config_text(
"Z-Buffer requirement not met."));
350 if (sug & AGL_Z_DEPTH) {
351 if (dinfo->depth_size < target.depth_size) {
352 score += (64 * dinfo->depth_size) / target.depth_size;
355 score += 64 + 64 / (1 + dinfo->depth_size - target.depth_size);
360 && (dinfo->stencil_size != target.stencil_size)) {
362 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
363 get_config_text(
"Stencil depth requirement not met."));
367 if (sug & AGL_STENCIL_DEPTH) {
368 if (dinfo->stencil_size < target.stencil_size) {
369 score += (64 * dinfo->stencil_size) / target.stencil_size;
372 score += 64 + 64 / (1 + dinfo->stencil_size - target.stencil_size);
377 && ((dinfo->rmethod != target.rmethod) || (target.rmethod == 2))) {
379 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
380 get_config_text(
"Render Method requirement not met"));
384 if ((sug & AGL_RENDERMETHOD) && (dinfo->rmethod == target.rmethod)) {
387 else if (dinfo->rmethod == 1) {
392 && (dinfo->sample_buffers != target.sample_buffers)) {
393 ustrzcpy(allegro_gl_error, AGL_ERROR_SIZE,
394 get_config_text(
"Multisample Buffers requirement not met"));
398 if (sug & AGL_SAMPLE_BUFFERS) {
399 if (dinfo->sample_buffers < target.sample_buffers) {
400 score += (64 * dinfo->sample_buffers) / target.sample_buffers;
404 + 64 / (1 + dinfo->sample_buffers - target.sample_buffers);
408 if ((req &
AGL_SAMPLES) && (dinfo->samples != target.samples)) {
409 ustrzcpy(allegro_gl_error, AGL_ERROR_SIZE,
410 get_config_text(
"Multisample Samples requirement not met"));
414 if (sug & AGL_SAMPLES) {
415 if (dinfo->samples < target.samples) {
416 score += (64 * dinfo->samples) / target.samples;
419 score += 64 + 64 / (1 + dinfo->samples - target.samples);
424 if (!dinfo->float_color != !target.float_color) {
426 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
427 get_config_text(
"Float Color requirement not met."));
432 if (sug & AGL_FLOAT_COLOR) {
437 if (!dinfo->float_depth != !target.float_depth) {
439 ustrzcpy (allegro_gl_error, AGL_ERROR_SIZE,
440 get_config_text(
"Float Depth requirement not met."));
445 if (sug & AGL_FLOAT_Z) {
450 TRACE(PREFIX_I
"Score is : %i\n", score);
460 int __allegro_gl_score_config(
int refnum,
461 struct allegro_gl_display_info *dinfo)
463 int score = get_score(dinfo);
465 TRACE(PREFIX_I
"score_config: %s\n", allegro_gl_error);
469 if (score == best_score) {
476 if (score > best_score) {
486 int __allegro_gl_best_config(
void)
#define AGL_SAMPLE_BUFFERS
Define multisample parameters Some OpenGL ICDs expose an extension called GL_ARB_multisample which pr...
#define AGL_GREEN_DEPTH
Select the green depth of the frame buffer.
#define AGL_STEREO
Creates seperate left/right buffers for stereo display.
#define AGL_REQUIRE
Reject other values for these settings.
#define AGL_DOUBLEBUFFER
Creates a backbuffer if set.
#define AGL_ALPHA_DEPTH
Select the alpha depth of the frame buffer.
#define AGL_SUGGEST
Prefer the assigned values for these settings.
#define AGL_SAMPLES
Define multisample samples Set this value to the number of samples that can be accepted in the multis...
#define AGL_ACC_BLUE_DEPTH
Select the blue depth of the accumulator buffer.
#define AGL_ACC_ALPHA_DEPTH
Select the alpha depth of the accumulator buffer.
#define AGL_ACC_GREEN_DEPTH
Select the green depth of the accumulator buffer.
void allegro_gl_set(int option, int value)
Sets a configuration option.
#define AGL_Z_DEPTH
Select the depth of the z-buffer.
#define AGL_STENCIL_DEPTH
Select the depth of the stencil buffer.
#define AGL_FLOAT_COLOR
Floating-point Color buffer.
#define AGL_COLOR_DEPTH
Specify the total color depth of the frame buffer.
#define AGL_FLOAT_Z
Floating-point Depth buffer.
#define AGL_AUX_BUFFERS
Creates additional auxiliary buffers.
#define AGL_ACC_RED_DEPTH
Select the red depth of the accumulator buffer.
Main header file for AllegroGL.
#define AGL_BLUE_DEPTH
Select the blue depth of the frame buffer.
#define AGL_RED_DEPTH
Select the red depth of the frame buffer.
#define AGL_RENDERMETHOD
Set it if you'd like AllegroGL to pay special attention on whether hardware acceleration is present o...