Пример #1
0
            inline void tglMultMatrix(const math::Matrix4& matrix)
            {
#if defined(TAU_SCALAR_DOUBLE)
                    glMultTransposeMatrixd((const double*)matrix.getData());
#else
                    glMultTransposeMatrixf((const float*)matrix.getData());
#endif
            }
Пример #2
0
void TinyGLRenderer::setupCameraPerspective(float pitch, float heading, float fov) {
	// TODO: Find a correct and exact formula for the FOV
	TGLfloat glFOV = 0.63 * fov; // Approximative and experimental formula
	if (fov > 79.0 && fov < 81.0)
		glFOV = 50.5; // Somewhat good value for fov == 80
	else if (fov > 59.0 && fov < 61.0)
		glFOV = 36.0; // Somewhat good value for fov == 60

	// NOTE: tinyGL viewport implementation needs to be checked as it doesn't behave the same as openGL
	tglViewport(0, kTopBorderHeight, kOriginalWidth, kFrameHeight);
	tglMatrixMode(TGL_PROJECTION);
	tglLoadIdentity();
	Math::Matrix4 m = Math::makePerspectiveMatrix(glFOV, (TGLfloat)kOriginalWidth / (TGLfloat)kFrameHeight, 1.0, 10000.0);
	tglMultMatrixf(m.getData());

	// Rotate the model to simulate the rotation of the camera
	tglMatrixMode(TGL_MODELVIEW);
	tglLoadIdentity();
	tglRotatef(pitch, -1.0f, 0.0f, 0.0f);
	tglRotatef(heading - 180.0f, 0.0f, 1.0f, 0.0f);

	tglGetFloatv(TGL_MODELVIEW_MATRIX, _cubeModelViewMatrix);
	tglGetFloatv(TGL_PROJECTION_MATRIX, _cubeProjectionMatrix);
	tglGetIntegerv(TGL_VIEWPORT, (TGLint *)_cubeViewport);
}
Пример #3
0
void OpenGLRenderer::setupCameraPerspective(float pitch, float heading, float fov) {
	// TODO: Find a correct and exact formula for the FOV
	GLfloat glFOV = 0.63 * fov; // Approximative and experimental formula
	if (fov > 79.0 && fov < 81.0)
		glFOV = 50.5; // Somewhat good value for fov == 80
	else if (fov > 59.0 && fov < 61.0)
		glFOV = 36.0; // Somewhat good value for fov == 60

	Common::Rect frame = frameViewport();
	glViewport(frame.left, frame.top, frame.width(), frame.height());
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	Math::Matrix4 m = Math::makePerspectiveMatrix(glFOV, (GLfloat)kOriginalWidth / (GLfloat)kFrameHeight, 1.0, 10000.0);
	glMultMatrixf(m.getData());

	// Rotate the model to simulate the rotation of the camera
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glRotatef(pitch, -1.0f, 0.0f, 0.0f);
	glRotatef(heading - 180.0f, 0.0f, 1.0f, 0.0f);

	glGetDoublev(GL_MODELVIEW_MATRIX, _cubeModelViewMatrix);
	glGetDoublev(GL_PROJECTION_MATRIX, _cubeProjectionMatrix);
	glGetIntegerv(GL_VIEWPORT, (GLint *)_cubeViewport);
}