Exemplo n.º 1
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
}
Exemplo n.º 2
0
// Renders the overlays either to a texture or to the screen
void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
    PROFILE_RANGE(__FUNCTION__);
    CHECK_GL_ERROR();
    PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");

    // TODO move to Application::idle()?
    Stats::getInstance()->updateStats();
    AvatarInputs::getInstance()->update();

    buildFramebufferObject();
    
    if (!_overlayFramebuffer) {
        return; // we can't do anything without our frame buffer.
    }

    // Execute the batch into our framebuffer
    gpu::Batch batch;
    renderArgs->_batch = &batch;

    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
    renderAudioScope(renderArgs); // audio scope in the very back
    renderRearView(renderArgs); // renders the mirror view selfie
    renderQmlUi(renderArgs); // renders a unit quad with the QML UI texture, and the text overlays from scripts
    renderOverlays(renderArgs); // renders Scripts Overlay and AudioScope
    renderStatsAndLogs(renderArgs);  // currently renders nothing

    renderArgs->_context->render(batch);

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

    CHECK_GL_ERROR();
}
Exemplo n.º 3
0
// Renders the overlays either to a texture or to the screen
void ApplicationOverlay::renderOverlay(bool renderToTexture) {
    PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
    Application* application = Application::getInstance();
    Overlays& overlays = application->getOverlays();
    GLCanvas* glWidget = application->getGLWidget();
    MyAvatar* myAvatar = application->getAvatar();
    
    _textureFov = glm::radians(Menu::getInstance()->getOculusUIAngularSize());
    _textureAspectRatio = (float)application->getGLWidget()->getDeviceWidth() / (float)application->getGLWidget()->getDeviceHeight();

    //Handle fading and deactivation/activation of UI
    if (Menu::getInstance()->isOptionChecked(MenuOption::UserInterface)) {
        _alpha += FADE_SPEED;
        if (_alpha > 1.0f) {
            _alpha = 1.0f;
        }
    } else {
        _alpha -= FADE_SPEED;
        if (_alpha <= 0.0f) {
            _alpha = 0.0f;
        }
    }

    // Render 2D overlay
    glMatrixMode(GL_PROJECTION);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    if (renderToTexture) {
        _overlays.buildFramebufferObject();
        _overlays.bind();
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    }
    
    glPushMatrix(); {
        glLoadIdentity();
        gluOrtho2D(0, glWidget->width(), glWidget->height(), 0);
        
        renderAudioMeter();
        
        if (Menu::getInstance()->isOptionChecked(MenuOption::HeadMouse)) {
            myAvatar->renderHeadMouse(glWidget->width(), glWidget->height());
        }
        
        renderStatsAndLogs();
        
        // give external parties a change to hook in
        emit application->renderingOverlay();
        
        overlays.render2D();
        
        renderPointers();
        
        renderDomainConnectionStatusBorder();
    } glPopMatrix();

    glMatrixMode(GL_MODELVIEW);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_CONSTANT_ALPHA, GL_ONE);

    if (renderToTexture) {
        _overlays.release();
    }
}