void Screen::set_ortho_viewport(const Extents& extents) { int screenHeight = m_extents->bottom() - m_extents->top(); const int& x1 = extents.left(), y1 = extents.top(), x2 = extents.right(), y2 = extents.bottom(); glViewport(x1, screenHeight - y2, x2-x1, y2-y1); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1, x2+1-x1, y2+1-y1, -1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
/** Fits the components to the specified container extents and returns them. @param extents The extents of the container for which this object is the layout @return A collection of laid-out components to be put into the container */ std::vector<LaidOutGUIComponent> ExplicitLayout::fit(const Extents& extents) const { std::vector<LaidOutGUIComponent> components(m_components); for(std::vector<LaidOutGUIComponent>::iterator it=components.begin(), iend=components.end(); it!=iend; ++it) { // TODO: Check that the component fits within the container's extents, and clip // its own extents if not. it->extents = it->extents.translate(extents.left(), extents.top()); } return components; }
void Screen::set_persp_viewport(const Extents& extents, double fovY, double zNear, double zFar) { int screenHeight = m_extents->bottom() - m_extents->top(); const int& x1 = extents.left(), y1 = extents.top(), x2 = extents.right(), y2 = extents.bottom(); glViewport(x1, screenHeight - y2, x2-x1, y2-y1); double width = x2 - x1, height = y2 - y1; glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(fovY, width / height, zNear, zFar); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }