void MFRenderer_EndFrame() { MFRenderer_EndFramePlatformSpecific(); // free scratch buffers MFVertex_EndFrame(); // calculate the high water mark for the scratch memory size_t size = gScratchMemoryOffset < gScratchMemoryMark ? gScratchMemorySize - gScratchMemoryMark + gScratchMemoryOffset : gScratchMemoryOffset - gScratchMemoryMark; gScratchMemoryPeak = MFMax(gScratchMemoryPeak, size); // move the render memory marker to the current offset gScratchMemoryMark = gScratchMemoryOffset; }
int MFRenderer_CreateDisplay() { // create the D3D device D3DPRESENT_PARAMETERS presentparams; HRESULT hr; MFZeroMemory(&presentparams, sizeof(D3DPRESENT_PARAMETERS)); presentparams.BackBufferWidth = gDisplay.width; presentparams.BackBufferHeight = gDisplay.height; presentparams.BackBufferFormat = (gDisplay.colourDepth == 32) ? D3DFMT_X8R8G8B8 : D3DFMT_R5G6B5; presentparams.BackBufferCount = 1; presentparams.MultiSampleType = D3DMULTISAMPLE_NONE; presentparams.SwapEffect = D3DSWAPEFFECT_DISCARD; presentparams.EnableAutoDepthStencil = TRUE; presentparams.AutoDepthStencilFormat = D3DFMT_D24S8; presentparams.FullScreen_RefreshRateInHz = gDisplay.refreshRate; presentparams.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE_OR_IMMEDIATE;// : D3DPRESENT_INTERVAL_IMMEDIATE; presentparams.Flags = (gDisplay.wide ? D3DPRESENTFLAG_WIDESCREEN : NULL) | (gDisplay.progressive ? D3DPRESENTFLAG_PROGRESSIVE : NULL); hr = d3d8->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, NULL, D3DCREATE_HARDWARE_VERTEXPROCESSING, &presentparams, &pd3dDevice); if(hr != D3D_OK) return 2; // clear frame buffers to black MFVector oldColour = gClearColour; MFRenderer_SetClearColour(0,0,0,0); MFRenderer_BeginFramePlatformSpecific(); MFRenderer_ClearScreen(CS_All); MFRenderer_EndFramePlatformSpecific(); MFRenderer_BeginFramePlatformSpecific(); MFRenderer_ClearScreen(CS_All); MFRenderer_EndFramePlatformSpecific(); MFRenderer_SetClearColour(oldColour.x, oldColour.y, oldColour.z, oldColour.w); return 0; }
MF_API void MFDebug_DebugAssert(const char *pReason, const char *pMessage, const char *pFile, int line) { MFDebug_Message(MFStr("%s(%d) : Assertion Failure.",pFile,line)); MFDebug_Message(MFStr("Failed Condition: %s\n%s", pReason, pMessage)); #if !defined(_RETAIL) MFCallstack_Log(); #endif #if defined(MF_LINUX) || defined(MF_OSX) MFDebug_Breakpoint(); #endif if(!MFFont_GetDebugFont()) return; while(!gQuit) { MFSystem_HandleEventsPlatformSpecific(); MFSystem_UpdateTimeDelta(); gFrameCount++; MFSystem_Update(); MFSystem_PostUpdate(); MFRenderer_BeginFramePlatformSpecific(); MFRenderer_SetClearColour(0,0,0,0); MFRenderer_ClearScreen(); MFView_SetDefault(); MFView_SetOrtho(); if(!(((uint32)gSystemTimer.GetSecondsF()) % 2)) { MFMaterial_SetMaterial(MFMaterial_GetStockMaterial(MFMat_White)); MFPrimitive(PT_QuadList); MFBegin(4); MFSetColour(1,0,0,1); MFSetPosition(50, 50, 0); MFSetPosition(590, 110, 0); MFSetColour(0,0,0,1); MFSetPosition(55, 55, 0); MFSetPosition(585, 105, 0); MFEnd(); } MFFont_DrawText2f(MFFont_GetDebugFont(), 110, 60, 20, MakeVector(1,0,0,1), "Software Failure. Press left mouse button to continue."); MFFont_DrawText2f(MFFont_GetDebugFont(), 240, 80, 20, MakeVector(1,0,0,1), "Guru Meditation: "); MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 120, 20, MakeVector(1,0,0,1), "Assertion Failure:"); MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 140, 20, MakeVector(1,0,0,1), MFStr("Failed Condition: %s", pReason)); MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 160, 20, MakeVector(1,0,0,1), MFStr("File: %s, Line: %d", pFile, line)); MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 190, 20, MakeVector(1,0,0,1), MFStr("Message: %s", pMessage)); #if !defined(_RETAIL) MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 230, 20, MakeVector(1,0,0,1), "Callstack:"); MFFont_DrawText2f(MFFont_GetDebugFont(), 100, 250.0f, 20, MakeVector(1,0,0,1), MFCallstack_GetCallstackString()); #else MFFont_DrawText2f(MFFont_GetDebugFont(), 80, 230, 20, MakeVector(1,0,0,1), "Callstack not available in RETAIL builds"); #endif // MFSystem_Draw(); MFRenderer_EndFramePlatformSpecific(); } }