Example #1
0
	void RenderVehicleHud (DemoEntityManager* const scene, int lineNumber) const
	{
		if (m_player) {
			// set to transparent color
			glEnable (GL_BLEND);
			glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

			//print controllers help 
			DrawHelp(scene, lineNumber);

			// restore color and blend mode
			glDisable (GL_BLEND);
		}
	}
Example #2
0
void GSShaderWave::DrawScene()
{
    AmjuGL::SetClearColour(Colour(0.5f, 1, 1, 1));
    DrawHelp();

    m_shader->Begin();
    Matrix mv;
    mv.ModelView();
    Matrix proj;
    proj.Projection();
    Matrix mat = mv * proj;
    m_shader->Set("modelViewProjectionMatrix", mat);

    static float shaderTime = 0;
    shaderTime += 0.01f;
    m_shader->Set("gTime", shaderTime);

    grid.Draw();
    m_shader->End();
}
Example #3
0
void MyApp::Draw()
{
	if(!FvRobotMainApp::pInstance())
		return;

	//! 修改窗口大小
	if(m_iResetWindowSize)
	{
		int w,h;
		GetWindowSize(w, h);

		if(m_iResetWindowSize & 0x1)
			w = FvRobotCfg::Instance().GetWindowSizeWidth();
		if(m_iResetWindowSize & 0x2)
			h = FvRobotCfg::Instance().GetWindowSizeHeight();

		SetWindowSize(w, h);
		m_iResetWindowSize = 0;
	}

	if(m_iShowMode == 0)
	{
		if(FvRobotCfg::Instance().GetSingleMode())
			DrawSingleMode();
		else
			DrawGlobalMode();
	}
	else if(m_iShowMode == 1)
	{
		DrawHelp();
	}
	else
	{
		DrawConfig();
	}
}
Example #4
0
//------------------------------------------------------------------------------
void NBodyWnd::Render()
{
    static long ct = 0;
    if (!(m_flags & dspPAUSE))
    {
        ++ct;

        if (m_bDumpImage && ct%5==0)
            SaveToTGA();
    }

    glClear(GL_COLOR_BUFFER_BIT  | GL_DEPTH_BUFFER_BIT);

    Vec3D orient;
    switch (m_camOrient)
    {
    // Default orientation
    case 0:
        orient.x = 0;
        orient.y = 1;
        orient.z = 0;
        break;

    // Rotate with galaxy core
    case 1:
    {
        Vec2D p1 = m_galaxy.GetStarPos(0),
              p2 = m_galaxy.GetStarPos(1);
        orient.x = p2.x - p1.x;
        orient.y = p2.y - p1.y;
        orient.z = 0;
    }
    break;

    // Rotate with edge of disk
    case 2:
    {
        Vec2D p1 = m_galaxy.GetStarPos(0),
              p2 = m_galaxy.GetStarPos(2);
        orient.x = p2.x - p1.x;
        orient.y = p2.y - p1.y;
        orient.z = 0;
    }
    break;
    }

    Vec3D lookAt(0, 0, 0),
          pos(0, 0, 5000);
    SetCamera(pos, lookAt, orient);

    if (!(m_flags & dspPAUSE))
    {
        m_galaxy.SingleTimeStep(100000); // time in years
    }

    if (m_flags & dspAXIS)
        DrawAxis(Vec2D(0, 0));

    if (m_flags & dspDENSITY_WAVES)
        DrawDensityWaves(50, m_galaxy.GetFarFieldRad());

    if (m_flags & dspSTAT)
        DrawStat();

    if (m_flags & dspDUST)
        DrawDust();

    if (m_flags & dspH2)
        DrawH2();

    if (m_flags & dspSTARS)
        DrawStars();

    if (m_flags & dspRADII)
        DrawGalaxyRadii();

    if (m_flags & dspVELOCITY)
        DrawVelocity();

    if (m_flags & dspHELP)
        DrawHelp();

    SDL_GL_SwapBuffers();
}
void C4GraphicsSystem::Execute()
	{
	// activity check
	if (!StartDrawing()) return;

	bool fBGDrawn = false;

	// If lobby running, message board only (page flip done by startup message board)
	if (!Game.pGUI || !Game.pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI
		if(Game.Network.isLobbyActive() || !Game.IsRunning)
			if (Application.isFullScreen)
				{
				// Message board
				if (iRedrawBackground) ClearFullscreenBackground();
				MessageBoard.Execute();
				if (!Game.pGUI || !C4GUI::IsActive())
					{ FinishDrawing(); return; }
				fBGDrawn = true;
				}

	// fullscreen GUI?
	if (Application.isFullScreen && Game.pGUI && C4GUI::IsActive() && (Game.pGUI->HasFullscreenDialog(false) || !Game.IsRunning))
		{  
		if (!fBGDrawn && iRedrawBackground) ClearFullscreenBackground();
		Game.pGUI->Render(!fBGDrawn);
		FinishDrawing();
		return;
		}

	// Fixed screen rate in old network
	ScreenRate = 1;

	// Background redraw
	if (Application.isFullScreen)
		if (iRedrawBackground)
			DrawFullscreenBackground();

	// Screen rate skip frame draw
	ScreenTick++; if (ScreenTick>=ScreenRate) ScreenTick=0;

	// Reset object audibility
	Game.Objects.ResetAudibility();

	// some hack to ensure the mouse is drawn after a dialog close and before any
	// movement messages
	if (Game.pGUI && !C4GUI::IsActive())
		SetMouseInGUI(false, false);

	// Viewports
	for (C4Viewport *cvp=FirstViewport; cvp; cvp=cvp->Next)	
		cvp->Execute();

	if (Application.isFullScreen)
		{
		// Upper board
		UpperBoard.Execute();

		// Message board
		MessageBoard.Execute();

		// Help & Messages
		DrawHelp();
		DrawHoldMessages();
		DrawFlashMessage();
		}

	// InGame-GUI
	if (Game.pGUI && C4GUI::IsActive())
		{  
		Game.pGUI->Render(false);
		}

	// Palette update
	if (fSetPalette) { SetPalette(); /*SetDarkColorTable();*/ fSetPalette=FALSE; }

	// gamma update
	if (fSetGamma)
		{
		ApplyGamma();
		fSetGamma=FALSE;
		}

	// Video record & status (fullsrceen)
	if (Application.isFullScreen)
		Video.Execute();
	
	// done
	FinishDrawing();
	}
void C4GraphicsSystem::Execute()
{
	// activity check
	if (!StartDrawing()) return;

	bool fBGDrawn = false;

	// If lobby running, message board only (page flip done by startup message board)
	if (!::pGUI->HasFullscreenDialog(true)) // allow for message board behind GUI
		if (::Network.isLobbyActive() || !Game.IsRunning)
			if (!Application.isEditor)
			{
				// Message board
				if (iRedrawBackground) ClearFullscreenBackground();
				MessageBoard->Execute();
				if (!C4GUI::IsActive())
					{ FinishDrawing(); return; }
				fBGDrawn = true;
			}

	// fullscreen GUI?
	if (!Application.isEditor && C4GUI::IsActive() && (::pGUI->HasFullscreenDialog(false) || !Game.IsRunning))
	{
		if (!fBGDrawn && iRedrawBackground) ClearFullscreenBackground();
		::pGUI->Render(!fBGDrawn);
		FinishDrawing();
		return;
	}


	// Reset object audibility
	::Objects.ResetAudibility();

	// some hack to ensure the mouse is drawn after a dialog close and before any
	// movement messages
	if (!C4GUI::IsActive())
		::pGUI->SetMouseInGUI(false, false);

	// Viewports
	::Viewports.Execute(!Application.isEditor && iRedrawBackground);
	if (iRedrawBackground) --iRedrawBackground;

	if (!Application.isEditor)
	{
		// Upper board
		UpperBoard.Execute();

		// Message board
		MessageBoard->Execute();

		// Help & Messages
		DrawHelp();
		DrawHoldMessages();
		DrawFlashMessage();
	}

	// InGame-GUI
	if (C4GUI::IsActive())
	{
		::pGUI->Render(false);
	}

	// done
	FinishDrawing();
}
Example #7
0
int main(int argc, char* argv[])
{
	SDL_Init(SDL_INIT_EVERYTHING);

	SDL_Window *window = SDL_CreateWindow("Ritual", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, RES_X, RES_Y, 0);
	SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);

	int ww, hh;
	errorTextures[0] = ImgToTex(renderer, "assets/error1.png", ww, hh);
	errorTextures[1] = ImgToTex(renderer, "assets/error1.png", ww, hh);
	errorTextures[2] = ImgToTex(renderer, "assets/error2.png", ww, hh);
	errorTextures[3] = ImgToTex(renderer, "assets/error3.png", ww, hh);
	errorTextures[4] = ImgToTex(renderer, "assets/error4.png", ww, hh);
	errorTextures[5] = ImgToTex(renderer, "assets/error5.png", ww, hh);
	errorTextures[6] = ImgToTex(renderer, "assets/error6.png", ww, hh);
	errorTextures[7] = ImgToTex(renderer, "assets/error7.png", ww, hh);
	errorTextures[8] = ImgToTex(renderer, "assets/error8.png", ww, hh);
	helpTexture = ImgToTex(renderer, "assets/help.png", ww, hh);
	deathTexture = ImgToTex(renderer, "assets/gameover.png", ww, hh);

	bool quit = false;

	g_world = new World(renderer, "assets/map");
	g_scrub = new Scrub(renderer, g_world);
	//for (int i = 0; i < 5; i++)
	g_buttons[0] = new Button(renderer, "assets/tower3.png", 100, 100 + 0 * 110, 100, 100);
	g_buttons[1] = new Button(renderer, "assets/tower1_icon.png", 100, 100 + 1 * 110, 100, 100);
	g_buttons[2] = new Button(renderer, "assets/tower2_icon.png", 100, 100 + 2 * 110, 100, 100);
	g_buttons[3] = new Button(renderer, "assets/tower4_icon.png", 100, 100 + 3 * 110, 100, 100);

	g_playpause[0] = new Button(renderer, "assets/play.png", RES_X - 280, RES_Y - 200, 80, 80);
	g_playpause[1] = new Button(renderer, "assets/pause.png", RES_X - 180, RES_Y - 200, 80, 80);

	InitNav();
	InitSim();

	unsigned long long perfCnt = SDL_GetPerformanceCounter();
	unsigned long long perfFreq = SDL_GetPerformanceFrequency();
	nowTime = double(perfCnt) / double(perfFreq);

	SDL_Surface *winSurf = SDL_GetWindowSurface(window);

	bool win = false;

	for (;;) {

		double lastTime = nowTime;
		perfCnt = SDL_GetPerformanceCounter();
		perfFreq = SDL_GetPerformanceFrequency();
		nowTime = double(perfCnt) / double(perfFreq);
		double ddeltatime = nowTime - lastTime;
		ddeltatime = ddeltatime > 0.1 ? 0.1 : ddeltatime;

		SDL_Event event;
		while (SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT) {
				quit = 1;
				break;
			}
			if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_ESCAPE)
				quit = true;
			if (!isDead) {
				if (g_scrub->Event(event)) continue;
				bool eatenByButton = false;
				for (int i = 0; i < nButtons; i++) {
					bool hit = g_buttons[i]->Event(event);
					if (hit)
						selectedButton = i;
					eatenByButton |= hit;
				}
				if (eatenByButton)
					continue;
				if (g_playpause[0]->Event(event)) {
					isPlaying = true;
					continue;
				}
				if (g_playpause[1]->Event(event)) {
					isPlaying = false;
					continue;
				}
				if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_SPACE) {
					isPlaying = !isPlaying;
				}
				if (g_scrub->Event(event)) continue;
				if (!win) {
					if (g_world->Event(event, selectedButton)) continue;
				}
			}
		}
		if (quit)
			break;

		if (isPlaying) {
			float t0 = g_scrub->mTime;
			g_scrub->AdvanceTime(float(ddeltatime));
			float t1 = g_scrub->mTime;
			PlaySimulationSounds(t0, t1);
		}

		SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
		SDL_RenderClear(renderer);

		g_world->Draw(renderer);
		if (!g_scrub->mClaimedMouse)
			g_world->DrawMarker(renderer);
		g_scrub->Draw(renderer, selectedButton, float(nowTime));
		for (int i = 0; i < nButtons; i++)
			g_buttons[i]->Draw(renderer, i == selectedButton);
		g_playpause[0]->Draw(renderer, isPlaying);
		g_playpause[1]->Draw(renderer, !isPlaying);
#ifdef _DEBUG
		SimDebugDraw(renderer, g_scrub->mTime);
#endif

		if (win) {
			ShowErrorMessage(errWin);
			static bool firstWin = true;
			if (firstWin) {
				g_world->myAudioManager.PlaySound("assets/audio/win.mp3", false);
				firstWin = false;
			}

		}
		else {
			if (GetGameOverTime() / g_scrub->mTotalTime >= 1.0f)
				win = true;
		}

		DrawErrorMessage(renderer);
		DrawHelp(renderer);
		DrawDeath(renderer);

		SDL_RenderPresent(renderer);
	}

    return 0;
}