my fucking fingers
[carveJwlIkooP6JGAAIwe30JlM.git] / render.h
index a4005ddbcec76028b77fd873c6b9b8dca479a7b1..41aeef241ef529b7bc33522f8cb1dea880b3d067 100644 (file)
--- a/render.h
+++ b/render.h
@@ -36,7 +36,8 @@ VG_STATIC struct pipeline{
 
    framebuffer *fb_main,
                *fb_water_reflection,
-               *fb_water_beneath;
+               *fb_water_beneath,
+               *fb_workshop_preview;
    int ready;
 
    float view_render_scale,
@@ -175,6 +176,27 @@ framebuffers[] =
             .attachment     = GL_DEPTH_STENCIL_ATTACHMENT
          }
       }
+   },
+   {
+      "workshop_preview",
+      .link = &gpipeline.fb_workshop_preview,
+      .resolution_div = 0,
+      .fixed_w = 504, .fixed_h = 336,
+      .attachments = 
+      {
+         {
+            "colour", k_framebuffer_attachment_type_texture,
+            .internalformat = GL_RGB,
+            .format         = GL_RGB,
+            .type           = GL_UNSIGNED_BYTE,
+            .attachment     = GL_COLOR_ATTACHMENT0
+         },
+         {
+            "depth_stencil", k_framebuffer_attachment_type_renderbuffer,
+            .internalformat = GL_DEPTH24_STENCIL8,
+            .attachment = GL_DEPTH_STENCIL_ATTACHMENT
+         }
+      }
    }
 };
 
@@ -244,7 +266,7 @@ VG_STATIC void render_fb_bind_texture( framebuffer *fb,
    if( (at->purpose != k_framebuffer_attachment_type_texture) &&
        (at->purpose != k_framebuffer_attachment_type_texture_depth) )
    {
-      vg_fatal_exit_loop( "illegal operation: bind non-texture framebuffer"
+      vg_fatal_error( "illegal operation: bind non-texture framebuffer"
                           " attachment to texture slot" );
    }
 
@@ -480,7 +502,7 @@ VG_STATIC void render_fb_allocate( struct framebuffer *fb )
          vg_error( "  status: Generic Error" );
 
       vg_info( "}\n" );
-      vg_fatal_exit_loop( "Incomplete framebuffer (see logs)" );
+      vg_fatal_error( "Incomplete framebuffer (see logs)" );
    }
 }
 
@@ -503,16 +525,23 @@ VG_STATIC void render_fb_resize(void)
 
 VG_STATIC int render_framebuffer_control( int argc, char const *argv[] );
 VG_STATIC void render_framebuffer_poll( int argc, char const *argv[] );
-VG_STATIC void render_init_fs_quad(void)
+
+VG_STATIC void async_render_init( void *payload, u32 size )
 {
-   vg_info( "[render] Allocate quad\n" );
+   /* 
+    * Complete Framebuffers
+    */
+   for( int i=0; i<vg_list_size(framebuffers); i++ ){
+      struct framebuffer *fb = &framebuffers[i];
+      render_fb_allocate( fb );
+   }
 
    float quad[] = { 
-      0.00f,0.00f, 1.00f,1.00f, 0.00f,1.00f,
-      0.00f,0.00f, 1.00f,0.00f, 1.00f,1.00f,
+      0.00f,0.00f, 1.00f,1.00f, 0.00f,1.00f,    /* fsquad */
+      0.00f,0.00f, 1.00f,0.00f, 1.00f,1.00f,    
 
-      0.20f,0.00f, 0.80f,1.00f, 0.20f,1.00f,
-      0.20f,0.00f, 0.80f,0.00f, 0.80f,1.00f,
+      0.00f,0.00f, 1.00f,0x1p-4f,0.00f,0x1p-4f,    /* fsquad1 */
+      0.00f,0.00f, 1.00f,0.00f,  1.00f,0x1p-4f,
 
       /* 9x9 debug grid */
       /* row0 */
@@ -552,6 +581,9 @@ VG_STATIC void render_init_fs_quad(void)
    glEnableVertexAttribArray( 0 );
 
    VG_CHECK_GL_ERR();
+
+   glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+   gpipeline.ready = 1;
 }
 
 VG_STATIC void render_init(void)
@@ -560,23 +592,7 @@ VG_STATIC void render_init(void)
    shader_blitblur_register();
    shader_blitcolour_register();
 
-   vg_acquire_thread_sync();
-   {
-      /* 
-       * Complete Framebuffers
-       */
-      for( int i=0; i<vg_list_size(framebuffers); i++ ){
-         struct framebuffer *fb = &framebuffers[i];
-         render_fb_allocate( fb );
-      }
-
-      render_init_fs_quad();
-
-      glBindFramebuffer( GL_FRAMEBUFFER, 0 );
-      gpipeline.ready = 1;
-   }
-
-   vg_release_thread_sync();
+   vg_async_call( async_render_init, NULL, 0 );
 }
 
 /*
@@ -599,6 +615,7 @@ VG_STATIC void render_fsquad1(void)
  */
 VG_STATIC void render_view_framebuffer_ui(void)
 {
+#if 0
    int viewing_count = 0;
 
    glBindVertexArray( gpipeline.fsquad.vao );
@@ -649,6 +666,7 @@ VG_STATIC void render_view_framebuffer_ui(void)
          viewing_count ++;
       }
    }
+#endif
 }
 
 VG_STATIC void render_framebuffer_show( struct framebuffer *fb,