diff options
| author | aura <nw@moneybot.cc> | 2026-03-10 05:34:22 +0100 |
|---|---|---|
| committer | aura <nw@moneybot.cc> | 2026-03-10 05:34:22 +0100 |
| commit | 4d83331b3fbeaa16eeb360c06f9f1ffc41a9326f (patch) | |
| tree | 77f7ba2ff78e1aa02e953801d06ce713ee08dcf9 /src | |
| parent | 30151d75dddd651faa1b27148a052ced7d0f190a (diff) | |
handle drawing world in 3dview better
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor/view3d.cpp | 47 | ||||
| -rw-r--r-- | src/render/gl_batch.h | 12 |
2 files changed, 17 insertions, 42 deletions
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; diff --git a/src/render/gl_batch.h b/src/render/gl_batch.h index 04f72a7..21b8f58 100644 --- a/src/render/gl_batch.h +++ b/src/render/gl_batch.h @@ -125,14 +125,12 @@ inline void gl_batch_draw( GL_BATCH<VERTEX>* batch ) { inline U8 gl_batch_is_allowed_primitive( U16 primitive ) { switch( primitive ) { - case GL_TRIANGLE_FAN: - case GL_TRIANGLE_STRIP: - case GL_QUAD_STRIP: - case GL_LINE_STRIP: - case GL_LINE_LOOP: - return 0; - default: + case GL_TRIANGLES: + case GL_LINES: + case GL_QUADS: return 1; + default: + return 0; } } |
