//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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]); }
//-------------------------------------------------------------------------------------------------- /// 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; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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()))); } } }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- 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); } } } }