예제 #1
0
void MySample::Render(double deltaSeconds)
{
    CPUTRenderParameters renderParams;
    if(isInstanced)
        SetEffectVals( 0 );
    else
        SetEffectVals( 1 );


    renderParams.mpPerFrameConstants = mpPerFrameConstantBuffer;
    renderParams.mpPerModelConstants = mpPerModelConstantBuffer;
	renderParams.mpCamera = mpCamera;
    UpdatePerFrameConstantBuffer(renderParams, deltaSeconds);

    int width,height;
    mpWindow->GetClientDimensions(&width, &height);

    // Set default viewport
    glViewport( 0, 0, width, height );
    GL_CHECK(glClearColor ( 0.7f, 0.7f, 0.7f, 1.0f ));
    GL_CHECK(glClearDepthf(0.0f));
    GL_CHECK(glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ));


    mpScene->Render( renderParams);

#ifdef ENABLE_GUI
	CPUTDrawGUI();
#endif
}
예제 #2
0
// Call the user's Render() callback (if it exists)
//-----------------------------------------------------------------------------
void CPUT_DX11::InnerExecutionLoop()
{
#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_BeginEvent(D3DCOLOR(0xff0000), L"CPUT User's Render() ");
#endif
    if(!mbShutdown)
    {
        double deltaSeconds = mpTimer->GetElapsedTime();
        Update(deltaSeconds);
        Present(); // Note: Presenting immediately before Rendering minimizes CPU stalls (i.e., execute Update() before Present() stalls)

        double totalSeconds = mpTimer->GetTotalTime();
        UpdatePerFrameConstantBuffer(totalSeconds);
        CPUTMaterialDX11::ResetStateTracking();
        Render(deltaSeconds);
        if(!CPUTOSServices::GetOSServices()->DoesWindowHaveFocus())
        {
            Sleep(100);
        }
    }
    else
    {
#ifndef _DEBUG
        exit(0);
#endif
        Present(); // Need to present, or will leak all references held by previous Render()!
        ShutdownAndDestroy();
    }

#ifdef CPUT_GPA_INSTRUMENTATION
    D3DPERF_EndEvent();
#endif
}
예제 #3
0
//-----------------------------------------------------------------------------
void MySample::Render(double deltaSeconds)
{
    CPUTRenderParameters renderParams;

    const int DEFAULT_MATERIAL = 0;
    const int SHADOW_MATERIAL = 1;
    renderParams.mpShadowCamera = NULL;
    renderParams.mpCamera = mpShadowCamera;
    renderParams.mpPerFrameConstants = (CPUTBuffer*)mpPerFrameConstantBuffer;
    renderParams.mpPerModelConstants = (CPUTBuffer*)mpPerModelConstantBuffer;
    //Animation
    renderParams.mpSkinningData = (CPUTBuffer*)mpSkinningDataConstantBuffer;
    int windowWidth, windowHeight;
    mpWindow->GetClientDimensions( &windowWidth, &windowHeight);
    renderParams.mWidth = windowWidth;
    renderParams.mHeight = windowHeight;
    renderParams.mRenderOnlyVisibleModels = false;
    //*******************************
    // Draw the shadow scene
    //*******************************
    UpdatePerFrameConstantBuffer(renderParams, deltaSeconds);

    renderParams.mWidth = windowWidth;
    renderParams.mHeight = windowHeight;
    renderParams.mpCamera = mpCamera;
    renderParams.mpShadowCamera = mpShadowCamera;
    UpdatePerFrameConstantBuffer(renderParams, deltaSeconds);

    // Clear back buffer
    const float clearColor[] = { 0.0993f, 0.0993f, 0.0993f, 1.0f };
    mpContext->ClearRenderTargetView( mpBackBufferRTV,  clearColor );
    mpContext->ClearDepthStencilView( mpDepthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 0.0f, 0);

    if(mpCameraController->GetCamera() == mpShadowCamera)
    {
        mpDebugSprite->DrawSprite(renderParams);
    }

	MenuController_Render(renderParams);
	CPUTDrawGUI();

	ImGui::Render();
}