};
struct{
- u32 draw,
- allow_input;
+ u32 enabled,
+ render;
struct vg_lines_vert{
v3f co;
glEnableVertexAttribArray( 1 );
VG_CHECK_GL_ERR();
- vg_lines.allow_input = 1;
}
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 );
}
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 );
}
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 );
}
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 );
}
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<<j)? box[1][j]: box[0][j];
static void vg_line_mesh( v3f verts[], u32 indices[][2], u32 indice_count,
u32 colour ){
+ if( !vg_lines.enabled ) return;
+
for( u32 i=0; i<indice_count; i++ ){
vg_line( verts[indices[i][0]], verts[indices[i][1]], colour );
}
}
static void vg_line_boxf( boxf box, u32 colour ){
+ if( !vg_lines.enabled ) return;
+
v3f verts[8];
vg_line_box_verts( box, verts );
u32 indices[][2] = {{0,1},{1,3},{3,2},{2,0},
}
static void vg_line_boxf_transformed( m4x3f m, boxf box, u32 colour ){
+ if( !vg_lines.enabled ) return;
+
v3f verts[8];
vg_line_box_verts( box, verts );
}
static void vg_line_cross(v3f pos,u32 colour, float scale){
+ if( !vg_lines.enabled ) return;
+
v3f p0, p1;
v3_add( (v3f){ scale,0.0f,0.0f}, pos, p0 );
v3_add( (v3f){-scale,0.0f,0.0f}, pos, p1 );
}
static void vg_line_point( v3f pt, float size, u32 colour ){
+ if( !vg_lines.enabled ) return;
+
boxf box =
{
{ pt[0]-size, pt[1]-size, pt[2]-size },
static void vg_line_sphere( m4x3f m, float radius, u32 colour ){
+ if( !vg_lines.enabled ) return;
+
v3f ly = { 0.0f, 0.0f, radius },
lx = { 0.0f, radius, 0.0f },
lz = { 0.0f, 0.0f, radius };
}
static void vg_line_capsule( m4x3f m, float radius, float h, u32 colour ){
+ if( !vg_lines.enabled ) return;
+
v3f ly = { 0.0f, 0.0f, radius },
lx = { 0.0f, radius, 0.0f },
lz = { 0.0f, 0.0f, radius };