binary message system
[vg.git] / vg_lines.h
index a16f5020481a35a7ce3b76048859c144b89d3238..5c88d9bc8f40c57f9e7838a3c5b722c0cefa302b 100644 (file)
@@ -68,57 +68,55 @@ struct{
 }
 static vg_lines;
 
+VG_STATIC void async_vg_lines_init( void *payload, u32 payload_size )
+{
+   glGenVertexArrays( 1, &vg_lines.vao );
+   glGenBuffers( 1, &vg_lines.vbo );
+   glBindVertexArray( vg_lines.vao );
+   glBindBuffer( GL_ARRAY_BUFFER, vg_lines.vbo );
+   
+   u32 size = 50000 * sizeof( struct vg_lines_vert );
+
+   vg_lines.vertex_buffer = 
+      vg_create_linear_allocator(vg_mem.rtmemory, size, VG_MEMORY_REALTIME);
+   
+   glBufferData( GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW );
+   glBindVertexArray( vg_lines.vao );
+   VG_CHECK_GL_ERR();
+
+   /* Pointers */
+   glVertexAttribPointer( 
+      0, 
+      3,
+      GL_FLOAT, 
+      GL_FALSE, 
+      sizeof( struct vg_lines_vert ), 
+      (void *)0 
+   );
+   glEnableVertexAttribArray( 0 );
+   
+   glVertexAttribPointer( 
+      1, 
+      4, 
+      GL_UNSIGNED_BYTE, 
+      GL_TRUE, 
+      sizeof( struct vg_lines_vert ), 
+      (void*)(offsetof( struct vg_lines_vert, colour ))
+   );
+   glEnableVertexAttribArray( 1 );
+   
+   VG_CHECK_GL_ERR();
+   vg_lines.allow_input = 1;
+}
+
 VG_STATIC void vg_lines_init(void)
 {
-   vg_info( "vg_lines_init\n" );
+   vg_async_call( async_vg_lines_init, NULL, 0 );
 
    vg_console_reg_var( "vg_lines", &vg_lines.draw, k_var_dtype_i32, 
                        VG_VAR_CHEAT );
    vg_shader_register( &_shader_lines );
 
-   vg_acquire_thread_sync();
-   {
-      glGenVertexArrays( 1, &vg_lines.vao );
-      glGenBuffers( 1, &vg_lines.vbo );
-      glBindVertexArray( vg_lines.vao );
-      glBindBuffer( GL_ARRAY_BUFFER, vg_lines.vbo );
-      
-      u32 size = 50000 * sizeof( struct vg_lines_vert );
-
-      vg_lines.vertex_buffer = 
-         vg_create_linear_allocator(vg_mem.rtmemory, size, VG_MEMORY_REALTIME);
-      
-      glBufferData( GL_ARRAY_BUFFER, size, NULL, GL_DYNAMIC_DRAW );
-      glBindVertexArray( vg_lines.vao );
-      VG_CHECK_GL_ERR();
-
-      /* Pointers */
-      glVertexAttribPointer( 
-         0, 
-         3,
-         GL_FLOAT, 
-         GL_FALSE, 
-         sizeof( struct vg_lines_vert ), 
-         (void *)0 
-      );
-      glEnableVertexAttribArray( 0 );
-      
-      glVertexAttribPointer( 
-         1, 
-         4, 
-         GL_UNSIGNED_BYTE, 
-         GL_TRUE, 
-         sizeof( struct vg_lines_vert ), 
-         (void*)(offsetof( struct vg_lines_vert, colour ))
-      );
-      glEnableVertexAttribArray( 1 );
-      
-      VG_CHECK_GL_ERR();
-      vg_success( "done\n" );
-   }
-
-   vg_release_thread_sync();
-   vg_lines.allow_input = 1;
 }
 
 VG_STATIC void vg_lines_drawall( void )
@@ -151,6 +149,8 @@ VG_STATIC void vg_line2( line_co from, line_co to, u32 fc, u32 tc )
    if( !vg_lines.allow_input )
       return;
 
+   return;
+
    u32 size = 2 * sizeof(struct vg_lines_vert);
        struct vg_lines_vert *v = vg_linear_alloc( vg_lines.vertex_buffer, size );