revision 2
[carveJwlIkooP6JGAAIwe30JlM.git] / trail.c
diff --git a/trail.c b/trail.c
index 3399694923e2fed841efd3069992e084aa4c0b14..6bdee69262a8d0eab261862fca9b9914263c48f7 100644 (file)
--- a/trail.c
+++ b/trail.c
@@ -1,4 +1,10 @@
 #pragma once
+#include "vg/vg_engine.h"
+#include "vg/vg_platform.h"
+#include "vg/vg_m.h"
+#include "vg/vg_lines.h"
+#include "vg/vg_async.h"
+#include "vg/vg_camera.h"
 #include "trail.h"
 #include "shaders/particle.h"
 #include "shaders/trail.h"
@@ -14,8 +20,9 @@ static void trail_increment( trail_system *sys ){
       sys->count ++;
 }
 
-static void trail_system_update( trail_system *sys, f32 dt,
-                                 v3f co, v3f normal, f32 alpha ){
+void trail_system_update( trail_system *sys, f32 dt,
+                          v3f co, v3f normal, f32 alpha )
+{
    /* update existing points and clip dead ones */
    bool clip_allowed = 1;
    for( i32 i=0; i<sys->count; i ++ ){
@@ -82,7 +89,8 @@ static void trail_system_update( trail_system *sys, f32 dt,
    pdest->alpha = alpha;
 }
 
-static void trail_system_debug( trail_system *sys ){
+void trail_system_debug( trail_system *sys )
+{
    for( i32 i=0; i<sys->count; i ++ ){
       i32 i0 = sys->head - sys->count + i;
       if( i0 < 0 ) i0 += sys->max;
@@ -105,7 +113,8 @@ struct trail_init_args {
    trail_system *sys;
 };
 
-static void async_trail_init( void *payload, u32 size ){
+void async_trail_init( void *payload, u32 size )
+{
    struct trail_init_args *args = payload;
    trail_system *sys = args->sys;
 
@@ -125,7 +134,8 @@ static void async_trail_init( void *payload, u32 size ){
    VG_CHECK_GL_ERR();
 }
 
-static void trail_alloc( trail_system *sys, u32 max ){
+void trail_alloc( trail_system *sys, u32 max )
+{
    size_t stride = sizeof(trail_vert);
    sys->max = max;
    sys->array = vg_linear_alloc( vg_mem.rtmemory, max*sizeof(trail_point) );
@@ -138,7 +148,8 @@ static void trail_alloc( trail_system *sys, u32 max ){
    vg_async_dispatch( call, async_trail_init );
 }
 
-static void trail_system_prerender( trail_system *sys ){
+void trail_system_prerender( trail_system *sys )
+{
    if( sys->count < 2 ) return;
 
    for( i32 i=0; i<sys->count; i ++ ){
@@ -162,7 +173,8 @@ static void trail_system_prerender( trail_system *sys ){
    glBufferSubData( GL_ARRAY_BUFFER, 0, sys->count*stride*2, sys->vertices );
 }
 
-static void trail_system_render( trail_system *sys, camera *cam ){
+void trail_system_render( trail_system *sys, vg_camera *cam )
+{
    if( sys->count < 2 ) return;
    glDisable( GL_CULL_FACE );
    glEnable( GL_DEPTH_TEST );
@@ -175,7 +187,3 @@ static void trail_system_render( trail_system *sys, camera *cam ){
        glBindVertexArray( sys->vao );
    glDrawArrays( GL_TRIANGLE_STRIP, 0, sys->count*2 );
 }
-
-static void trail_init( void ){
-   shader_trail_register();
-}