int *pvalue )
{
uint count;
- uint index;
const struct stw_pixelformat_info *pfi;
count = stw_pixelformat_get_extended_count();
return TRUE;
}
- index = (uint) iPixelFormat - 1;
- if (index >= count)
+ pfi = stw_pixelformat_get_info( iPixelFormat );
+ if (!pfi) {
return FALSE;
-
- pfi = stw_pixelformat_get_info( index );
+ }
switch (attrib) {
case WGL_DRAW_TO_WINDOW_ARB:
}
const struct stw_pixelformat_info *
-stw_pixelformat_get_info( uint index )
+stw_pixelformat_get_info( int iPixelFormat )
{
- assert( index < stw_dev->pixelformat_extended_count );
+ int index;
+
+ if (iPixelFormat <= 0) {
+ return NULL;
+ }
+
+ index = iPixelFormat - 1;
+ if (index >= stw_dev->pixelformat_extended_count) {
+ return NULL;
+ }
return &stw_dev->pixelformats[index];
}
PIXELFORMATDESCRIPTOR *ppfd )
{
uint count;
- uint index;
const struct stw_pixelformat_info *pfi;
(void) hdc;
return 0;
count = stw_pixelformat_get_extended_count();
- index = (uint) iPixelFormat - 1;
if (ppfd == NULL)
return count;
- if (index >= count || cjpfd != sizeof( PIXELFORMATDESCRIPTOR ))
+ if (cjpfd != sizeof( PIXELFORMATDESCRIPTOR ))
return 0;
- pfi = stw_pixelformat_get_info( index );
+ pfi = stw_pixelformat_get_info( iPixelFormat );
+ if (!pfi) {
+ return 0;
+ }
memcpy(ppfd, &pfi->pfd, sizeof( PIXELFORMATDESCRIPTOR ));
(void) hdc;
count = stw_pixelformat_get_count();
- bestindex = count;
+ bestindex = 0;
bestdelta = ~0U;
- for (index = 0; index < count; index++) {
+ for (index = 1; index <= count; index++) {
uint delta = 0;
const struct stw_pixelformat_info *pfi = stw_pixelformat_get_info( index );
}
}
- if (bestindex == count)
- return 0;
-
- return bestindex + 1;
+ return bestindex;
}
stw_pixelformat_get_extended_count( void );
const struct stw_pixelformat_info *
-stw_pixelformat_get_info( uint index );
+stw_pixelformat_get_info( int iPixelFormat );
int
stw_pixelformat_choose( HDC hdc,