Esempio n. 1
0
int main(int argc, char *argv[])
{
	const SDL_VideoInfo *info;
	int i;
	SDL_Rect **modes;
	char driver[128];

	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
		fprintf(stderr,
			"Couldn't initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}
	if ( SDL_VideoDriverName(driver, sizeof(driver)) ) {
		printf("Video driver: %s\n", driver);
	}
	info = SDL_GetVideoInfo();
	printf(
"Current display: %dx%d, %d bits-per-pixel\n",
		info->current_w, info->current_h, info->vfmt->BitsPerPixel);
	if ( info->vfmt->palette == NULL ) {
		printf("	Red Mask = 0x%.8x\n", info->vfmt->Rmask);
		printf("	Green Mask = 0x%.8x\n", info->vfmt->Gmask);
		printf("	Blue Mask = 0x%.8x\n", info->vfmt->Bmask);
	}
	/* Print available fullscreen video modes */
	modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
	if ( modes == (SDL_Rect **)0 ) {
		printf("No available fullscreen video modes\n");
	} else
	if ( modes == (SDL_Rect **)-1 ) {
		printf("No special fullscreen video modes\n");
	} else {
		printf("Fullscreen video modes:\n");
		for ( i=0; modes[i]; ++i ) {
			printf("\t%dx%dx%d\n", modes[i]->w, modes[i]->h, info->vfmt->BitsPerPixel);
		}
	}
	if ( info->wm_available ) {
		printf("A window manager is available\n");
	}
	if ( info->hw_available ) {
		printf("Hardware surfaces are available (%dK video memory)\n",
			info->video_mem);
	}
	if ( info->blit_hw ) {
		printf(
"Copy blits between hardware surfaces are accelerated\n");
	}
	if ( info->blit_hw_CC ) {
		printf(
"Colorkey blits between hardware surfaces are accelerated\n");
	}
	if ( info->blit_hw_A ) {
		printf(
"Alpha blits between hardware surfaces are accelerated\n");
	}
	if ( info->blit_sw ) {
		printf(
"Copy blits from software surfaces to hardware surfaces are accelerated\n");
	}
	if ( info->blit_sw_CC ) {
		printf(
"Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
	}
	if ( info->blit_sw_A ) {
		printf(
"Alpha blits from software surfaces to hardware surfaces are accelerated\n");
	}
	if ( info->blit_fill ) {
		printf(
"Color fills on hardware surfaces are accelerated\n");
	}

	if ( argv[1] && (strcmp(argv[1], "-benchmark") == 0) ) {
		RunVideoTests();
	}

	SDL_Quit();
	return(0);
}
Esempio n. 2
0
int
main(int argc, char *argv[])
{
    const SDL_VideoInfo *info;
    int i, d, n;
    const char *driver;
    SDL_DisplayMode mode;
    int bpp;
    Uint32 Rmask, Gmask, Bmask, Amask;
    int nmodes;

    /* Print available video drivers */
    n = SDL_GetNumVideoDrivers();
    if (n == 0) {
        printf("No built-in video drivers\n");
    } else {
        printf("Built-in video drivers:");
        for (i = 0; i < n; ++i) {
            if (i > 0) {
                printf(",");
            }
            printf(" %s", SDL_GetVideoDriver(i));
        }
        printf("\n");
    }

    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
        exit(1);
    }
    driver = SDL_GetCurrentVideoDriver();
    if (driver) {
        printf("Video driver: %s\n", driver);
    }
    printf("Number of displays: %d\n", SDL_GetNumVideoDisplays());
    for (d = 0; d < SDL_GetNumVideoDisplays(); ++d) {
        printf("Display %d:\n", d);
        SDL_SelectVideoDisplay(d);

        SDL_GetDesktopDisplayMode(&mode);
        SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask,
                                   &Amask);
        printf("  Current mode: %dx%d@%dHz, %d bits-per-pixel\n", mode.w,
               mode.h, mode.refresh_rate, bpp);
        if (Rmask || Gmask || Bmask) {
            printf("      Red Mask = 0x%.8x\n", Rmask);
            printf("      Green Mask = 0x%.8x\n", Gmask);
            printf("      Blue Mask = 0x%.8x\n", Bmask);
            if (Amask)
                printf("      Alpha Mask = 0x%.8x\n", Amask);
        }

        /* Print available fullscreen video modes */
        nmodes = SDL_GetNumDisplayModes();
        if (nmodes == 0) {
            printf("No available fullscreen video modes\n");
        } else {
            printf("  Fullscreen video modes:\n");
            for (i = 0; i < nmodes; ++i) {
                SDL_GetDisplayMode(i, &mode);
                SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask,
                                           &Gmask, &Bmask, &Amask);
                printf("    Mode %d: %dx%d@%dHz, %d bits-per-pixel\n", i,
                       mode.w, mode.h, mode.refresh_rate, bpp);
                if (Rmask || Gmask || Bmask) {
                    printf("        Red Mask = 0x%.8x\n", Rmask);
                    printf("        Green Mask = 0x%.8x\n", Gmask);
                    printf("        Blue Mask = 0x%.8x\n", Bmask);
                    if (Amask)
                        printf("        Alpha Mask = 0x%.8x\n", Amask);
                }
            }
        }
    }

    info = SDL_GetVideoInfo();
    if (info->wm_available) {
        printf("A window manager is available\n");
    }
    if (info->hw_available) {
        printf("Hardware surfaces are available (%dK video memory)\n",
               info->video_mem);
    }
    if (info->blit_hw) {
        printf("Copy blits between hardware surfaces are accelerated\n");
    }
    if (info->blit_hw_CC) {
        printf("Colorkey blits between hardware surfaces are accelerated\n");
    }
    if (info->blit_hw_A) {
        printf("Alpha blits between hardware surfaces are accelerated\n");
    }
    if (info->blit_sw) {
        printf
            ("Copy blits from software surfaces to hardware surfaces are accelerated\n");
    }
    if (info->blit_sw_CC) {
        printf
            ("Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
    }
    if (info->blit_sw_A) {
        printf
            ("Alpha blits from software surfaces to hardware surfaces are accelerated\n");
    }
    if (info->blit_fill) {
        printf("Color fills on hardware surfaces are accelerated\n");
    }
    printf("Current resolution: %dx%d\n", info->current_w, info->current_h);
#if 0
    if (argv[1] && (strcmp(argv[1], "-benchmark") == 0)) {
        RunVideoTests();
    }
#endif

    SDL_Quit();
    return (0);
}