X-Git-Url: https://harrygodden.com/git/?p=vg.git;a=blobdiff_plain;f=vg_lines.h;fp=vg_lines.h;h=8fff226106e7bc2a007611636226a339910ac294;hp=5511875b9f058747c30afce32d7f40d13cb09049;hb=1c305409e8eca9cf8449d681df73208956ce14df;hpb=1abb54856257b10f6a20a4980a31930c59e3d37c diff --git a/vg_lines.h b/vg_lines.h index 5511875..8fff226 100644 --- a/vg_lines.h +++ b/vg_lines.h @@ -59,8 +59,8 @@ static struct vg_shader _shader_lines = { }; struct{ - u32 draw, - allow_input; + u32 enabled, + render; struct vg_lines_vert{ v3f co; @@ -106,7 +106,6 @@ static void async_vg_lines_init( void *payload, u32 payload_size ){ glEnableVertexAttribArray( 1 ); VG_CHECK_GL_ERR(); - vg_lines.allow_input = 1; } static void vg_lines_init(void){ @@ -116,7 +115,7 @@ static void vg_lines_init(void){ vg_async_call( async_vg_lines_init, NULL, 0 ); - vg_console_reg_var( "vg_lines", &vg_lines.draw, k_var_dtype_i32, + vg_console_reg_var( "vg_lines", &vg_lines.render, k_var_dtype_i32, VG_VAR_CHEAT ); vg_shader_register( &_shader_lines ); } @@ -131,14 +130,13 @@ static void vg_lines_drawall( void ){ glBindBuffer( GL_ARRAY_BUFFER, vg_lines.vbo ); u32 bufusage = vg_linear_get_cur(vg_lines.vertex_buffer); - glBufferSubData( GL_ARRAY_BUFFER, 0, bufusage, vg_lines.vertex_buffer ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBlendEquation( GL_FUNC_ADD ); - if( vg_lines.draw ) + if( vg_lines.render ) glDrawArrays( GL_LINES, 0, bufusage / sizeof(struct vg_lines_vert) ); glDisable( GL_BLEND ); @@ -146,8 +144,7 @@ static void vg_lines_drawall( void ){ } static void vg_line2( line_co from, line_co to, u32 fc, u32 tc ){ - if( !vg_lines.allow_input ) return; - if( !vg_lines.draw ) return; + if( !vg_lines.enabled ) return; u32 size = 2 * sizeof(struct vg_lines_vert); struct vg_lines_vert *v = vg_linear_alloc( vg_lines.vertex_buffer, size ); @@ -160,10 +157,14 @@ static void vg_line2( line_co from, line_co to, u32 fc, u32 tc ){ } static void vg_line( line_co from, line_co to, u32 colour ){ + if( !vg_lines.enabled ) return; + vg_line2( from, to, colour, colour ); } static void vg_line_arrow( line_co co, line_co dir, float size, u32 colour ){ + if( !vg_lines.enabled ) return; + v3f p1, tx, ty, p2, p3; v3_muladds( co, dir, size, p1 ); v3_tangent_basis( dir, tx, ty ); @@ -178,6 +179,8 @@ static void vg_line_arrow( line_co co, line_co dir, float size, u32 colour ){ } static void vg_line_box_verts( boxf box, v3f verts[8] ){ + if( !vg_lines.enabled ) return; + for( u32 i=0; i<8; i++ ){ for( u32 j=0; j<3; j++ ){ verts[i][j] = i&(0x1<