jjgl's picture

Aspect ratio problem by using Matrix

Project:The Open Toolkit library
Version:1.0.0-rc1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I am using OpenTK in my project and have difficulty to use OpenTK.Math.Matrix4.Perspective() dealing with aspect ratio problem. The following Resize function is not working. Could anyone tell me what I have missed here?

private void glControl1_Resize(object sender, EventArgs e)
{
if (!left_glcontrol_loaded)
{
return;
}

GL.MatrixMode(MatrixMode.Projection);
GL.LoadIdentity();

Matrix4 m_prespective = Matrix4.Perspective(45.0f, (float) glControl1.Width/ (float)glControl1.Height, 1.0f, 400.0f);
GL.LoadMatrix(ref m_prespective);

}


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jjgl's picture

#11

Need to change ymax in gluPerspective() as ymax = zNear * Math.Tan(fovy * Math.PI / 180.0); to make display right. Thank you all!

the Fiddler's picture

#12

Status:by design» closed