예제 #1
0
void Render_drawFrame()
{
	FrameTime.ProfileEnd();
	double timeInSec = FrameTime.ProfileElapsedTime();
	
	FrameTime.ProfileBegin();

	SDL_SetRenderDrawColor(g_renderInfo.ren,0,0,0,255);
	SDL_RenderClear(g_renderInfo.ren);



	for(int i = 0 ; i< MAX_NOTES_ON_SCREEN ; i++)
	{
		SpriteInfo &currentSprite  = g_renderInfo.sprite_pool[i];

		if(currentSprite.visible == TRUE)
		{
			SetSprite_Color(currentSprite);
			SDL_SetRenderDrawColor(g_renderInfo.ren,currentSprite.color.r,currentSprite.color.g,currentSprite.color.b,currentSprite.color.a);
			currentSprite.rect.x =  currentSprite.SubBand * RENDER_BAND_WIDTH;

			currentSprite.rect.y = (int)(currentSprite.rect.y + NOTES_SPEED * timeInSec);
			currentSprite.rect.w = RENDER_BAND_WIDTH;
			currentSprite.rect.h = RENDER_BAND_HEIGHT;

			currentSprite.timeonScreen += timeInSec;

			if( currentSprite.timeonScreen > TIME_TO_EXIT_SCREEN -TIME_OFFSET_HIT)
			{
				double ammount = 1.0 -abs(TIME_TO_EXIT_SCREEN - currentSprite.timeonScreen)/(TIME_OFFSET_HIT*2);
				currentSprite.rect.h = (int)(RENDER_BAND_HEIGHT* HIT_NOTE_SIZE_MULTIPLICATOR * ammount);
			}
			if( currentSprite.timeonScreen > TIME_TO_EXIT_SCREEN +TIME_OFFSET_HIT)
			{
				currentSprite.rect.h = RENDER_BAND_HEIGHT;
			}

			if(TIME_TO_EXIT_SCENE < currentSprite.timeonScreen)
			{
				currentSprite.visible  = false;
			}

			SDL_RenderFillRect(g_renderInfo.ren,&g_renderInfo.sprite_pool[i].rect);
		}
	}

#ifdef DISPLAY_FPS
	char FPS[64] ={0};
	sprintf(FPS,"FPS:%f",(float)1.0/timeInSec);
	DrawDebugText(FPS,10, 50);
#endif

	SDL_RenderPresent(g_renderInfo.ren);

#ifdef USE_PROFILER
	g_Profiler.reset();
#endif
}
예제 #2
0
void SWRenderer::SwapBuffer()
{
	// Do our OSD callbacks
	OSD::DoCallbacks(OSD::OSD_ONFRAME);

	DrawDebugText();

	glFlush();

	GLInterface->Swap();

	swstats.ResetFrame();

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
예제 #3
0
    _Use_decl_annotations_
    void EndFrame(const std::shared_ptr<IGraphicsSystem>& graphics)
    {
        if (g_profilerEnabled)
        {
            static std::map<CodeTag, LARGE_INTEGER> combinedTime;
            combinedTime.clear();

            static LARGE_INTEGER frequency = { 0LL };
            if (frequency.QuadPart == 0LL)
            {
                QueryPerformanceFrequency(&frequency);
            }

            static std::shared_ptr<ISpriteFont> debugFont;
            if (debugFont == nullptr)
            {
                auto assetLoader = AssetLoader::Create();
                debugFont = assetLoader->LoadSpriteFontFromFile(graphics, L"font14.spritefont");
            }

            // Coalesce markers and tally stats
            for (uint32_t i = 0; i < static_cast<uint32_t>(CodeTag::Max); ++i)
            {
                CodeTag tag = static_cast<CodeTag>(i);

                ProfileEntry* entry = g_profileData;
                uint32_t recursionCount = 0;
                LARGE_INTEGER start = { 0LL };
                LARGE_INTEGER total = { 0LL };
                bool encountered = false;
                for (uint32_t n = 0; n < g_numProfileEntries; ++n, ++entry)
                {
                    if (entry->Tag == tag)
                    {
                        encountered = true;

                        if (entry->Begin)
                        {
                            ++recursionCount;
                        }
                        else
                        {
                            --recursionCount;
                        }

                        if (recursionCount == 1)
                        {
                            start = entry->Timestamp;
                        }
                        else if (recursionCount == 0)
                        {
                            total.QuadPart += (entry->Timestamp.QuadPart - start.QuadPart);
                        }
                    }
                }

                if (encountered)
                {
                    combinedTime[tag] = total;
                }
            }

            // Display stats (Just simple text now. Build better display laters)
            char message[100] = {};
            uint32_t y = 60;
            auto present = combinedTime.find(CodeTag::Present);
            for (auto& pair : combinedTime)
            {
                float time = pair.second.QuadPart * 1000.0f / static_cast<float>(frequency.QuadPart);

                if (pair.first == CodeTag::Draw && present != std::end(combinedTime))
                {
                    sprintf_s(message, "%s %3.2fms   Excl. Present: %3.2fms\n",
                        GetCodeTagName(pair.first),
                        time, time - (present->second.QuadPart * 1000.0f / static_cast<float>(frequency.QuadPart)));
                }
                else
                {
                    sprintf_s(message, "%s %3.2fms\n", GetCodeTagName(pair.first), pair.second.QuadPart * 1000.0f / static_cast<float>(frequency.QuadPart));
                }

                DrawDebugText(graphics, debugFont, 0, y, message);
                y += 20;
            }
        }
    }