- int ptr = vg_log.buffer_line_current;
-
- vg_uictx.cursor[0] = 0;
- vg_uictx.cursor[1] = lines_to_draw*fh;
- vg_uictx.cursor[3] = fh;
- ui_fill_x();
-
- for( int i=0; i<lines_to_draw; i ++ )
- {
- ptr --;
-
- if( ptr < 0 )
- ptr = vg_list_size( vg_log.buffer )-1;
-
- ui_text( vg_uictx.cursor, vg_log.buffer[ptr], 1, 0 );
- vg_uictx.cursor[1] -= fh;
- }
-
- SDL_AtomicUnlock( &log_print_sl );
-
- ui_resolve();
- ui_draw( NULL );
-}
-
-VG_STATIC void vg_loader_render(void)
-{
- glViewport( 0,0, vg.window_x, vg.window_y );
- glBindFramebuffer( GL_FRAMEBUFFER, 0 );
- glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
- glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
-
- glUseProgram( _shader_loader.id );
- glUniform1f( glGetUniformLocation( _shader_loader.id, "uTime" ), vg.time );
-
- glBindVertexArray( vg_loader.vao );
- glDrawArrays( GL_TRIANGLES, 0, 6 );
-
- vg_render_log();
-}
-
-
-VG_STATIC void vg_load_full(void);
-
-VG_STATIC int vg_loader_thread(void * nothing)
-{
- SDL_AtomicLock( &vg.sl_context );
- vg.thread_id_loader = SDL_GetThreadID(NULL);
- SDL_AtomicUnlock( &vg.sl_context );
-
- /* Run client loader */
- vg_load_full();
-
- SDL_SemPost( vg.sem_loader );
- vg.thread_id_loader = 0;
-
- return 0;
-}
-
-VG_STATIC void vg_loader_start(void)
-{
- SDL_SemWait( vg.sem_loader );
- SDL_CreateThread( vg_loader_thread, "Loader thread", NULL );
-}
-
-/* this is maybe probably unused now */
-VG_STATIC void vg_free_libc_malloced( void *data )
-{
- free( data );
-}
-
-VG_STATIC void vg_loader_push_free_step( struct loader_free_step step )
-{
- if( vg_loader.step_count == vg_list_size(vg_loader.step_buffer) )
- vg_fatal_exit_loop( "Too many free steps" );
-
- vg_loader.step_buffer[ vg_loader.step_count ++ ] = step;
-}
-
-/*
- * Schedule something to be ran now, freed later. Checks in with engine status
- */
-VG_STATIC void vg_loader_highwater( void( *fn_load )(void),
- void( *fn_free )(void *), void *data )
-{
- if( fn_load )
- fn_load();
-
- if( fn_free )
- {
- struct loader_free_step step;
- step.data = data;
- step.fn_free = fn_free;
-
- vg_loader_push_free_step( step );
- }
- else
- {
- if( data )
- {
- struct loader_free_step step;
- step.data = data;
- step.fn_free = vg_free_libc_malloced;
-
- vg_loader_push_free_step( step );
- }
- }
-
- vg_ensure_engine_running();
-}