update helpers/location to 'frosted' ui
[carveJwlIkooP6JGAAIwe30JlM.git] / particle.c
index 9c1f87e5e044f8674b4995cc4f6ee53367004c60..2e05a1923dc05a5d94560731832d94704a339b1f 100644 (file)
@@ -1,8 +1,22 @@
+#include "vg/vg_lines.h"
+#include "vg/vg_async.h"
 #include "particle.h"
-#include "shaders/trail.h"
+#include "shaders/particle.h"
+
+struct particle_system particles_grind = {
+   .scale = 0.02f,
+   .velocity_scale = 0.001f,
+   .width = 0.0125f
+},
+particles_env = {
+   .scale = 0.04f,
+   .velocity_scale = 0.001f,
+   .width = 0.25f
+};
 
-static void particle_spawn( particle_system *sys, 
-                            v3f co, v3f v, f32 lifetime, u32 colour ){
+void particle_spawn( particle_system *sys, v3f co, v3f v,
+                     f32 lifetime, u32 colour )
+{
    if( sys->alive == sys->max ) return;
 
    particle *p = &sys->array[ sys->alive ++ ];
@@ -12,9 +26,10 @@ static void particle_spawn( particle_system *sys,
    p->colour = colour;
 }
 
-static void particle_spawn_cone( particle_system *sys, 
-                                 v3f co, v3f dir, f32 angle, f32 speed, 
-                                 f32 lifetime, u32 colour ){
+void particle_spawn_cone( particle_system *sys, 
+                          v3f co, v3f dir, f32 angle, f32 speed, 
+                          f32 lifetime, u32 colour )
+{
    if( sys->alive == sys->max ) return;
 
    particle *p = &sys->array[ sys->alive ++ ];
@@ -33,7 +48,8 @@ static void particle_spawn_cone( particle_system *sys,
    v3_copy( co, p->co );
 }
 
-static void particle_system_update( particle_system *sys, f32 dt ){
+void particle_system_update( particle_system *sys, f32 dt )
+{
    u32 i = 0;
 iter: if( i == sys->alive ) return;
 
@@ -52,7 +68,8 @@ iter: if( i == sys->alive ) return;
    goto iter;
 }
 
-static void particle_system_debug( particle_system *sys ){
+void particle_system_debug( particle_system *sys )
+{
    for( u32 i=0; i<sys->alive; i ++ ){
       particle *p = &sys->array[i];
       v3f p1;
@@ -95,11 +112,8 @@ static void async_particle_init( void *payload, u32 size ){
    VG_CHECK_GL_ERR();
 }
 
-static void particle_init(void){
-   shader_particle_register();
-}
-
-static void particle_alloc( particle_system *sys, u32 max ){
+void particle_alloc( particle_system *sys, u32 max )
+{
    size_t stride = sizeof(particle_vert);
 
    sys->max = max;
@@ -123,7 +137,8 @@ static void particle_alloc( particle_system *sys, u32 max ){
    vg_async_dispatch( call, async_particle_init );
 }
 
-static void particle_system_prerender( particle_system *sys ){
+void particle_system_prerender( particle_system *sys )
+{
    for( u32 i=0; i<sys->alive; i ++ ){
       particle *p = &sys->array[i];
       particle_vert *vs = &sys->vertices[i*4];
@@ -160,7 +175,8 @@ static void particle_system_prerender( particle_system *sys ){
    glBufferSubData( GL_ARRAY_BUFFER, 0, sys->alive*stride*4, sys->vertices );
 }
 
-static void particle_system_render( particle_system *sys, camera *cam ){
+void particle_system_render( particle_system *sys, vg_camera *cam )
+{
    glDisable( GL_CULL_FACE );
    glEnable( GL_DEPTH_TEST );