From 413eb84b6c807cbd7977b64eead54a0a23fd2fa3 Mon Sep 17 00:00:00 2001 From: Garux Date: Fri, 19 Sep 2025 03:58:33 +0500 Subject: [PATCH] * render camera crosshair sharply independently of viewport size, with shadow --- docs/changelog-custom.txt | 1 + radiant/camwindow.cpp | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/docs/changelog-custom.txt b/docs/changelog-custom.txt index 0e7c0239..0da2357e 100644 --- a/docs/changelog-custom.txt +++ b/docs/changelog-custom.txt @@ -1143,6 +1143,7 @@ misc... * Layers Browser: New Layer, Show All Layers, Hide All Layers buttons * new icons by Julius, high dpi scaling support * improved GUI themes, new unmodified Fusion theme, external .qss file + * render camera crosshair sharply independently of viewport size, with shadow diff --git a/radiant/camwindow.cpp b/radiant/camwindow.cpp index d02e50a6..43b283e8 100644 --- a/radiant/camwindow.cpp +++ b/radiant/camwindow.cpp @@ -2084,16 +2084,24 @@ void CamWnd::Cam_Draw(){ // draw the crosshair if ( m_bFreeMove ) { - gl().glBegin( GL_LINES ); - gl().glVertex2f( (float)m_Camera.width / 2.f, (float)m_Camera.height / 2.f + 6 ); - gl().glVertex2f( (float)m_Camera.width / 2.f, (float)m_Camera.height / 2.f + 2 ); - gl().glVertex2f( (float)m_Camera.width / 2.f, (float)m_Camera.height / 2.f - 6 ); - gl().glVertex2f( (float)m_Camera.width / 2.f, (float)m_Camera.height / 2.f - 2 ); - gl().glVertex2f( (float)m_Camera.width / 2.f + 6, (float)m_Camera.height / 2.f ); - gl().glVertex2f( (float)m_Camera.width / 2.f + 2, (float)m_Camera.height / 2.f ); - gl().glVertex2f( (float)m_Camera.width / 2.f - 6, (float)m_Camera.height / 2.f ); - gl().glVertex2f( (float)m_Camera.width / 2.f - 2, (float)m_Camera.height / 2.f ); - gl().glEnd(); + // .5 coords for exact pixel rendering + const Vector2 cent( ( m_Camera.width + 1 ) / 2 + .5f, ( m_Camera.height + 1 ) / 2 + .5f ); + constexpr float a = 6.5, b = 2.5; + for( float f : { 0.f, 1.f } ) + { + gl().glColor3f( f, f, f ); + const Vector2 verts[]{ + cent + Vector2( 0, a ) - Vector2( f, f ), + cent + Vector2( 0, b ) - Vector2( f, f ), + cent + Vector2( 0, -a ) - Vector2( f, f ), + cent + Vector2( 0, -b ) - Vector2( f, f ), + cent + Vector2( a, 0 ) - Vector2( f, f ), + cent + Vector2( b, 0 ) - Vector2( f, f ), + cent + Vector2( -a, 0 ) - Vector2( f, f ), + cent + Vector2( -b, 0 ) - Vector2( f, f ) }; + gl().glVertexPointer( 2, GL_FLOAT, sizeof( *verts ), verts->data() ); + gl().glDrawArrays( GL_LINES, 0, std::size( verts ) ); + } } if ( g_camwindow_globals.m_showStats ) {