diff options
| author | kasull <qsullian@gmail.com> | 2026-03-01 20:18:08 -0500 |
|---|---|---|
| committer | kasull <qsullian@gmail.com> | 2026-03-01 20:18:08 -0500 |
| commit | 413ef78504278d37080b9b59a652e4bbd5e2a0fc (patch) | |
| tree | 67be817cf765725dd2d08c14b2d0ce8c12b20997 /src/render/gl_3d.cpp | |
| parent | 71dd7fcccb45a54d85ae23a95a8a8905ed21fe15 (diff) | |
editor ui rework
add responsive editor relayout for window resize
rework header with back/save, view mode buttons, and 2d view type selector
add clipped, scrollable assets and contextual tool panels
simplify tool button wiring and repeated layout logic
simplify 2d top-down editor internals and shared grid update hooks
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 ); |
