getting stuff working on windows again
[vg.git] / vg_loader.h
index 3c519b57137bc99d19707c80b07c421e1c178079..a776322b8b1ab18b60dcae8113cea53dc382a058 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "common.h"
 
-VG_STATIC void vg_loader_start( void(*pfn)(void) );
+VG_STATIC void vg_loader_start( void(*pfn)(void *data), void *data );
 VG_STATIC void vg_loader_step( void( *fn_load )(void), void( *fn_free )(void) );
 
 static struct vg_shader _shader_loader = 
@@ -59,7 +59,6 @@ static struct vg_shader _shader_loader =
       
       "void main()"
       "{"
-
          "vec3 col = 0.5+0.5*sin( uTime + aUv.xyx + vec3(0.0,2.0,4.0) );"
          
          "vec2 uvx = aUv - vec2( 0.5 );"
@@ -79,8 +78,7 @@ static struct vg_shader _shader_loader =
 static struct vg_loader
 {
    /* Shutdown steps */
-   struct loader_free_step
-   {
+   struct loader_free_step{
       void (*fn_free)(void);
    }
    step_buffer[16];
@@ -190,15 +188,15 @@ VG_STATIC void _vg_loader_render(void)
 
 VG_STATIC void vg_load_full(void);
 
-VG_STATIC int _vg_loader_thread(void *pfn)
+VG_STATIC int _vg_loader_thread( void *pfn )
 {
    if( setjmp( vg.env_loader_exit ) )
       return 0;
 
    /* Run client loader */
    vg_info( "Starting client loader thread @%p\n", pfn );
-   void (*call_func)(void) = pfn;
-   call_func();
+   void (*call_func)(void *data) = pfn;
+   call_func( vg.thread_data );
 
    SDL_SemPost( vg.sem_loader );
    vg.thread_id_loader = 0;
@@ -206,9 +204,11 @@ VG_STATIC int _vg_loader_thread(void *pfn)
    return 0;
 }
 
-VG_STATIC void vg_loader_start( void(*pfn)(void) )
+VG_STATIC void vg_loader_start( void(*pfn)(void *data), void *data )
 {
    SDL_SemWait( vg.sem_loader );
+
+   vg.thread_data = data;
    SDL_CreateThread( _vg_loader_thread, "Loader thread", pfn );
 }