Пример #1
0
void MapKnowledge::discover(const Position& i_Pos, const RangeOfSight& i_ROS)
{
    m_LastTile = toSCoord(i_Pos.tileCoord());
    m_LastDir = i_Pos.facingDir();
    m_LastROS = &i_ROS;
    SCoord ulCorner(i_ROS.getWindowULCorner(m_LastDir));
    SCoord lrCorner(i_ROS.getWindowLRCorner(m_LastDir));

    SCoord centered;
    for (    centered.y = ulCorner.y; centered.y < lrCorner.y; ++centered.y) {
        for (centered.x = ulCorner.x; centered.x < lrCorner.x; ++centered.x) {
            Coord onMap(toCoord(m_LastTile + centered));
            if (!(onMap < m_Dim)) {
                continue;
            }
            std::vector<bool>::reference curr(operator()(onMap));
            curr = curr || i_ROS.isVisible(centered, m_LastDir);
        }
    }
}
Пример #2
0
    void draw()
    {
        // Release the row-interleaved FB if not being used.
        rowInterNeedRelease = true;

        switch (vrCfg.mode())
        {
        // A) Single view type stereo 3D modes here:
        case VRConfig::Mono:
            // Non-stereoscopic frame.
            drawContent();
            break;

        case VRConfig::LeftOnly:
            // Left eye view
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            drawContent();
            break;

        case VRConfig::RightOnly:
            // Right eye view
            vrCfg.setCurrentEye(VRConfig::RightEye);
            drawContent();
            break;

        // B) Split-screen type stereo 3D modes here:
        case VRConfig::TopBottom: // Left goes on top
            // Left eye view on top of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(0, 0, width(), height()/2), true);
            drawContent();
            // Right eye view on bottom of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(0, height()/2, width(), height()/2), true);
            drawContent();
            break;

        case VRConfig::SideBySide: // Squished aspect
            // Left eye view on left side of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(0, 0, width()/2, height()), true);
            drawContent();
            // Right eye view on right side of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(width()/2, 0, width()/2, height()), true);
            drawContent();
            break;

        case VRConfig::Parallel: // Normal aspect
            // Left eye view on left side of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(0, 0, width()/2, height()), true);
            drawContent();
            // Right eye view on right side of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(width()/2, 0, width()/2, height()), true);
            drawContent();
            break;

        case VRConfig::CrossEye: // Normal aspect
            // Right eye view on left side of screen.
            vrCfg.setCurrentEye(VRConfig::RightEye);
            target().setActiveRect(Rectangleui(0, 0, width()/2, height()), true);
            drawContent();
            // Left eye view on right side of screen.
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            target().setActiveRect(Rectangleui(width()/2, 0, width()/2, height()), true);
            drawContent();
            break;

        case VRConfig::OculusRift:
            vrDrawOculusRift();
            break;

        // Overlaid type stereo 3D modes below:
        case VRConfig::GreenMagenta:
            // Left eye view
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            GLState::push().setColorMask(gl::WriteGreen | gl::WriteAlpha); // Left eye view green
            drawContent();
            // Right eye view
            vrCfg.setCurrentEye(VRConfig::RightEye);
            GLState::current().setColorMask(gl::WriteRed | gl::WriteBlue | gl::WriteAlpha); // Right eye view magenta
            drawContent();
            GLState::pop();
            break;

        case VRConfig::RedCyan:
            // Left eye view
            vrCfg.setCurrentEye(VRConfig::LeftEye);
            GLState::push().setColorMask(gl::WriteRed | gl::WriteAlpha); // Left eye view red
            drawContent();
            // Right eye view
            vrCfg.setCurrentEye(VRConfig::RightEye);
            GLState::current().setColorMask(gl::WriteGreen | gl::WriteBlue | gl::WriteAlpha); // Right eye view cyan
            drawContent();
            GLState::pop();
            break;

        case VRConfig::QuadBuffered:
            if (self().window().format().stereo())
            {
                /// @todo Fix me!

                // Left eye view
                vrCfg.setCurrentEye(VRConfig::LeftEye);
                drawContent();
                //canvas().framebuffer().swapBuffers(canvas(), gl::SwapStereoLeftBuffer);

                // Right eye view
                vrCfg.setCurrentEye(VRConfig::RightEye);
                drawContent();
                //canvas().framebuffer().swapBuffers(canvas(), gl::SwapStereoRightBuffer);
            }
            else
            {
                // Normal non-stereoscopic frame.
                drawContent();
            }
            break;

        case VRConfig::RowInterleaved: {
#if !defined (DENG_MOBILE)
            // Use absolute screen position of window to determine whether the
            // first scan line is odd or even.
            QPoint ulCorner(0, 0);
            ulCorner = self().window().mapToGlobal(ulCorner); // widget to screen coordinates
            bool const rowParityIsEven = ((int(ulCorner.y()) % 2) == 0);

            rowInterNeedRelease = false;

            // Draw the left eye view.
            rowInterLeftFB.glInit();
            rowInterLeftFB.resize(GLFramebuffer::Size(width(), height()));
            rowInterLeftFB.colorTexture().setFilter(gl::Linear, gl::Linear, gl::MipNone);
            rowInterLeftFB.colorTexture().glApplyParameters();
            GLState::push()
                    .setTarget(rowInterLeftFB)
                    .setViewport(Rectangleui::fromSize(rowInterLeftFB.size()));
            vrCfg.setCurrentEye(rowParityIsEven? VRConfig::LeftEye : VRConfig::RightEye);
            drawContent();
            GLState::pop();

            // Draw right the eye view.
            rowInterRightFB.glInit();
            rowInterRightFB.resize(GLFramebuffer::Size(width(), height()));
            rowInterRightFB.colorTexture().setFilter(gl::Linear, gl::Linear, gl::MipNone);
            rowInterRightFB.colorTexture().glApplyParameters();
            GLState::push()
                    .setTarget(rowInterRightFB)
                    .setViewport(Rectangleui::fromSize(rowInterRightFB.size()));
            vrCfg.setCurrentEye(rowParityIsEven ? VRConfig::RightEye : VRConfig::LeftEye);
            drawContent();
            GLState::pop();

            // Draw right eye view to the screen from FBO color texture
            vrInitRowInterleaved();
            rowInterUniformTex  = rowInterLeftFB.colorTexture();
            rowInterUniformTex2 = rowInterRightFB.colorTexture();
            rowInterDrawable.draw();
#endif
            break;
          }

        case VRConfig::ColumnInterleaved: /// @todo implement column interleaved stereo 3D after row intleaved is working correctly...
        case VRConfig::Checkerboard: /// @todo implement checker stereo 3D after row intleaved is working correctly ...
        default:
            // Non-stereoscopic frame.
            drawContent();
            break;
        }

        if (rowInterNeedRelease)
        {
            // release unused FBOs
            rowInterRightFB.glDeinit();
        }

        // Restore default VR dynamic parameters
        target().unsetActiveRect(true);
        vrCfg.setCurrentEye(VRConfig::NeitherEye);

        LIBGUI_ASSERT_GL_OK();
    }