コード例 #1
0
ファイル: Screen.cpp プロジェクト: galek/hesperus
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();
}
コード例 #2
0
ファイル: ExplicitLayout.cpp プロジェクト: galek/hesperus
/**
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;
}
コード例 #3
0
ファイル: Screen.cpp プロジェクト: galek/hesperus
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();
}