예제 #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
파일: 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();
}