Go to the source code of this file.
Functions | |
WINGDIAPI BOOL APIENTRY | wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats) |
WINGDIAPI BOOL APIENTRY | wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues) |
WINGDIAPI BOOL APIENTRY | wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues) |
WINGDIAPI BOOL APIENTRY wglChoosePixelFormatARB | ( | HDC | hdc, | |
const int * | piAttribIList, | |||
const FLOAT * | pfAttribFList, | |||
UINT | nMaxFormats, | |||
int * | piFormats, | |||
UINT * | nNumFormats | |||
) |
Definition at line 383 of file stw_wgl_arbpixelformat.c.
References FALSE, FREE, pixelformat_score::index, MALLOC, pixelformat_get_extended_count(), points(), pixelformat_score::points, score_pixelformats(), and TRUE.
00390 { 00391 uint count; 00392 struct pixelformat_score *scores; 00393 uint i; 00394 00395 *nNumFormats = 0; 00396 00397 /* Allocate and initialize pixelformat score table -- better matches 00398 * have higher scores. Start with a high score and take out penalty 00399 * points for a mismatch when the match does not have to be exact. 00400 * Set a score to 0 if there is a mismatch for an exact match criteria. 00401 */ 00402 count = pixelformat_get_extended_count(); 00403 scores = (struct pixelformat_score *) MALLOC( count * sizeof( struct pixelformat_score ) ); 00404 if (scores == NULL) 00405 return FALSE; 00406 for (i = 0; i < count; i++) { 00407 scores[i].points = 0x7fffffff; 00408 scores[i].index = i; 00409 } 00410 00411 /* Given the attribute list calculate a score for each pixelformat. 00412 */ 00413 if (piAttribIList != NULL) { 00414 while (*piAttribIList != 0) { 00415 if (!score_pixelformats( scores, count, piAttribIList[0], piAttribIList[1] )) { 00416 FREE( scores ); 00417 return FALSE; 00418 } 00419 piAttribIList += 2; 00420 } 00421 } 00422 if (pfAttribFList != NULL) { 00423 while (*pfAttribFList != 0) { 00424 if (!score_pixelformats( scores, count, (int) pfAttribFList[0], (int) pfAttribFList[1] )) { 00425 FREE( scores ); 00426 return FALSE; 00427 } 00428 pfAttribFList += 2; 00429 } 00430 } 00431 00432 /* Bubble-sort the resulting scores. Pixelformats with higher scores go first. 00433 * TODO: Find out if there are any patent issues with it. 00434 */ 00435 if (count > 1) { 00436 uint n = count; 00437 boolean swapped; 00438 00439 do { 00440 swapped = FALSE; 00441 for (i = 1; i < n; i++) { 00442 if (scores[i - 1].points < scores[i].points) { 00443 struct pixelformat_score score = scores[i - 1]; 00444 00445 scores[i - 1] = scores[i]; 00446 scores[i] = score; 00447 swapped = TRUE; 00448 } 00449 } 00450 n--; 00451 } 00452 while (swapped); 00453 } 00454 00455 /* Return a list of pixelformats that are the best match. 00456 * Reject pixelformats with non-positive scores. 00457 */ 00458 for (i = 0; i < count; i++) { 00459 if (scores[i].points > 0) { 00460 if (*nNumFormats < nMaxFormats) 00461 piFormats[*nNumFormats] = scores[i].index + 1; 00462 (*nNumFormats)++; 00463 } 00464 } 00465 00466 FREE( scores ); 00467 return TRUE; 00468 }
WINGDIAPI BOOL APIENTRY wglGetPixelFormatAttribfvARB | ( | HDC | hdc, | |
int | iPixelFormat, | |||
int | iLayerPlane, | |||
UINT | nAttributes, | |||
const int * | piAttributes, | |||
FLOAT * | pfValues | |||
) |
Definition at line 471 of file stw_wgl_arbpixelformat.c.
References FALSE, FLOAT, query_attrib(), TRUE, and UINT.
00478 { 00479 UINT i; 00480 00481 (void) hdc; 00482 00483 for (i = 0; i < nAttributes; i++) { 00484 int value; 00485 00486 if (!query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &value )) 00487 return FALSE; 00488 pfValues[i] = (FLOAT) value; 00489 } 00490 00491 return TRUE; 00492 }
WINGDIAPI BOOL APIENTRY wglGetPixelFormatAttribivARB | ( | HDC | hdc, | |
int | iPixelFormat, | |||
int | iLayerPlane, | |||
UINT | nAttributes, | |||
const int * | piAttributes, | |||
int * | piValues | |||
) |
Definition at line 495 of file stw_wgl_arbpixelformat.c.
References FALSE, query_attrib(), TRUE, and UINT.
00502 { 00503 UINT i; 00504 00505 (void) hdc; 00506 00507 for (i = 0; i < nAttributes; i++) { 00508 if (!query_attrib( iPixelFormat, iLayerPlane, piAttributes[i], &piValues[i] )) 00509 return FALSE; 00510 } 00511 00512 return TRUE; 00513 }