bool ApplicationClass::Frame() { bool result; // Read the user input. result = m_Input->Frame(); if(!result) { return false; } // Check if the user pressed escape and wants to exit the application. if(m_Input->IsEscapePressed() == true) { return false; } // Update the system stats. m_Timer->Frame(); m_Fps->Frame(); m_Cpu->Frame(); // Update the FPS value in the text object. result = m_Text->SetFps(m_Fps->GetFps(), m_Direct3D->GetDeviceContext()); if(!result) { return false; } // Update the CPU usage value in the text object. result = m_Text->SetCpu(m_Cpu->GetCpuPercentage(), m_Direct3D->GetDeviceContext()); if(!result) { return false; } // Do the frame input processing. result = HandleInput(m_Timer->GetTime()); if(!result) { return false; } // Do the sky plane frame processing. m_SkyPlane->Frame(); // Render the graphics. result = RenderGraphics(); if(!result) { return false; } return result; }
void TankTop::Draw(){ RenderGraphics(); if(hit){ hit=true; colVolume->DrawColVolume(Vect(1,0,0)); //DebugVisualizer::ShowAABB(colVolume->GetCheapMinAABBPoint(),colVolume->GetCheapMaxAABBPoint(),Vect(1,0,0)); //DebugVisualizer::ShowOBB(colVolume->,colVolume->GetCheapMaxAABBPoint(),colWorld ,Vect(1,0,0)); //DebugVisualizer::ShowSphere(colVolume->GetCheapCenter(), colVolume->GetCheapSphereRadius(), Vect(1,0,0)); }else{ colVolume->DrawColVolume(Vect(0,0,1)); //DebugVisualizer::ShowAABB(colVolume->GetCheapMinAABBPoint(),colVolume->GetCheapMaxAABBPoint(),Vect(0,0,1)); //DebugVisualizer::ShowAABB(colVolume->GetCheapMinAABBPoint(),colVolume->GetCheapMaxAABBPoint(),Vect(0,0,1)); //DebugVisualizer::ShowSphere(colVolume->GetCheapCenter(), colVolume->GetCheapSphereRadius(), Vect(0,0,1)); } hit =false; }
bool ApplicationClass::Frame() { char text[32], itoaTemp[16], videoCard[128]; if(!m_Input->Frame()) { return false; } if(m_Input->IsKeyPressed(DIK_ESCAPE)) { return false; } m_Timer->Frame(); m_Cpu->Frame(); m_Fps->Frame(); _itoa_s(m_Fps->GetFps(), itoaTemp, 10); strcpy_s(text, "FPSTime: "); strcat_s(text, itoaTemp); if(!m_Text->UpdateString("FPS", text, m_D3D->GetDeviceContext())) { } _itoa_s(m_Cpu->GetCpuPercentage(), itoaTemp, 10); strcpy_s(text, "CPUTime: "); strcat_s(text, itoaTemp); strcat_s(text, "%"); if(!m_Text->UpdateString("CPU", text, m_D3D->GetDeviceContext())) { } float x, y, z; m_Position->GetPosition(x, y, z); strcpy_s(text, "POS (X: "); _itoa_s((int)x, itoaTemp, 10); strcat_s(text, itoaTemp); strcat_s(text, " Y: "); _itoa_s((int)y, itoaTemp, 10); strcat_s(text, itoaTemp); strcat_s(text, " Z: "); _itoa_s((int)z, itoaTemp, 10); strcat_s(text, itoaTemp); strcat_s(text, ")"); if(!m_Text->UpdateString("POS", text, m_D3D->GetDeviceContext())) { MessageBox(NULL, L"Failed To Update Position String", L"Error", MB_OK); } m_Position->GetRotation(x, y, z); strcpy_s(text, "ROT (X: "); _itoa_s((int)x, itoaTemp, 10); strcat_s(text, itoaTemp); strcat_s(text, " Y: "); _itoa_s((int)y, itoaTemp, 10); strcat_s(text, itoaTemp); strcat_s(text, " Z: "); _itoa_s((int)z, itoaTemp, 10); strcat_s(text, itoaTemp); strcat_s(text, ")"); if(!m_Text->UpdateString("ROT", text, m_D3D->GetDeviceContext())) { MessageBox(NULL, L"Failed To Update Rotation String", L"Error", MB_OK); } float drawpct = (float)m_QuadTree->GetDrawCount() / (float)m_QuadTree->GetTriangleCount(); _itoa_s(drawpct*100, itoaTemp, 10); strcpy_s(text, "Draw: "); strcat_s(text, itoaTemp); strcat_s(text, "%"); if(!m_Text->UpdateString("QTR", text, m_D3D->GetDeviceContext())) { } _itoa_s(m_QuadTree->GetDrawCount(), itoaTemp, 10); strcpy_s(text, "Tri's: "); strcat_s(text, itoaTemp); if(!m_Text->UpdateString("XCS", text, m_D3D->GetDeviceContext())) { } if(!HandleInput(m_Timer->GetTime())) { return false; } if(!RenderGraphics()) { return false; } return true; }
//+++++++++++++++++++++++++++++++++++++++++++++++++ //メイン関数 //------------------------------------------------- //初期化及びメインループ //--in--------------------------------------------- // //--out--------------------------------------------- // //+++++++++++++++++++++++++++++++++++++++++++++++++ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPTSTR lpCmdLine, int iCmdShow) { HWND hWnd; MSG msg; DWORD dwFPSLastTime, dwCurrentTime, dwFrameCount; //ウィンドウ クラスを登録 WNDCLASS wndClass = { CS_HREDRAW | CS_VREDRAW, WndProc, 0, 0, hInst, LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1)), LoadCursor(NULL, IDC_ARROW), (HBRUSH)GetStockObject(WHITE_BRUSH), MAKEINTRESOURCE(IDR_MENU1), CLASS_NAME }; if (RegisterClass(&wndClass) == 0) return false; //ウィンドウ サイズを取得 RECT rc = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT}; DWORD dwStyle = WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE; DWORD dwExStyle = 0; AdjustWindowRectEx(&rc, dwStyle, FALSE, dwExStyle); //ウィンドウを作成 hWnd = CreateWindowEx( dwExStyle, CLASS_NAME, CAPTION_NAME, dwStyle, WINDOW_X, WINDOW_Y, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInst, NULL); if (hWnd == NULL) return false; g_bWindow = true; if(FAILED(InitializeGraphics(hWnd, g_bWindow))) return 0; //OpenGL の初期化 //変数初期化 timeBeginPeriod(1); //タイマの分解能を最小にセット dwFPSLastTime = dwExecLastTime = timeGetTime(); //現在のシステム タイマを取得 dwExecLastTime -= FRAME_RATE; dwFrameCount = 0; g_fFPS = 0.0f; //マウスカーソル位置を固定する //SetCursorPos( WINDOW_X + SCREEN_WIDTH / 2, WINDOW_Y + SCREEN_HEIGHT / 2 ); //ウィンドウの中心位置に固定 ShowCursor(false); //メイン ウインドウ ループ msg.message = WM_NULL; //乱数設定 InitRandom(); while (WM_QUIT != msg.message && !g_bEnd) //WM_QUIT がくるか、終了フラグがたつまでループ { if (PeekMessage(&msg,NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { dwCurrentTime = timeGetTime(); //現在のタイマ値を取得 if (dwCurrentTime - dwFPSLastTime >= 500) //0.5 秒ごとに計測 { //フレーム数を計算 g_fFPS = dwFrameCount * 1000.0f / (dwCurrentTime - dwFPSLastTime); dwFPSLastTime = dwCurrentTime; //タイマ値を更新 dwFrameCount = 0; //フレーム カウンタをリセット } //この辺で時間管理 while (dwCurrentTime - dwExecLastTime >= FRAME_RATE) //一定時間が経過したら・・・ { dwExecLastTime += FRAME_RATE; //タイマ値を更新 GameMain(hWnd); //ゲーム メイン処理 } RenderGraphics(); //レンダリング処理を実行 dwFrameCount++; //フレーム カウントを+1 Sleep(1); //いったん Windows に制御を戻す } //終了確認 if(g_bEnd) { //if (IDNO == MessageBox(hWnd, _T("ゲームを終了しますか?"), _T("終了確認"), MB_YESNO)) // g_bEnd = false; } } timeEndPeriod(1); //システム タイマの分解能を元に戻す return (int)msg.wParam; }
void LoseText::Draw(){ RenderGraphics(); }
bool ApplicationClass::Frame() { bool result; // Read the user input. result = m_Input->Frame(); if(!result){ return false; } // Check if the user pressed escape and wants to exit the application. if(m_Input->IsEscapePressed() == true) { return false; } // Update the system stats. m_Timer->Frame(); m_Fps->Frame(); m_Cpu->Frame(); // Set the frames per second. result = m_Text->SetFps(m_Fps->GetFps(), m_D3D->GetDeviceContext()); if(!result) { return false; } // Set the cpu usage. result = m_Text->SetCpu(m_Cpu->GetCpuPercentage(), m_D3D->GetDeviceContext()); if(!result) { return false; } // Set the vertex count. result = m_Text->SetVertexCount(m_Model->GetVertexCount(), m_D3D->GetDeviceContext()); if(!result) { return false; } // Set the face count. result = m_Text->SetFaceCount(m_Model->GetFaceCount(), m_D3D->GetDeviceContext()); if(!result) { return false; } // Do the frame input processing. result = HandleInput(m_Timer->GetTime()); if(!result) { return false; } // Render the graphics. result = RenderGraphics(); if(!result) { return false; } return true; }