Beispiel #1
0
void renderScene() {
    FrameTimeCounter counter;
    int avgFps = 0;
    int iterations = 0;
    while (!complete) {
        counter.BeginCounting();

        physicsWorld->Simulate(1.0f / 10.0f);

        contextPtr->BeginScene();
        contextPtr->ApplyCamera(*cameraPtr);
        //contextPtr->RenderLine(vec2(0.0f, 0.0f), vec2(100.0f, 100.0f));
        for (int i = 0; i < physicsBodies.size(); ++i) {
            physicsBodies[i].DebugRender(debugRenderer);
        }

        for (int i = 0; i < physicsJoints.size(); ++i) {
            physicsJoints[i].DebugRender(debugRenderer);
        }

        contextPtr->EndScene();



        counter.EndCounting();

        avgFps += counter.GetFps();
        iterations++;
        if (iterations > 10) {
            SetWindowTextA(hWnd, formatString("fps: %d", avgFps / iterations).c_str());
            iterations = 0;
            avgFps = 0;
        }
    }
}