Beispiel #1
0
// The main message loop
int RunMessageLoop()
{
	int bRestartVideo;
	int finished= 0;
    
    video_fskipcounter=0;
    SDL_StartTicks();
    
	do {
		bRestartVideo = 0;
        
		//MediaInit();
        
		if (!bVidOkay) {
            
			// Reinit the video plugin
			VidInit();
			if (!bVidOkay && nVidFullscreen) {
                
				nVidFullscreen = 0;
				VidInit();
			}
            
        }
        
		RunInit();
        
		GameInpCheckMouse();															// Hide the cursor
        
        done=0;timer = 0;ticks=0;tick=0;sdl_fps = 0;
		while (!finished) {
            if (nShouldExit==1) {
                finished=1;                
            }
            if (nShouldExit==0) {
				RunIdle();
			} else {
                usleep(10000); //10ms
            }
		}
		RunExit();        
	} while (bRestartVideo);
    
	return 0;
}
Beispiel #2
0
int
SDL_InitSubSystem(Uint32 flags)
{
#if !SDL_VIDEO_DISABLED
    /* Initialize the video/event subsystem */
    if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) {
        if (SDL_VideoInit(NULL) < 0) {
            return (-1);
        }
        SDL_initialized |= SDL_INIT_VIDEO;
    }
#else
    if (flags & SDL_INIT_VIDEO) {
        SDL_SetError("SDL not built with video support");
        return (-1);
    }
#endif

#if !SDL_AUDIO_DISABLED
    /* Initialize the audio subsystem */
    if ((flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO)) {
        if (SDL_AudioInit(NULL) < 0) {
            return (-1);
        }
        SDL_initialized |= SDL_INIT_AUDIO;
    }
#else
    if (flags & SDL_INIT_AUDIO) {
        SDL_SetError("SDL not built with audio support");
        return (-1);
    }
#endif

#if !SDL_TIMERS_DISABLED
    /* Initialize the timer subsystem */
    if (!ticks_started) {
        SDL_StartTicks();
        ticks_started = 1;
    }
    if ((flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER)) {
        if (SDL_TimerInit() < 0) {
            return (-1);
        }
        SDL_initialized |= SDL_INIT_TIMER;
    }
#else
    if (flags & SDL_INIT_TIMER) {
        SDL_SetError("SDL not built with timer support");
        return (-1);
    }
#endif

#if !SDL_JOYSTICK_DISABLED
    /* Initialize the joystick subsystem */
    if ((flags & SDL_INIT_JOYSTICK) && !(SDL_initialized & SDL_INIT_JOYSTICK)) {
        if (SDL_JoystickInit() < 0) {
            return (-1);
        }
        SDL_initialized |= SDL_INIT_JOYSTICK;
    }
#else
    if (flags & SDL_INIT_JOYSTICK) {
        SDL_SetError("SDL not built with joystick support");
        return (-1);
    }
#endif

#if !SDL_HAPTIC_DISABLED
    /* Initialize the haptic subsystem */
    if ((flags & SDL_INIT_HAPTIC) && !(SDL_initialized & SDL_INIT_HAPTIC)) {
        if (SDL_HapticInit() < 0) {
            return (-1);
        }
        SDL_initialized |= SDL_INIT_HAPTIC;
    }
#else
    if (flags & SDL_INIT_HAPTIC) {
        SDL_SetError("SDL not built with haptic (force feedback) support");
        return (-1);
    }
#endif
    return (0);
}
Beispiel #3
0
int SDL_InitSubSystem(Uint32 flags)
{
#ifndef DISABLE_VIDEO
	/* Initialize the video/event subsystem */
	if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) {
		if ( SDL_VideoInit(getenv("SDL_VIDEODRIVER"),
		                   (flags&SDL_INIT_EVENTTHREAD)) < 0 ) {
			return(-1);
		}
		SDL_initialized |= SDL_INIT_VIDEO;
	}
#else
	if ( flags & SDL_INIT_VIDEO ) {
		SDL_SetError("SDL not built with video support");
		return(-1);
	}
#endif

#ifndef DISABLE_AUDIO
	/* Initialize the audio subsystem */
	if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) {
		if ( SDL_AudioInit(getenv("SDL_AUDIODRIVER")) < 0 ) {
			return(-1);
		}
		SDL_initialized |= SDL_INIT_AUDIO;
	}
#else
	if ( flags & SDL_INIT_AUDIO ) {
		SDL_SetError("SDL not built with audio support");
		return(-1);
	}
#endif

#ifndef DISABLE_TIMERS
	/* Initialize the timer subsystem */
	if ( ! ticks_started ) {
		SDL_StartTicks();
		ticks_started = 1;
	}
	if ( (flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER) ) {
		if ( SDL_TimerInit() < 0 ) {
			return(-1);
		}
		SDL_initialized |= SDL_INIT_TIMER;
	}
#else
	if ( flags & SDL_INIT_TIMER ) {
		SDL_SetError("SDL not built with timer support");
		return(-1);
	}
#endif

#ifndef DISABLE_JOYSTICK
	/* Initialize the joystick subsystem */
	if ( (flags & SDL_INIT_JOYSTICK) &&
	     !(SDL_initialized & SDL_INIT_JOYSTICK) ) {
		if ( SDL_JoystickInit() < 0 ) {
			return(-1);
		}
		SDL_initialized |= SDL_INIT_JOYSTICK;
	}
#else
	if ( flags & SDL_INIT_JOYSTICK ) {
		SDL_SetError("SDL not built with joystick support");
		return(-1);
	}
#endif

#ifndef DISABLE_CDROM
	/* Initialize the CD-ROM subsystem */
	if ( (flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM) ) {
		if ( SDL_CDROMInit() < 0 ) {
			return(-1);
		}
		SDL_initialized |= SDL_INIT_CDROM;
	}
#else
	if ( flags & SDL_INIT_CDROM ) {
		SDL_SetError("SDL not built with cdrom support");
		return(-1);
	}
#endif
	return(0);
}
Beispiel #4
0
int
SDL_InitSubSystem(Uint32 flags)
{
#if !SDL_TIMERS_DISABLED
    if (!ticks_started) {
        SDL_StartTicks();
        ticks_started = 1;
    }
#endif

    /* Initialize the timer subsystem */
    if ((flags & SDL_INIT_TIMER) ){
#if !SDL_TIMERS_DISABLED
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
            if (SDL_TimerInit() < 0) {
                return (-1);
            }
        }
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_TIMER);
#else
        SDL_SetError("SDL not built with timer support");
        return (-1);
#endif
    }

    /* Initialize the video/event subsystem */
    if ((flags & SDL_INIT_VIDEO) ){
#if !SDL_VIDEO_DISABLED
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
            if (SDL_VideoInit(NULL) < 0) {
                return (-1);
            }
        }
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_VIDEO);
#else
        SDL_SetError("SDL not built with video support");
        return (-1);
#endif
    }

    /* Initialize the audio subsystem */
    if ((flags & SDL_INIT_AUDIO) ){
#if !SDL_AUDIO_DISABLED
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
            if (SDL_AudioInit(NULL) < 0) {
                return (-1);
            }
        }
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_AUDIO);
#else
        SDL_SetError("SDL not built with audio support");
        return (-1);
#endif
    }

    if ((flags & SDL_INIT_GAMECONTROLLER)) {
        // Game controller implies Joystick.
        flags |= SDL_INIT_JOYSTICK;
    }

    /* Initialize the joystick subsystem */
    if ((flags & SDL_INIT_JOYSTICK) ){
#if !SDL_JOYSTICK_DISABLED
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
           if (SDL_JoystickInit() < 0) {
               return (-1);
           }
        }
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_JOYSTICK);
#else
        SDL_SetError("SDL not built with joystick support");
        return (-1);
#endif
    }

    if ((flags & SDL_INIT_GAMECONTROLLER) ){
#if !SDL_JOYSTICK_DISABLED
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
            if (SDL_GameControllerInit() < 0) {
                return (-1);
            }
        }
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_GAMECONTROLLER);
#else
        SDL_SetError("SDL not built with joystick support");
        return (-1);
#endif
    }

    /* Initialize the haptic subsystem */
    if ((flags & SDL_INIT_HAPTIC) ){
#if !SDL_HAPTIC_DISABLED
        if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
            if (SDL_HapticInit() < 0) {
                return (-1);
            }
        }
        SDL_PrivateSubsystemRefCountIncr(SDL_INIT_HAPTIC);
#else
        SDL_SetError("SDL not built with haptic (force feedback) support");
        return (-1);
#endif
    }

    return (0);
}