Esempio n. 1
0
void TestWindow::endFrame() {
#ifdef DEFERRED_LIGHTING
    RenderArgs* args = _renderContext->args;
    gpu::doInBatch(args->_context, [&](gpu::Batch& batch) {
        args->_batch = &batch;
        auto deferredFboColorDepthStencil = DependencyManager::get<FramebufferCache>()->getDeferredFramebufferDepthColor();
        batch.setViewportTransform(args->_viewport);
        batch.setStateScissorRect(args->_viewport);
        batch.setFramebuffer(deferredFboColorDepthStencil);
        batch.setPipeline(_opaquePipeline);
        batch.draw(gpu::TRIANGLE_STRIP, 4);
        batch.setResourceTexture(0, nullptr);
    });

    auto deferredLightingEffect = DependencyManager::get<DeferredLightingEffect>();
    deferredLightingEffect->render(_renderContext);

    gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) {
        PROFILE_RANGE_BATCH(batch, "blit");
        // Blit to screen
        auto framebufferCache = DependencyManager::get<FramebufferCache>();
        auto framebuffer = framebufferCache->getLightingFramebuffer();
        batch.blit(framebuffer, _renderArgs->_viewport, nullptr, _renderArgs->_viewport);
    });
#endif

    gpu::doInBatch(_renderArgs->_context, [&](gpu::Batch& batch) {
        batch.resetStages();
    });
    _glContext.swapBuffers(this);
}
Esempio n. 2
0
// Renders the overlays either to a texture or to the screen
void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
    PROFILE_RANGE(render, __FUNCTION__);
    buildFramebufferObject();
    
    if (!_overlayFramebuffer) {
        return; // we can't do anything without our frame buffer.
    }

    // Execute the batch into our framebuffer
    doInBatch("ApplicationOverlay::render", renderArgs->_context, [&](gpu::Batch& batch) {
        PROFILE_RANGE_BATCH(batch, "ApplicationOverlayRender");
        renderArgs->_batch = &batch;
        batch.enableStereo(false);

        int width = _overlayFramebuffer->getWidth();
        int height = _overlayFramebuffer->getHeight();

        batch.setViewportTransform(glm::ivec4(0, 0, width, height));
        batch.setFramebuffer(_overlayFramebuffer);

        glm::vec4 color { 0.0f, 0.0f, 0.0f, 0.0f };
        float depth = 1.0f;
        int stencil = 0;
        batch.clearFramebuffer(gpu::Framebuffer::BUFFER_COLOR0 | gpu::Framebuffer::BUFFER_DEPTH, color, depth, stencil);

        // Now render the overlay components together into a single texture
        renderDomainConnectionStatusBorder(renderArgs); // renders the connected domain line
        renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
#if !defined(DISABLE_QML)
        renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
#endif
    });

    renderArgs->_batch = nullptr; // so future users of renderArgs don't try to use our batch
}