void MFCallstackInternal_DrawMeterLabel(const MFVector &listPos, const MFVector &colour, const char *pString, const char *pStats) { MFPrimitive_DrawUntexturedQuad(listPos.x, listPos.y + 1.0f, listPos.x + 14.0f, listPos.y + 15.0f, MFVector::one); MFPrimitive_DrawUntexturedQuad(listPos.x + 2, listPos.y + 3.0f, listPos.x + 12.0f, listPos.y + 13.0f, colour); MFFont_DrawTextf(MFFont_GetDebugFont(), listPos + MakeVector(16.0f, 0.0f, 0.0f), 16.0f, MFVector::one, pString); if(pStats) { float width = (float)MFDisplay_GetDisplaySettings()->width; MFFont_DrawTextf(MFFont_GetDebugFont(), listPos + MakeVector((width - listPos.x) - 250.0f, 0.0f, 0.0f), 16.0f, MFVector::one, pStats); } }
float MenuItemColour::ListDraw(bool selected, const MFVector &_pos, float maxWidth) { MFVector pos = _pos; MFFont_DrawText(MFFont_GetDebugFont(), pos+MakeVector(0.0f, MENU_FONT_HEIGHT*0.25f, 0.0f), MENU_FONT_HEIGHT, selected ? MakeVector(1,1,0,1) : MFVector::one, MFStr("%s: 0x%08X", name, pData->ToPackedColour())); pos += MakeVector(maxWidth - 55.0f, 2.0f, 0.0f); MFPrimitive(PT_TriStrip|PT_Untextured); MFBegin(4); MFSetColourV(MFVector::white); MFSetPositionV(pos); MFSetPositionV(pos + MakeVector(45.0f, 0.0f, 0.0f)); MFSetPositionV(pos + MakeVector(0.0f, MENU_FONT_HEIGHT*1.5f-4.0f, 0.0f)); MFSetPositionV(pos + MakeVector(45.0f, MENU_FONT_HEIGHT*1.5f-4.0f, 0.0f)); MFEnd(); pos += MakeVector(2.0f, 2.0f, 0.0f); MFBegin(4); MFSetColourV(*pData); MFSetPositionV(pos); MFSetPositionV(pos + MakeVector(41.0f, 0.0f, 0.0f)); MFSetPositionV(pos + MakeVector(0.0f, MENU_FONT_HEIGHT*1.5f-8.0f, 0.0f)); MFSetPositionV(pos + MakeVector(41.0f, MENU_FONT_HEIGHT*1.5f-8.0f, 0.0f)); MFEnd(); return MENU_FONT_HEIGHT*1.5f; }
void Game_Draw() { if(!bShowModel) { MFView_SetOrtho(); // draw model list if(models.size() > 0) { for(int a=0; a<(int)models.size(); ++a) { MFFont_DrawText2(MFFont_GetDebugFont(), 100.f, 100.f + (-menuIndex*20 + a*20), 20.f, a == menuIndex ? MFVector::yellow : MFVector::white, models[a].CStr()); } } else { MFFont_DrawText2(MFFont_GetDebugFont(), 100.f, 100.f, 20.f, MFVector::red, "No models found!"); } } else { if(pModel) { // set projection MFView_ConfigureProjection(MFDEGREES(60.f), 0.1f, 10000.f); MFView_SetAspectRatio(MFDisplay_GetNativeAspectRatio()); MFView_SetProjection(); // render the mesh MFRenderer_AddModel(pModel, NULL, MFView_GetViewState()); } else { MFView_SetOrtho(); MFFont_DrawText2(MFFont_GetDebugFont(), 100.f, 100.f, 20.f, MFVector::red, "Failed to load model!"); } } }
HKWidgetLabel::HKWidgetLabel(HKWidgetType *pType) : HKWidget(pType) { textColour = MFVector::black; pFont = MFFont_GetDebugFont(); bOwnFont = false; textJustification = MFFontJustify_Top_Left; bAutoTextHeight = true; textHeight = MFFont_GetFontHeight(pFont); shadowDepth = 0.f; if(bAutoHeight) UpdateHeight(textHeight); }
void Game_Draw() { MFCALLSTACK; // set clear colour and clear the screen MFRenderer_SetClearColour(0.f, 0.f, 0.2f, 1.f); MFRenderer_ClearScreen(); // push current view onto the stack MFView_Push(); // set orthographic projection MFView_SetOrtho(); // render some text MFFont_DrawText2(MFFont_GetDebugFont(), 200.f, 200.f, 50.f, MFVector::one, "Hello World!"); // pop the current view MFView_Pop(); }
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(); } }
void Game_Draw() { MFView_SetOrtho(); const char *pText; float x, y; int a, b; x = 30.0f; for(a=0; a<MFInput_GetNumGamepads(); a++) { if(MFInput_IsAvailable(IDD_Gamepad, a)) { MFFont_DrawText2(MFFont_GetDebugFont(), x-10.0f, 15.0f, 15.0f, MFVector::one, MFStr("%s (%d):", MFInput_GetDeviceName(IDD_Gamepad,a), a)); if(MFInput_IsReady(IDD_Gamepad, a)) { y = 30.0f; for(b=0; b<GamepadType_Max; b++) { float value = MFInput_Read(b, IDD_Gamepad, a); // int ival = (int)(value * 255.f); // MFFont_DrawText2(MFFont_GetDebugFont(), x, y, 15.0f, MFVector::one, MFStr("%s: %.3g - %d (0x%02X)", MFInput_EnumerateString(b, IDD_Gamepad, a), value, ival, ival)); MFFont_DrawText2(MFFont_GetDebugFont(), x, y, 15.0f, MFVector::one, MFStr("%s: %.3g", MFInput_EnumerateString(b, IDD_Gamepad, a), value)); y += 15.0f; } } else { MFFont_DrawText2(MFFont_GetDebugFont(), x, 30.0f, 15.0f, MakeVector(1.0f, 0.0f, 0.0f, 1.0f), "Disconnected..."); } x += 170.0f; } } int numMouses = MFInput_GetNumPointers(); x = 80.0f; for(a=0; a<numMouses; a++) { MFFont_DrawText2(MFFont_GetDebugFont(), x, 355.0f, 15.0f, MFVector::one, MFStr("Mouse Pos: %g, %g", MFInput_Read(Mouse_XPos, IDD_Mouse, a), MFInput_Read(Mouse_YPos, IDD_Mouse, a))); MFFont_DrawText2(MFFont_GetDebugFont(), x, 370.0f, 15.0f, MFVector::one, MFStr("Mouse Delta: %g, %g", MFInput_Read(Mouse_XDelta, IDD_Mouse, a), MFInput_Read(Mouse_YDelta, IDD_Mouse, a))); MFFont_DrawText2(MFFont_GetDebugFont(), x, 385.0f, 15.0f, MFVector::one, MFStr("Mouse Wheel: %g, %g", MFInput_Read(Mouse_Wheel, IDD_Mouse, a), MFInput_Read(Mouse_Wheel2, IDD_Mouse, a))); pText = "Mouse Buttons:"; for(b=Mouse_MaxAxis; b<Mouse_Max; b++) { if(MFInput_Read(b, IDD_Mouse, a)) { pText = MFStr("%s %s", pText, MFInput_EnumerateString(b, IDD_Mouse, a)); } } MFFont_DrawText2(MFFont_GetDebugFont(), x, 400.0f, 15.0f, MFVector::one, pText); x += 170.0f; } pText = "Keys:"; for(a=0; a<Key_Max; a++) { if(MFInput_Read(a, IDD_Keyboard, 0)) { pText = MFStr("%s %s", pText, MFInput_EnumerateString(a, IDD_Keyboard, 0)); } } MFFont_DrawText2(MFFont_GetDebugFont(), 80.0f, 430.0f, 15.0f, MFVector::one, pText); }
// MenuItemPosition2D float MenuItemPosition2D::ListDraw(bool selected, const MFVector &pos, float maxWidth) { MFFont_DrawText(MFFont_GetDebugFont(), pos, MENU_FONT_HEIGHT, selected ? MakeVector(1,1,0,1) : MFVector::one, MFStr("%s: %.2f, %.2f", name, pData->x, pData->y)); return MENU_FONT_HEIGHT; }
// MenuItemIntString float MenuItemIntString::ListDraw(bool selected, const MFVector &pos, float maxWidth) { MFFont_DrawText(MFFont_GetDebugFont(), pos, MENU_FONT_HEIGHT, selected ? MakeVector(1,1,0,1) : MFVector::one, MFStr("%s: %s", name, ppValues[data])); return MENU_FONT_HEIGHT; }
// MenuItemBool float MenuItemBool::ListDraw(bool selected, const MFVector &pos, float maxWidth) { MFFont_DrawText(MFFont_GetDebugFont(), pos, MENU_FONT_HEIGHT, selected ? MakeVector(1,1,0,1) : MFVector::one, MFStr("%s: %s", name, data ? "true" : "false")); return MENU_FONT_HEIGHT; }
// MenuItemStatic float MenuItemStatic::ListDraw(bool selected, const MFVector &pos, float maxWidth) { MFFont_DrawText(MFFont_GetDebugFont(), pos, MENU_FONT_HEIGHT, selected ? MakeVector(1,1,0,1) : MFVector::one, name); return MENU_FONT_HEIGHT; }
void Menu::Draw() { MFVector dimensions = MakeVector(0.0f, 0.0f, 0.0f); MFVector currentPos; float requestedWidth = menuDimensions.x-40.0f; float selStart, selEnd; int a; // get menu size for(a=0; a<numChildren; a++) { MFVector dim = pChildren[a]->GetDimensions(requestedWidth); if(selection==a) { selStart = dimensions.y; selEnd = selStart + dim.y; if(selStart < -yOffset) { targetOffset = -selStart; } if(selEnd > menuDimensions.y - 75.0f - yOffset) { targetOffset = -(selEnd-(menuDimensions.y-75.0f)); } } dimensions.y += dim.y; dimensions.x = MFMax(dimensions.x, dim.x); } if(targetOffset != yOffset) { yOffset -= MFAbs(yOffset-targetOffset) < 0.1f ? yOffset-targetOffset : (yOffset-targetOffset)*0.1f; } currentPos = MakeVector(menuPosition.x+20.0f, menuPosition.y+50.0f + yOffset, 0.0f); MFPrimitive(PT_TriStrip|PT_Untextured); MFBegin(4); MFSetColourV(colour*0.4f); MFSetPosition(menuPosition.x, menuPosition.y, 0); MFSetColourV(colour*0.8f); MFSetPosition(menuPosition.x+menuDimensions.x, menuPosition.y, 0); MFSetColourV(colour*0.6f); MFSetPosition(menuPosition.x, menuPosition.y+menuDimensions.y, 0); MFSetColourV(colour); MFSetPosition(menuPosition.x+menuDimensions.x, menuPosition.y+menuDimensions.y, 0); MFEnd(); MFFont_DrawText2(MFFont_GetDebugFont(), menuPosition.x+10.0f, menuPosition.y+5.0f, MENU_FONT_HEIGHT*1.5f, MakeVector(1,0.6875f,0.5f,1), name); MFMaterial_SetMaterial(MFMaterial_GetStockMaterial(MFMat_SysLogoSmall)); float logoMargin = 5.0f; float iconSize = 35.0f; MFPrimitive(PT_TriStrip); MFBegin(4); MFSetColourV(MFVector::white); MFSetTexCoord1(0,0); MFSetPosition((menuPosition.x+menuDimensions.x) - logoMargin*2 - iconSize, menuPosition.y + logoMargin, 0); MFSetTexCoord1(1,0); MFSetPosition((menuPosition.x+menuDimensions.x) - logoMargin*2, menuPosition.y + logoMargin, 0); MFSetTexCoord1(0,1); MFSetPosition((menuPosition.x+menuDimensions.x) - logoMargin*2 - iconSize, menuPosition.y + logoMargin + iconSize, 0); MFSetTexCoord1(1,1); MFSetPosition((menuPosition.x+menuDimensions.x) - logoMargin*2, menuPosition.y + logoMargin + iconSize, 0); MFEnd(); #if MF_RENDERER == MF_DRIVER_D3D9 || MF_RENDERER == MF_DRIVER_XBOX pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, TRUE); pd3dDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_ALWAYS); pd3dDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCR); #endif MFPrimitive(PT_TriStrip|PT_Untextured); MFBegin(4); MFSetColour(0.f, 0.f, 0.f, 0.65f); MFSetPosition(menuPosition.x+15, menuPosition.y+45, 0); MFSetPosition(menuPosition.x+menuDimensions.x-15, menuPosition.y+45, 0); MFSetPosition(menuPosition.x+15, menuPosition.y+menuDimensions.y-15, 0); MFSetPosition(menuPosition.x+menuDimensions.x-15, menuPosition.y+menuDimensions.y-15, 0); MFEnd(); #if MF_RENDERER == MF_DRIVER_D3D9 || MF_RENDERER == MF_DRIVER_XBOX pd3dDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESS); pd3dDevice->SetRenderState(D3DRS_STENCILREF, 0); #endif for(a=0; a<numChildren; a++) { if(currentPos.y > menuPosition.y + menuDimensions.y - 15.0f) break; if(selection==a) { float height = pChildren[a]->GetDimensions(requestedWidth).y; if(currentPos.y + height < menuPosition.y + 45.0f) { currentPos.y += height; continue; } MFPrimitive(PT_TriStrip|PT_Untextured); MFBegin(4); MFSetColour(0.f, 0.f, .5f, .75f); MFSetPosition(menuPosition.x+15, currentPos.y, 0); MFSetColour(0.f, 0.f, .8f, .75f); MFSetPosition(menuPosition.x+menuDimensions.x-15, currentPos.y, 0); MFSetColour(0.f, 0.f, .56f, .75f); MFSetPosition(menuPosition.x+15, currentPos.y + height, 0); MFSetColour(0.f, 0.f, .1f, .75f); MFSetPosition(menuPosition.x+menuDimensions.x-15, currentPos.y + height, 0); MFEnd(); } currentPos.y += pChildren[a]->ListDraw(selection==a, currentPos, requestedWidth); } #if MF_RENDERER == MF_DRIVER_D3D9 || MF_RENDERER == MF_DRIVER_XBOX pd3dDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE); #endif }
float Menu::ListDraw(bool selected, const MFVector &pos, float maxWidth) { MFFont_DrawText(MFFont_GetDebugFont(), pos, MENU_FONT_HEIGHT, selected ? MakeVector(1,1,0,1) : folderColour, name); return MENU_FONT_HEIGHT; }
void MFCallstack_Draw() { MFCALLSTACK; if(drawCallstack) { const MFDisplaySettings *pDisplaySettings = MFDisplay_GetDisplaySettings(); float width = (float)pDisplaySettings->width; float height = (float)pDisplaySettings->height; float xoffset = width / 10.0f; float yoffset = height / 6.0f; MFView_Push(); MFRect rect = { 0.f, 0.f, width, height }; MFView_SetOrtho(&rect); float rtcFreq = 1000000.f / (float)MFSystem_GetRTCFrequency(); MFVector callstackPos = MakeVector(xoffset, yoffset, 0.f, 0.f); // sort the calls qsort(gpProfiles, gNumProfileFunctions, sizeof(gpProfiles[0]), MFCallstack_SortPred); // if(!drawCallstackMeter) { // just draw the callstack profiling information.. MFPrimitive_DrawUntexturedQuad(callstackPos.x - 10.f, callstackPos.y - 10.f, (width - callstackPos.x) + 10, callstackPos.y + (float)gNumProfileFunctions*16.0f + 10, MakeVector(0, 0, 0, 0.8f)); for(int a=0; a<gNumProfileFunctions; a++) { uint32 microseconds = uint32((float)gpProfiles[a]->totalTime * rtcFreq); uint32 percent = uint32((float)microseconds / 166.66666f); // MFVector colour = gProfileColours[gpProfiles[a]->functionColour]; MFVector colour = MFVector::one; MFFont_DrawTextf(MFFont_GetDebugFont(), callstackPos, 16.0f, colour, "%s", gpProfiles[a]->pFunctionName); MFFont_DrawTextf(MFFont_GetDebugFont(), callstackPos + MakeVector((width - xoffset) - 250.0f, 0, 0), 16.0f, colour, "- %dus (%d%%) %d calls", microseconds, percent, gpProfiles[a]->numCalls); callstackPos.y += 16.0f; } } /* else { // draw a meter up the top of the screen representing the frame.. MFPrimitive_DrawUntexturedQuad(callstackPos.x - 10.f, callstackPos.y - 10.f, width - callstackPos.x + 10, callstackPos.y + (float)(gNumProfileTotals+1)*16.0f + 18, MakeVector(0, 0, 0, 0.8f)); MFVector meterPos = MakeVector(xoffset - 8.f, yoffset*0.5f - 15.0f, 0.0f); MFVector meterDimensions = MakeVector(width - (xoffset-8.0f)*2.0f, 20.0f, 0.0f); // draw the meter container MFPrimitive_DrawUntexturedQuad(meterPos.x - 2.0f, meterPos.y - 2.0f, meterPos.x + meterDimensions.x + 2.0f, meterPos.y + meterDimensions.y + 2.0f, MakeVector(1.0f, 1.0f, 1.0f, 0.8f)); MFPrimitive_DrawUntexturedQuad(meterPos.x, meterPos.y, meterPos.x + meterDimensions.x, meterPos.y + meterDimensions.y, MakeVector(0.0f, 0.0f, 0.0f, 1.0f)); // draw the overhead counter uint32 frameDuration = uint32(gBeginTime - gLastBeginTime); float frameTime = (float)frameDuration * rtcFreq; MFCallstackInternal_DrawMeterBlock(meterPos, meterDimensions, (float)(gEndTime - gLastBeginTime) / (float)frameTime, 1.0f, MakeVector(0.0f, 1.0f, 1.0f, 1.0f)); MFCallstackInternal_DrawMeterLabel(callstackPos, MakeVector(0.0f, 1.0f, 1.0f, 1.0f), "Frame Overhead/VSync", NULL); callstackPos.y += 24.0f; // draw all the totals for(int a=0; a<gNumProfileTotals; a++) { uint32 microseconds = uint32((float)gpProfiles[a]->totalTime * rtcFreq); uint32 percent = uint32((float)microseconds / 166.66666f); MFCallstackInternal_DrawMeterLabel(callstackPos, gProfileColours[a % gProfileColourCount], gProfileTotals[a].pFunctionName, MFStr("- %dus (%d%%) %d calls", microseconds, percent, gProfileTotals[a].numCalls)); callstackPos.y += 16.0f; } // draw all the function profiles float totalTime = (float)(gBeginTime - gLastBeginTime); for(int a=0; a<gNumProfileResults; a++) { int colour = MFCallstackInternal_GetTotalIndex(a); MFCallstackInternal_DrawMeterBlock(meterPos, meterDimensions, (float)(gProfileResults[a].startTime - gLastBeginTime) / totalTime, (float)(gProfileResults[a].endTime - gLastBeginTime) / totalTime, gProfileColours[colour % gProfileColourCount]); } } */ MFView_Pop(); } }