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); } }
void TitleScreen::Draw() { GHScreen::Draw(); MFView_Push(); MFRect rect; rect.x = (MFDisplay_GetAspectRatio() >= 1.5) ? -106.0f : 0.0f; rect.y = 0.0f; rect.width = (MFDisplay_GetAspectRatio() >= 1.5) ? 852.0f : 640.0f; rect.height = 480.0f; MFView_SetOrtho(&rect); MFPrimitive_DrawUntexturedQuad(20, 20, 640-40, 480-40, MakeVector(0,0,0,0.8f)); CenterText(30, 34, MFVector::yellow, "Main Menu", pHeading); float height = TEXT_HEIGHT; float y = 90-height; float x = 55.0f; // MFFont_DrawText(pText, , y+=height, 20, MFVector::white, "H - Enter help screen"); // CenterText(rect.height - 20 - 54, 44, MFVector::red, "Press ESC to continue", pFancy); MFView_Pop(); }
void HKWidgetRenderer::Render(const HKWidget &widget, const MFMatrix &worldTransform) { MFVector widgetColour = widget.GetColour(); MFVector size = widget.GetSize(); size.x -= padding.x + padding.z; size.y -= padding.y + padding.w; if(colour.w > 0.f) { float borderWidth = border.x + border.z; float borderHeight = border.y + border.w; MFPrimitive_DrawUntexturedQuad(padding.x + border.x, padding.y + border.y, size.x - borderWidth, size.y - borderHeight, colour*widgetColour, worldTransform); } if(border.x > 0.f) // left MFPrimitive_DrawUntexturedQuad(padding.x, padding.y, border.x, size.y, borderColour*widgetColour, worldTransform); if(border.y > 0.f) // top MFPrimitive_DrawUntexturedQuad(padding.x, padding.y, size.x, border.y, borderColour*widgetColour, worldTransform); if(border.z > 0.f) // right MFPrimitive_DrawUntexturedQuad(size.x - border.z + padding.x, padding.y, border.z, size.y, borderColour*widgetColour, worldTransform); if(border.w > 0.f) // bottom MFPrimitive_DrawUntexturedQuad(padding.x, padding.y + size.y - border.w, size.x, border.w, borderColour*widgetColour, worldTransform); if(pImage) { if(margin9Cell > 0.f) { // 9 cell stuff... } else { // draw the background image centered in the box MFMaterial_SetMaterial(pImage); float offset = 0; float tc = MFRenderer_GetTexelCenterOffset(); if(tc > 0.f) { if(size.x == texWidth && size.y == texHeight) offset = tc; } MFPrimitive_DrawQuad(padding.x - offset, padding.y - offset, size.x, size.y, widgetColour, 0, 0, 1, 1, worldTransform); } } }
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(); } }
void MFCallstackInternal_DrawMeterBlock(const MFVector &meterPos, const MFVector &meterDimensions, float start, float end, const MFVector &colour) { MFPrimitive_DrawUntexturedQuad(meterPos.x + meterDimensions.x*start, meterPos.y, meterPos.x + meterDimensions.x*end, meterPos.y + meterDimensions.y, colour); }
void dBFrame::Draw() { if(!pMat) { MFPrimitive_DrawUntexturedQuad(rect.x-10, rect.y-10, rect.width+20, rect.height+20, colours[0]); } else { // draw background float x, y, xRemaining, yRemaining; // calculate number of tiles (including edges) int h = (int)MFCeil(rect.width / borderWidth); int w = (int)MFCeil(rect.height / borderWidth); int numTiles = (h + 2) * (w + 2); // begin immediate renderer MFMaterial_SetMaterial(pMat); MFPrimitive(PT_QuadList); MFBegin(numTiles*2); MFSetColourV(colours[0]); // render tiled background yRemaining = rect.height; for(y = 0.0f; y < rect.height; y += borderWidth) { xRemaining = rect.width; for(x = 0.0f; x < rect.width; x += borderWidth) { float xuv = xRemaining < borderWidth ? 0.25f * (xRemaining / borderWidth) : 0.25f; float yuv = yRemaining < borderWidth ? 0.25f * (yRemaining / borderWidth) : 0.25f; MFSetTexCoord1(0.25f, 0.25f); MFSetPosition(rect.x + x, rect.y + y, 0); MFSetTexCoord1(0.25f + xuv, 0.25f + yuv); MFSetPosition(rect.x + x + MFMin(borderWidth, xRemaining), rect.y + y + MFMin(borderWidth, yRemaining), 0); xRemaining -= borderWidth; } yRemaining -= borderWidth; } // draw frame // draw corners MFSetTexCoord1(0.0f, 0.0f); MFSetPosition(rect.x - borderWidth, rect.y - borderWidth, 0.0f); MFSetTexCoord1(0.25f, 0.25f); MFSetPosition(rect.x, rect.y, 0.0f); MFSetTexCoord1(0.5f, 0.0f); MFSetPosition(rect.x + rect.width, rect.y - borderWidth, 0.0f); MFSetTexCoord1(0.75f, 0.25f); MFSetPosition(rect.x + rect.width + borderWidth, rect.y, 0.0f); MFSetTexCoord1(0.0f, 0.50f); MFSetPosition(rect.x - borderWidth, rect.y + rect.height, 0.0f); MFSetTexCoord1(0.25f, 0.75f); MFSetPosition(rect.x, rect.y + rect.height + borderWidth, 0.0f); MFSetTexCoord1(0.5f, 0.5f); MFSetPosition(rect.x + rect.width, rect.y + rect.height, 0.0f); MFSetTexCoord1(0.75f, 0.75f); MFSetPosition(rect.x + rect.width + borderWidth, rect.y + rect.height + borderWidth, 0.0f); // draw vertical edges yRemaining = rect.height; for(y = 0.0f; y < rect.height; y += borderWidth) { float yuv = yRemaining < borderWidth ? 0.25f * (yRemaining / borderWidth) : 0.25f; MFSetTexCoord1(0.0f, 0.25f); MFSetPosition(rect.x - borderWidth, rect.y + y, 0.0f); MFSetTexCoord1(0.25f, 0.25f + yuv); MFSetPosition(rect.x, rect.y + y + MFMin(borderWidth, yRemaining), 0.0f); MFSetTexCoord1(0.5f, 0.25f); MFSetPosition(rect.x + rect.width, rect.y + y, 0.0f); MFSetTexCoord1(0.75f, 0.25f + yuv); MFSetPosition(rect.x + rect.width + borderWidth, rect.y + y + MFMin(borderWidth, yRemaining), 0.0f); yRemaining -= borderWidth; } // draw horizontal edges xRemaining = rect.width; for(x = 0.0f; x < rect.width; x += borderWidth) { float xuv = xRemaining < borderWidth ? 0.25f * (xRemaining / borderWidth) : 0.25f; MFSetTexCoord1(0.25f, 0.0f); MFSetPosition(rect.x + x, rect.y - borderWidth, 0.0f); MFSetTexCoord1(0.25f + xuv, 0.25f); MFSetPosition(rect.x + x + MFMin(borderWidth, xRemaining), rect.y, 0.0f); MFSetTexCoord1(0.25f, 0.5f); MFSetPosition(rect.x + x, rect.y + rect.height, 0.0f); MFSetTexCoord1(0.25f + xuv, 0.75f); MFSetPosition(rect.x + x + MFMin(borderWidth, xRemaining), rect.y + rect.height + borderWidth, 0.0f); xRemaining -= borderWidth; } MFEnd(); } }