opentk / LearnOpenTK

A port of learnopengl.com's tutorials to OpenTK and C#.
Creative Commons Attribution 4.0 International
463 stars 115 forks source link

Why OpenTK does not support Matrix4.CreatePerspective( ) method ?. What are the differences between Matrix4.CreatePerspective( ) vs Matrix4.CreatePerspectiveFieldOfView( ) #75

Closed MauNguyenVan closed 2 years ago

MauNguyenVan commented 2 years ago

I have seen many libraries matrix4 like Monogame or System.Numerics.Matrix4x4 ... support both Matrix4.CreatePerspective( ) and Matrix4.CreatePerspectiveFieldOfView( ) method. So, why OpenTK decided to do not support Matrix4.CreatePerspective( ), but only Matrix4.CreatePerspectiveFieldOfView( ) ?

And show for me the differences between Matrix4.CreatePerspective( ) vs Matrix4.CreatePerspectiveFieldOfView( ).

Many thanks for your help.

image

utkumaden commented 2 years ago

It's just named differently. The OpenTK math types existed long before System.Numerics came to be. Matrix4.CreatePerspectiveFieldOfView() is the function you are looking for.

NogginBops commented 2 years ago

Because there are many ways to create perspective projection matrices, so just calling it CreatePerspective doesn't describe how the matrix is constructed. Therefore we have CreatePerspectiveFieldOfView (which is the same as the CreatePerspective functions in the other libraries), and CreatePerspectiveOffCenter for some more specific usecases where you want to create a very specific frustum. You can take a look in the API reference to see the different alternatives: https://opentk.net/api/OpenTK.Mathematics.Matrix4.html#OpenTK_Mathematics_Matrix4_CreatePerspectiveFieldOfView_System_Single_System_Single_System_Single_SystemSingle

So what you want is probably CreatePerspectiveFieldOfView, as you want to use a field of view (fov) value to create the perspective projection.

MauNguyenVan commented 2 years ago

Uhm. May be i could learn more about opentk to really understand issue.