From 413ef78504278d37080b9b59a652e4bbd5e2a0fc Mon Sep 17 00:00:00 2001 From: kasull Date: Sun, 1 Mar 2026 20:18:08 -0500 Subject: 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 --- src/render/gl_3d.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/render/gl_3d.cpp') 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 ); -- cgit v1.2.3