void FrameForClient::InitInstance(){//Initialize Window
	/*
	//only use in In InitInstance();
	BOOL SetWndText(LPWSTR title);  if title = DEFAULT ,the title of window is default title
	BOOL SetSleepTime(UINT time);   if time = DEFAULT , the sleep time is 10 ms      
	BOOL SetWndSize(UINT width, UINT height); //if width(height) = DEFAULT , the width(height) will be default size
	BOOL SetAppIcon(UINT icon, UINT smicon); //if icon(smlicon) = DEFAULT , the icon(smlicon) will be default icon
	*/
	//To do something...
	SetAppIcon(IDI_ICON_BIRD,IDI_ICON_BIRD);
	SetWndText(_T(L"flappy bird"));
	SetWndSize(304, /*551*/510);
	SetSleepTime(20);
}
Beispiel #2
0
SdlUi::SdlUi(long width, long height, const std::string& title, bool fs_flag) :
	BaseUi(),
	zoom_available(true),
	toggle_fs_available(false),
	mode_changing(false) {

#ifdef GEKKO
	WPAD_Init();

	SYS_SetResetCallback(GekkoResetCallback);
#endif

	uint32_t flags = SDL_INIT_VIDEO;
	
#ifndef EMSCRIPTEN
	flags |= SDL_INIT_TIMER;
#endif

#if (!defined(NDEBUG) || defined(_WIN32))
	flags |= SDL_INIT_NOPARACHUTE;
#endif

	// Set some SDL env. variables before starting
	// These are platform dependent, so every port
	// needs to set them manually

	// Set window position to the middle of the
	// screen
#ifndef GEKKO
	putenv(const_cast<char *>("SDL_VIDEO_WINDOW_POS=center"));
#endif
#if defined(PSP)
	putenv(const_cast<char *>("SDL_ASPECT_RATIO=4:3"));
#endif

	if (SDL_Init(flags) < 0) {
		Output::Error("Couldn't initialize SDL.\n%s\n", SDL_GetError());
	}

#if SDL_MAJOR_VERSION==1
	sdl_surface = NULL;

	SetAppIcon();
#else
	sdl_window = NULL;
#endif

	BeginDisplayModeChange();
		if (!RequestVideoMode(width, height, fs_flag)) {
			Output::Error("No suitable video resolution found. Aborting.");
		}
	EndDisplayModeChange();

	SetTitle(title);

#if (defined(USE_JOYSTICK) && defined(SUPPORT_JOYSTICK)) || (defined(USE_JOYSTICK_AXIS) && defined(SUPPORT_JOYSTICK_AXIS)) || (defined(USE_JOYSTICK_HAT) && defined(SUPPORT_JOYSTICK_HAT))
	if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) {
		Output::Warning("Couldn't initialize joystick.\n%s", SDL_GetError());
	}

	SDL_JoystickEventState(1);
	SDL_JoystickOpen(0);
#endif

#if defined(USE_MOUSE) && defined(SUPPORT_MOUSE)
	ShowCursor(true);
#else
	ShowCursor(false);
#endif

#if defined(HAVE_SDL_MIXER)
	audio_.reset(new SdlAudio());
#elif defined(HAVE_OPENAL)
	audio_.reset(new ALAudio());
#else
	audio_.reset(new EmptyAudio());
#endif
}