From 4d83331b3fbeaa16eeb360c06f9f1ffc41a9326f Mon Sep 17 00:00:00 2001 From: aura Date: Tue, 10 Mar 2026 05:34:22 +0100 Subject: handle drawing world in 3dview better --- src/editor/view3d.cpp | 47 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) (limited to 'src/editor/view3d.cpp') diff --git a/src/editor/view3d.cpp b/src/editor/view3d.cpp index cdec211..fd27cf3 100644 --- a/src/editor/view3d.cpp +++ b/src/editor/view3d.cpp @@ -19,31 +19,10 @@ void gui_editor_3dview_draw_showpos( GUI_EDITOR_3DVIEW* view ) { STR posstr = STR( "pos: %.02f %.02f %.02f (%.02f)", pos.x, pos.y, pos.z, speed ); STR rotstr = STR( "rot: %.02f %.02f", objl->pl->rot.y, objl->pl->rot.x ); - VEC2 posdim = gl_font_dim( _gui.fonts.jpn12.glfnt, posstr ); - VEC2 rotdim = gl_font_dim( _gui.fonts.jpn12.glfnt, rotstr ); - - gl_font_draw( - _gui.fonts.jpn12.glfnt, - _gui.batch->shader, - VEC2( x + view->w - 2 - posdim.x, y + 2 ), - posstr, - ui_clr.txt - ); - gl_font_draw( - _gui.fonts.jpn12.glfnt, - _gui.batch->shader, - VEC2( x + view->w - 2 - rotdim.x, y + 18 ), - rotstr, - ui_clr.txt - ); + gui_draw_str( x + view->w - 2, y + 2, ALIGN_R, FNT_JPN12, ui_clr.txt, posstr.data ); + gui_draw_str( x + view->w - 2, y + 18, ALIGN_R, FNT_JPN12, ui_clr.txt, rotstr.data ); if( input.mouselock ) { - gl_font_draw( - _gui.fonts.jpn12.glfnt, - _gui.batch->shader, - VEC2( x + 2, y + 2 ), - "[capturing mouse]", - ui_clr.txt - ); + gui_draw_str( x + 2, y + 2, ALIGN_L, FNT_JPN12, ui_clr.txt, "[capturing mouse]" ); } } @@ -73,21 +52,19 @@ void gui_editor_3dview_draw_fn( void* ptr ) { CLR col = gui_is_fg_window( view )? ui_clr.border : ui_clr.border_inactive; gui_draw_frect( x-1, y-1, view->w+2, view->h+2, col ); gui_draw_frect( x, y, view->w, view->h, CLR::BLACK() ); + // draw everything we have so far. the world will go on top + gl_batch_draw( _gui.batch ); + gl_batch_empty( _gui.batch ); + + gui_draw_push_clip( x, y, view->w, view->h ); if( editor->drawbsp && editor->map->bsp ) { - gui_push_callback( &data, fn( void* data ) { - WORLD_DRAW_CB_DATA* d = (WORLD_DRAW_CB_DATA*)data; - bsp_draw( editor->map->bsp, editor->game, d->wnd, d->winsize ); - gui_editor_3dview_draw_showpos( d->view); - } ); + bsp_draw( editor->map->bsp, editor->game, wnd, winsize ); + gui_editor_3dview_draw_showpos( view ); } else { - gui_push_callback( &data, fn( void* data ) { - WORLD_DRAW_CB_DATA* d = (WORLD_DRAW_CB_DATA*)data; - world_draw( editor->game, objl->world, d->wnd, d->winsize ); - gui_editor_3dview_draw_showpos( d->view ); - } ); + world_draw( editor->game, objl->world, wnd, winsize ); + gui_editor_3dview_draw_showpos( view ); } - gui_draw_push_clip( x, y, view->w, view->h ); view->children.each( fn( GUI_BASE** childptr ) { GUI_BASE* child = *childptr; if( !child->enabled ) return; -- cgit v1.2.3