splitter switcher
[fishladder.git] / fishladder.c
index dc2d540a739edcf5dca8713443acb4572e33e3f7..49aa43ad1fe0b727835fd54a503abb1cd4adf196 100644 (file)
@@ -127,7 +127,7 @@ struct world
        
        u32 w, h;
        
-       struct mesh tile, circle;
+       struct mesh tile, circle, splitter_l, splitter_r;
        
        int selected;
        
@@ -341,6 +341,21 @@ void vg_start(void)
                init_mesh( &world.circle, circle_mesh, vg_list_size( circle_mesh ) );
        }
        
+       // splitters (temp)
+       {
+               float splitter_l[] =
+               {
+                       #include "models/splitter_l.obj.h"
+               };
+               float splitter_r[] =
+               {
+                       #include "models/splitter_r.obj.h"
+               };
+               
+               init_mesh( &world.splitter_l, splitter_l, vg_list_size( splitter_l ) );
+               init_mesh( &world.splitter_r, splitter_r, vg_list_size( splitter_r ) );
+       }
+       
        map_load
        ( 
                "#############;\n"
@@ -360,6 +375,8 @@ void vg_free(void)
 {
        free_mesh( &world.tile );
        free_mesh( &world.circle );
+       free_mesh( &world.splitter_l );
+       free_mesh( &world.splitter_r );
 
        map_free();
 }
@@ -729,7 +746,19 @@ void vg_render(void)
                        struct cell *cell = pcell((v2i){x,y});
                        int selected = world.selected == y*world.w + x;
                
-                       if( cell->state & FLAG_CANAL && !selected )
+                       if( cell->state & FLAG_SPLIT )
+                       {
+                               glUniform4f( SHADER_UNIFORM( shader_tile_colour, "uColour" ), 0.9f, 0.9f, 0.9f, 1.0f );
+                               glUniform3f( SHADER_UNIFORM( shader_tile_colour, "uOffset" ), (float)x, (float)y, 1.0f );
+                               
+                               struct mesh *splitter = cell->state & FLAG_FLIP_FLOP? &world.splitter_r: &world.splitter_l;
+                               
+                               use_mesh( splitter );
+                               draw_mesh( 0, splitter->elements );
+                               use_mesh( &world.tile );
+                       }
+               
+                       if( (cell->state & FLAG_CANAL) && !selected )
                                continue;
                
                        glUniform3f( SHADER_UNIFORM( shader_tile_colour, "uOffset" ), (float)x, (float)y, 1.0f );