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!"); } } }
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(); }
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); }
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 }