Пример #1
0
void C4Application::OnResolutionChanged(unsigned int iXRes, unsigned int iYRes)
{
	// notify game
	if (pDraw)
	{
		Game.OnResolutionChanged(iXRes, iYRes);
		pDraw->OnResolutionChanged(iXRes, iYRes);
	}
	if (pWindow)
	{
		if (pWindow->pSurface)
			pWindow->pSurface->UpdateSize(iXRes, iYRes);
		if (!FullScreenMode())
		{
			C4Rect r;
			pWindow->GetSize(&r);
			Config.Graphics.WindowX = r.Wdt;
			Config.Graphics.WindowY = r.Hgt;
		}
	}
}
Пример #2
0
void C4Application::GameTick()
{
	// Exec depending on game state
	switch (AppState)
	{
	case C4AS_None:
		assert(AppState != C4AS_None);
		break;
	case C4AS_Quit:
		// Do nothing, the main loop will exit soon
		break;
	case C4AS_PreInit:
		if (!PreInit()) Quit();
		break;
	case C4AS_Startup:
		SoundSystem.Execute();
		MusicSystem.Execute();
		// wait for the user to start a game
		break;
	case C4AS_StartGame:
		// immediate progress to next state; OpenGame will enter HandleMessage-loops in startup and lobby!
		C4Startup::CloseStartup();
		AppState = C4AS_Game;
		// first-time game initialization
		if (!Game.Init())
		{
			// set error flag (unless this was a lobby user abort)
			if (!C4GameLobby::UserAbort)
				Game.fQuitWithError = true;
			// no start: Regular QuitGame; this may reset the engine to startup mode if desired
			QuitGame();
			break;
		}
		if(Config.Graphics.Windowed == 2 && FullScreenMode())
			Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, true);
		break;
	case C4AS_AfterGame:
		// stop game
		Game.Clear();
		if(Config.Graphics.Windowed == 2 && !NextMission && !isEditor)
			Application.SetVideoMode(GetConfigWidth(), GetConfigHeight(), Config.Graphics.BitDepth, Config.Graphics.RefreshRate, Config.Graphics.Monitor, false);
		AppState = C4AS_PreInit;
		// if a next mission is desired, set to start it
		if (NextMission)
		{
			Game.SetScenarioFilename(NextMission.getData());
			Game.fLobby = Game.NetworkActive;
			Game.fObserve = false;
			NextMission.Clear();
		}
		break;
	case C4AS_Game:
		// Game
		if (Game.IsRunning)
			Game.Execute();
		// Sound
		SoundSystem.Execute();
		MusicSystem.Execute();
		// Gamepad
		if (pGamePadControl) pGamePadControl->Execute();
		break;
	}
}
Пример #3
0
bool Window::Create()
{
    if(!glfwOpenWindow(_width, _height, _redBits, _greenBits, _blueBits, _alphaBits, _depthBits, _stencilBits, FullScreenMode(_fullScreen)))
    {
        LeLog.WriteP("Window: Could not open glfw window. Width: %i, height: %i, r: %i, g: %i, b: %i, a: %i, d: %i, s: %i, fullscreen: %s",
            _width, _height, _redBits, _greenBits, _blueBits, _alphaBits, _depthBits, _stencilBits, _fullScreen ? "yes" : "no");
        return false;
    }

    glfwSetWindowTitle(_title.c_str());

    LeLog.WriteP("Window: Opened glfw window. Width: %i, height: %i, r: %i, g: %i, b: %i, a: %i, d: %i, s: %i, fullscreen: %s",
        _width, _height, _redBits, _greenBits, _blueBits, _alphaBits, _depthBits, _stencilBits, _fullScreen ? "yes" : "no");

    auto version = glGetString(GL_VERSION);
    auto renderer = glGetString(GL_RENDERER);

    LeLog.WriteP("OpenGL version: %s, renderer: %s", version, renderer);

    return true;
}