int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
	int i;
	int total_modes;
	VGLMode **modes;

	
	for ( i=0; i<NUM_MODELISTS; ++i ) {
		SDL_nummodes[i] = 0;
		SDL_modelist[i] = NULL;
	}

	
	if (SDL_getenv("SDL_NO_RAWKBD") == NULL) {
		if (VGLKeyboardInit(VGL_CODEKEYS) != 0) {
			SDL_SetError("Unable to initialize keyboard");
			return -1;
		}
	} else {
		warnx("Requiest to put keyboard into a raw mode ignored");
	}
	if (VGL_initkeymaps(STDIN_FILENO) != 0) {
		SDL_SetError("Unable to initialize keymap");
		return -1;
	}
	if (VGL_initmouse(STDIN_FILENO) != 0) {
		SDL_SetError("Unable to initialize mouse");
		return -1;
	}

	
	if (VGLCurMode != NULL) {
		this->info.current_w = VGLCurMode->ModeInfo.Xsize;
		this->info.current_h = VGLCurMode->ModeInfo.Ysize;
	}

	
	if (VGLCurMode != NULL)
		vformat->BitsPerPixel = VGLCurMode->Depth;
	else
		vformat->BitsPerPixel = 16;	

	
	total_modes = 0;
	modes = VGLListModes(-1, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
	for (i = 0; modes[i] != NULL; i++) {
		if ((modes[i]->ModeInfo.Type == VIDBUF8) ||
		    (modes[i]->ModeInfo.Type == VIDBUF16) ||
		    (modes[i]->ModeInfo.Type == VIDBUF32)) {
			VGL_AddMode(this, modes[i]);
			total_modes++;
		}
	}
	if (total_modes == 0) {
		SDL_SetError("No linear video modes available");
		return -1;
	}

	
	VGL_UpdateVideoInfo(this);

	
	hw_lock = SDL_CreateMutex();
	if (hw_lock == NULL) {
		SDL_SetError("Unable to create lock mutex");
		VGL_VideoQuit(this);
		return -1;
	}

	
	return 0;
}
Exemple #2
0
int VGL_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
	int i;
	int total_modes;
	VGLMode **modes;

	/* Initialize all variables that we clean on shutdown */
	for ( i=0; i<NUM_MODELISTS; ++i ) {
		SDL_nummodes[i] = 0;
		SDL_modelist[i] = NULL;
	}

	/* Enable mouse and keyboard support */
	if (SDL_getenv("SDL_NO_RAWKBD") == NULL) {
		if (VGLKeyboardInit(VGL_CODEKEYS) != 0) {
			SDL_SetError("Unable to initialize keyboard");
			return -1;
		}
	} else {
		warnx("Requiest to put keyboard into a raw mode ignored");
	}
	if (VGL_initkeymaps(STDIN_FILENO) != 0) {
		SDL_SetError("Unable to initialize keymap");
		return -1;
	}
	if (VGL_initmouse(STDIN_FILENO) != 0) {
		SDL_SetError("Unable to initialize mouse");
		return -1;
	}

	/* Determine the current screen size */
	if (VGLCurMode != NULL) {
		this->info.current_w = VGLCurMode->ModeInfo.Xsize;
		this->info.current_h = VGLCurMode->ModeInfo.Ysize;
	}

	/* Determine the screen depth */
	if (VGLCurMode != NULL)
		vformat->BitsPerPixel = VGLCurMode->Depth;
	else
		vformat->BitsPerPixel = 16;	/* Good default */

	/* Query for the list of available video modes */
	total_modes = 0;
	modes = VGLListModes(-1, V_INFO_MM_DIRECT | V_INFO_MM_PACKED);
	for (i = 0; modes[i] != NULL; i++) {
		if ((modes[i]->ModeInfo.Type == VIDBUF8) ||
		    (modes[i]->ModeInfo.Type == VIDBUF16) ||
		    (modes[i]->ModeInfo.Type == VIDBUF32)) {
			VGL_AddMode(this, modes[i]);
			total_modes++;
		}
	}
	if (total_modes == 0) {
		SDL_SetError("No linear video modes available");
		return -1;
	}

	/* Fill in our hardware acceleration capabilities */
	VGL_UpdateVideoInfo(this);

	/* Create the hardware surface lock mutex */
	hw_lock = SDL_CreateMutex();
	if (hw_lock == NULL) {
		SDL_SetError("Unable to create lock mutex");
		VGL_VideoQuit(this);
		return -1;
	}

	/* We're done! */
	return 0;
}