示例#1
0
void Game::PrintPerf()
{
	++perfFrameCount;
	if ( perfFrameCount == 10 ) {
		std::string str = PROFILE_GET_TREE_STRING();
		profile = str.c_str();
		perfFrameCount = 0;
	}
	char buf[512];

	static const int X = 250;
	static const int Y = 100;

	const char* p = profile.c_str();
	const char* end = p + profile.size();

	UFOText* ufoText = UFOText::Instance();
	int perfY = 0;

	while( p < end ) {
		char* q = buf;
		while( p < end && *p != '\n' ) {
			*q++ = *p++;
		}
		*q = 0;
		ufoText->Draw( X, Y+perfY, "%s", buf );
		perfY += 16;
		++p;
	}
}
示例#2
0
void Scene::DrawDebugTextDrawCalls( int x, int y, Engine* engine )
{
    UFOText* ufoText = UFOText::Instance();
    ufoText->Draw( x, y, "Model Draw Calls glow-em=%d shadow=%d model=%d nPart=%d",
                   engine->modelDrawCalls[Engine::GLOW_EMISSIVE],
                   engine->modelDrawCalls[Engine::SHADOW],
                   engine->modelDrawCalls[Engine::MODELS],
                   engine->particleSystem->NumParticles() );
}
示例#3
0
void Game::DoTick( U32 _currentTime )
{
	GPUDevice* device = GPUDevice::Instance();
	{
		//GRINLIZ_PERFTRACK
		PROFILE_FUNC();

		currentTime = _currentTime;
		if ( previousTime == 0 ) {
			previousTime = currentTime-1;
		}
		U32 deltaTime = currentTime - previousTime;

		if ( markFrameTime == 0 ) {
			markFrameTime			= currentTime;
			frameCountsSinceMark	= 0;
			framesPerSecond			= 0.0f;
		}
		else {
			++frameCountsSinceMark;
			if ( currentTime - markFrameTime > 500 ) {
				framesPerSecond		= 1000.0f*(float)(frameCountsSinceMark) / ((float)(currentTime - markFrameTime));
				// actually K-tris/second
				markFrameTime		= currentTime;
				frameCountsSinceMark = 0;
			}
		}

		// Limit so we don't ever get big jumps:
		if ( deltaTime > 100 )
			deltaTime = 100;

		device->ResetState();

		Scene* scene = sceneStack.Top()->scene;

		Color4F cc = scene->ClearColor();
		device->Clear( cc.x, cc.y, cc.z, cc.w );

		scene->DoTick( deltaTime );

		{
			//GRINLIZ_PERFTRACK_NAME( "Game::DoTick 3D" );
			PROFILE_BLOCK( DoTick3D );

			screenport.SetPerspective();
			scene->Draw3D( deltaTime );
		}

		{
			//GRINLIZ_PERFTRACK_NAME( "Game::DoTick UI" );
			PROFILE_BLOCK( DoTickUI );
			GLASSERT( scene );

			// UI Pass
			screenport.SetUI(); 

			if ( renderUI ) {
				screenport.SetUI();
				scene->RenderGamui2D();
			}
		}
	}

	int Y = 0;
	int space = 16;
	#ifndef GRINLIZ_DEBUG_MEM
//	const int memNewCount = 0;
	#endif
#if 1
	UFOText* ufoText = UFOText::Instance();
	if (SettingsManager::Instance()->DebugFPS()) {
		ufoText->Draw(0, Y, "%s %5.1ffps %4.1fK/f %3ddc/f fver=%d",
					  VERSION,
					  framesPerSecond,
					  (float)device->TrianglesDrawn() / 1000.0f,
					  device->DrawCalls(),
					  CURRENT_FILE_VERSION);
	}
	if ( debugText ) {
		sceneStack.Top()->scene->DrawDebugText();
	}
	Y += space;
#endif

#ifdef EL_SHOW_MODELS
	int k=0;
	while ( k < nModelResource ) {
		int total = 0;
		for( unsigned i=0; i<modelResource[k].nGroups; ++i ) {
			total += modelResource[k].atom[i].trisRendered;
		}
		UFODrawText( 0, 12+12*k, "%16s %5d K", modelResource[k].name, total );
		++k;
	}
#endif

#ifdef GRINLIZ_PROFILE
	PROFILE_UPDATE();

	if ( perfText ) {
		PrintPerf();
	}
#endif
	screenport.SetUI();
	UFOText::Instance()->FinalDraw();

	device->ResetTriCount();
	previousTime = currentTime;

	PushPopScene();
}