//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRendering)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    // Must setup a scissor to limit the overlay items to the current viewport, as they might setup a local viewport (e.g. navigation cube)
    GLboolean scissorWasOn = glIsEnabled(GL_SCISSOR_TEST);
    int scissorBox[4] = {0, 0, -1, -1};
    glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
    glScissor(static_cast<GLsizei>(m_camera->viewport()->x()), static_cast<GLsizei>(m_camera->viewport()->y()), static_cast<GLsizei>(m_camera->viewport()->width()), static_cast<GLsizei>(m_camera->viewport()->height()));
    glEnable(GL_SCISSOR_TEST);

    OverlayItemRectMap::iterator it;
    for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
    {
        OverlayItem* item = it->first;
        Recti rect = it->second;

        if (useSoftwareRendering)
        {
            item->renderSoftware(oglContext, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
        else
        {
            item->render(oglContext, rect.min(),  Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
    }

    // Restore scissor settings
    if (!scissorWasOn) glDisable(GL_SCISSOR_TEST);
    glScissor(scissorBox[0], scissorBox[1], scissorBox[2], scissorBox[3]); 
}
Пример #2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::calculateOverlayItemLayout(OverlayItemRectMap* itemRectMap)
{
    calculateOverlayItemLayout(itemRectMap, OverlayItem::TOP_LEFT,     OverlayItem::HORIZONTAL);
    calculateOverlayItemLayout(itemRectMap, OverlayItem::TOP_LEFT,     OverlayItem::VERTICAL);
    calculateOverlayItemLayout(itemRectMap, OverlayItem::TOP_RIGHT,    OverlayItem::HORIZONTAL);
    calculateOverlayItemLayout(itemRectMap, OverlayItem::TOP_RIGHT,    OverlayItem::VERTICAL);
    calculateOverlayItemLayout(itemRectMap, OverlayItem::BOTTOM_LEFT,  OverlayItem::HORIZONTAL);
    calculateOverlayItemLayout(itemRectMap, OverlayItem::BOTTOM_LEFT,  OverlayItem::VERTICAL);
    calculateOverlayItemLayout(itemRectMap, OverlayItem::BOTTOM_RIGHT, OverlayItem::HORIZONTAL);
    calculateOverlayItemLayout(itemRectMap, OverlayItem::BOTTOM_RIGHT, OverlayItem::VERTICAL);
}
Пример #3
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRendering)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    // Must setup a scissor to limit the overlay items to the current viewport, as they might setup a local viewport (e.g. navigation cube)
    GLboolean scissorWasOn = glIsEnabled(GL_SCISSOR_TEST);
    int scissorBox[4] = {0, 0, -1, -1};
    glGetIntegerv(GL_SCISSOR_BOX, scissorBox);
    glScissor(static_cast<GLsizei>(m_camera->viewport()->x()), static_cast<GLsizei>(m_camera->viewport()->y()), static_cast<GLsizei>(m_camera->viewport()->width()), static_cast<GLsizei>(m_camera->viewport()->height()));
    glEnable(GL_SCISSOR_TEST);


    const size_t numOverlayItems = m_overlayItems.size();
    for (size_t i = 0; i < numOverlayItems; i++)
    {
        OverlayItem* item = m_overlayItems.at(i);

        Vec2i pos(0, 0);
        Vec2ui size(0, 0);

        if (item->layoutScheme() == OverlayItem::FIXED_POSITION)
        {
            pos = item->fixedPosition();
            size = item->sizeHint();
        }
        else
        {
            // Item should be laid out already - grab its pos/size from the layout map
            OverlayItemRectMap::iterator it = itemRectMap.find(item);
            if (it != itemRectMap.end())
            {
                Recti rect = it->second;
                pos = rect.min();
                size.set(static_cast<uint>(rect.width()), static_cast<uint>(rect.height()));
            }
        }

        if (!size.isZero())
        {
            if (useSoftwareRendering)
            {
                item->renderSoftware(oglContext, pos, size);
            }
            else
            {
                item->render(oglContext, pos, size);
            }
        }
    }


    // Restore scissor settings
    if (!scissorWasOn) glDisable(GL_SCISSOR_TEST);
    glScissor(scissorBox[0], scissorBox[1], scissorBox[2], scissorBox[3]); 
}
Пример #4
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
cvf::Recti Rendering::overlayItemRect(OverlayItem* item)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    OverlayItemRectMap::iterator it = itemRectMap.find(item);
    if (it != itemRectMap.end())
    {
        return it->second;
    }

    return cvf::Recti();
}
Пример #5
0
//--------------------------------------------------------------------------------------------------
/// Get the the overlay item (if any) at the given cursor position
//--------------------------------------------------------------------------------------------------
OverlayItem* Rendering::overlayItemFromWindowCoordinates(int x, int y)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);

    OverlayItemRectMap::iterator it;
    for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
    {
        OverlayItem* item = it->first;
        Recti rect = it->second;

        if (item->pick(x, y, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height()))))
        {
            return item;
        }
    }

    return NULL;
}
Пример #6
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRendering)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    OverlayItemRectMap::iterator it;
    for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
    {
        OverlayItem* item = it->first;
        Recti rect = it->second;

        if (useSoftwareRendering)
        {
            item->renderSoftware(oglContext, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
        else
        {
            item->render(oglContext, rect.min(),  Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
    }
}
Пример #7
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRendering)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);
    
    OverlayItemRectMap::iterator it;
    for (it = itemRectMap.begin(); it != itemRectMap.end(); ++it)
    {
        OverlayItem* item = it->first;
        Recti rect = it->second;

        if (useSoftwareRendering)
        {
            item->renderSoftware(oglContext, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
        else
        {
            item->render(oglContext, rect.min(),  Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height())));
        }
    }

    for (size_t i = 0; i < m_overlayItems.size(); i++)
    {
        OverlayItemLayout item = m_overlayItems.at(i);
        if ((item.corner == OverlayItem::UNMANAGED) )
        {
            Vec2ui size = item.overlayItem->sizeHint();
            Vec2i pos =  item.overlayItem->unmanagedPosition();

            if (useSoftwareRendering)
            {
                item.overlayItem->renderSoftware(oglContext, pos, size);
            }
            else
            {
                item.overlayItem->render(oglContext, pos,  size);
            }
        }
    }
}
Пример #8
0
//--------------------------------------------------------------------------------------------------
/// Get the the overlay item (if any) at the given cursor position
//--------------------------------------------------------------------------------------------------
OverlayItem* Rendering::overlayItemFromWindowCoordinates(int x, int y)
{
    OverlayItemRectMap itemRectMap;
    calculateOverlayItemLayout(&itemRectMap);

    const size_t numOverlayItems = m_overlayItems.size();
    for (size_t i = 0; i < numOverlayItems; i++)
    {
        OverlayItem* item = m_overlayItems.at(i);
        OverlayItemRectMap::iterator it = itemRectMap.find(item);
        if (it != itemRectMap.end())
        {
            Recti rect = it->second;
            if (item->pick(x, y, rect.min(), Vec2ui(static_cast<cvf::uint>(rect.width()), static_cast<cvf::uint>(rect.height()))))
            {
                return item;
            }
        }
    }

    return NULL;
}