diff options
| author | aura <nw@moneybot.cc> | 2026-03-04 00:51:18 +0100 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-03-04 00:51:18 +0100 |
| commit | 890bea19359649695df1b618a41ce580cf3dfbda (patch) | |
| tree | 8bc10ae4e613b0ad57fae9a68cec38c7d59cf067 /src/render/gl_3d.cpp | |
| parent | 61aea7311c2e1af78fd9da544499f2198f2da1dd (diff) | |
| parent | be91342733fd56d1e7bafe72e82a8ac4dc67b79d (diff) | |
Merge branch 'ui-rework'
Diffstat (limited to 'src/render/gl_3d.cpp')
| -rw-r--r-- | src/render/gl_3d.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/render/gl_3d.cpp b/src/render/gl_3d.cpp index 40162e8..8449500 100644 --- a/src/render/gl_3d.cpp +++ b/src/render/gl_3d.cpp @@ -21,13 +21,20 @@ void gl_3d_projection_setup( GL_SHADER_PROGRAM *_gl3d, VEC3 pos, F32 fov_deg, F3 GL3D* gl3d = (GL3D*)_gl3d; MAT4 proj, yaw_rot, pitch_rot, view, transl, tmp; - F32 fov_rad = m_deg2rad( fov_deg ); + F32 fov_y_rad = m_deg2rad( fov_deg ); F32 yaw_rad = m_deg2rad( remainderf( yaw + 90.f, 360.f ) ); F32 pitch_rad = m_deg2rad( remainderf( pitch , 360.f ) ); - gl3d->aspect = winsize.x / winsize.y; + gl3d->aspect = winsize.y > 0.f ? winsize.x / winsize.y : 1.f; + if( gl3d->aspect <= 0.000001f ) + gl3d->aspect = 1.f; + + const F32 min_fovy = m_deg2rad( 1.f ); + const F32 max_fovy = m_deg2rad( 179.f ); + if( fov_y_rad < min_fovy ) fov_y_rad = min_fovy; + if( fov_y_rad > max_fovy ) fov_y_rad = max_fovy; gl3d->winsize = winsize; - mat4_perspective( &proj, fov_rad, gl3d->aspect, near, far ); + mat4_perspective( &proj, fov_y_rad, gl3d->aspect, near, far ); mat4_rotation_y( &yaw_rot, -yaw_rad ); mat4_rotation_x( &pitch_rot, -pitch_rad ); mat4_translation( &transl, -pos.x, -pos.z, -pos.y ); |
