Esempio n. 1
0
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int){

	SetWindowText("Title");
	SetGraphMode(WINDOW_WIDTH , WINDOW_HEIGHT,32 );
	ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen( DX_SCREEN_BACK );

	int LoadImage = LoadGraph("Natsuiro/BLOCK/load.png");
	DrawExtendGraph(0,0,WINDOW_WIDTH,WINDOW_HEIGHT, LoadImage ,false);
	ScreenFlip();
	
	SetTransColor(255,0,255);
	Awake();

	long long TIME = GetNowHiPerformanceCount();
#	if	BENCHMARK == TRUE
	long long int count = GetNowCount();
#	endif

	while( ScreenFlip()==0 && ProcessMessage()==0 && ClearDrawScreen()==0 && !CheckHitKey(KEY_INPUT_ESCAPE) ){
		GameLoop();
		Sleep( (unsigned long)max( 16 - (int)( GetNowHiPerformanceCount() - TIME ) / 1000 , 0 ) );
		TIME = GetNowHiPerformanceCount();

#		if BENCHMARK == TRUE
		DrawFormatString(WINDOW_WIDTH-200,0,BLACK,"FPS %d (%dms)", (int)( 1000/( GetNowCount() - count ) ) , GetNowCount() - count );
		count = GetNowCount();
#		endif

	}
        
	DxLib_End();
	return 0;
} 
void H264Thread::Release()
{
    Reset();

    if (IsValid())
    {
        m_bQuit = true;
        Awake();
        Wait();
    }

    Close();
} // void Release(void)
Esempio n. 3
0
bool MsgThread::Stop() {
	std::lock_guard<std::mutex> lock(m_mutex);

	if(m_stopped) {
		return false;
	}

	// wake up maybe sleeping thread
	m_running = false;
	Awake();

	m_worker.join();
	m_stopped = true;

	return true;
}
Esempio n. 4
0
	HRESULT	Atom::Init( char const *settingsFile )
	{
		ATOM_LOG("%s\n", __FUNCTION__);
		HRESULT	hr;

#ifdef _DEBUG
		SetCRTDebugFlags(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
		OpenSysConsole();
#endif

		// memory manager
		memory::MemoryInfo	meminfo;
		memory::GetMemoryInfo(meminfo);

		// logger - lol
		logger::Init();
		ATOM_LOG("peak: %d, working: %d, load: %d\n", meminfo.peakMemUsage, meminfo.workingMemUsage, meminfo.memoryLoad);

		// load settings from file
		settings::Init();
		g_settings.load(settingsFile);

		// create and open application window
		HR_H(hr, m_appWindow.Create(m_hInstance, AtomWindowProc, this), Destroy());

		// initialize rawinput
		HR_H(hr, m_inputHandler.Init(m_appWindow.GetHandle()), Destroy());

		// init renderer
		renderer::Init();
		HR_H(hr, g_renderer.Create(m_appWindow.GetHandle()), Destroy());

#ifndef _DEBUG
		if (g_settings.enableLeakCheck)
			SetCRTDebugFlags(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
		if (g_settings.attachConsole)
			OpenSysConsole();
#endif

		atom::InitRand();

		return Awake();
	}
Esempio n. 5
0
void RUN()
{
/*RUN - this in the game control loop, it calls the Awake() function once to
	initialise all the modules and then calls the Update() function over and over
	until the game ends.*/

	//int gameOver = 0; // gameOver = 1
	GameState gameState = Awake ();

  while(OBJECTS->pauseMenu->exitGame == false && OBJECTS->titleMenu->exitGame == false){
    Update(gameState);
    if(Mix_PlayingMusic() == 0){
      Mix_PlayMusic(OBJECTS->gameSounds->music, -1);
    }
  }

  sleep(1);
  Free_Memory(OBJECTS);
}