// ===========================================================================================================
static int colour_set_id = 0;
+static int world_theme_id = 0;
static v3f colour_sets[][4] =
{
},
};
+static struct world_theme
+{
+ const char *name;
+ v3f colour_bg;
+ vg_tex2d *tex_tiles;
+}
+world_themes[] =
+{
+ {
+ "Wood",
+ {},
+ &tex_tiles_wood
+ },
+ {
+ "Minimal",
+ {},
+ &tex_tiles_min
+ },
+ {
+ "Lab",
+ {},
+ &tex_tiles_lab
+ }
+};
+
static void colour_code_v3( char const cc, v3f target )
{
if( cc >= 'a' && cc <= 'z' )
}
}
+static void render_sprite( enum sprites_auto_combine_index id, v3f pos )
+{
+ struct vg_sprite *sp = &sprites_auto_combine[ id ];
+
+ glUniform4fv( SHADER_UNIFORM( shader_sprite, "uUv" ), 1, sp->uv_xywh );
+ glUniform3f( SHADER_UNIFORM( shader_sprite, "uPos" ), pos[0], pos[1], pos[2] * world.st.world_transition );
+
+ draw_mesh( 0, 2 );
+}
+
void vg_render(void)
{
glViewport( 0,0, vg_window_x, vg_window_y );
int const empty_start = circle_base+32;
int const empty_count = circle_base+32*2;
+ struct world_theme *theme = &world_themes[ world_theme_id ];
+
if( !world.initialzed )
return;
// Bind textures
vg_tex2d_bind( &tex_tile_data, 0 );
glUniform1i( SHADER_UNIFORM( shader_tile_main, "uTexGlyphs" ), 0 );
-
- vg_tex2d_bind( &tex_wood, 1 );
+
+ vg_tex2d_bind( theme->tex_tiles, 1 );
glUniform1i( SHADER_UNIFORM( shader_tile_main, "uTexWood" ), 1 );
render_tiles( colour_default, colour_default );
vg_tex2d_bind( &tex_tile_data, 0 );
glUniform1i( SHADER_UNIFORM( shader_tile_main, "uTexGlyphs" ), 0 );
- vg_tex2d_bind( &tex_wood, 1 );
+ // TODO: is this needed to be rebinded?
+ vg_tex2d_bind( theme->tex_tiles, 1 );
glUniform1i( SHADER_UNIFORM( shader_tile_main, "uTexWood" ), 1 );
glUniform1f( SHADER_UNIFORM( shader_tile_main, "uForeground" ), 1.0f );
if( vg_get_button_up( "primary" ) )
world_button_exec( NULL, NULL, NULL, NULL );
+
+ // SPRITES
+ // ========================================================================================================
+ SHADER_USE( shader_sprite );
+ glUniformMatrix3fv( SHADER_UNIFORM( shader_sprite, "uPv" ), 1, GL_FALSE, (float *)vg_pv );
+
+ vg_tex2d_bind( &tex_sprites, 0 );
+ glUniform1i( SHADER_UNIFORM( shader_sprite, "uTexMain" ), 0 );
+
+ for( int i = 0; i < world.tile_special_count; i ++ )
+ {
+ struct render_cmd *cmd = &world.cmd_buf_specials[i];
+ struct cell *cell = cmd->ptr;
+
+ if( cell->config == k_cell_type_split )
+ {
+ v2f center = { cmd->pos[0] + 0.5f, cmd->pos[1] + 0.5f };
+
+ v3f p0 = { 0.0f, 0.0f, 4.0f };
+ v3f p1 = { 0.0f, 0.0f, 4.0f };
+
+ v2_add( center, (v2f){ -0.25f, -0.25f }, p0 );
+ v2_add( center, (v2f){ 0.25f, -0.25f }, p1 );
+
+ render_sprite( k_sprite_jack_1, p0 );
+ render_sprite( k_sprite_jack_2, p1 );
+ }
+ }
// TEXT ELEMENTS
// ========================================================================================================
// SUB SPLITTER DIRECTION
// ========================================================================================================
- // TODO: Make this sprites probably
glUniform4f( SHADER_UNIFORM( shader_tile_colour, "uColour" ), 0.9f, 0.35f, 0.1f, 0.75f );
draw_mesh( cell->state & FLAG_FLIP_FLOP? 5: 4, 1 );
}
}
+
+ // LIGHT FLARES
+ // ========================================================================================================
+ glBlendFunc(GL_ONE, GL_ONE);
+ glBlendEquation(GL_FUNC_ADD);
+
+ SHADER_USE( shader_sprite );
+
+ vg_tex2d_bind( &tex_sprites, 0 );
+ glUniform1i( SHADER_UNIFORM( shader_sprite, "uTexMain" ), 0 );
+ for( int i = 0; i < world.tile_special_count; i ++ )
+ {
+ struct render_cmd *cmd = &world.cmd_buf_specials[i];
+ struct cell *cell = cmd->ptr;
+
+ if( cell->config == k_cell_type_split )
+ {
+ v2f center = { cmd->pos[0] + 0.5f, cmd->pos[1] + 0.5f };
+
+ v3f p0 = { 0.0f, 0.0f, 12.0f };
+ v3f p1 = { 0.0f, 0.0f, 12.0f };
+
+ v2_add( center, (v2f){ -0.25f, -0.25f }, p0 );
+ v2_add( center, (v2f){ 0.25f, -0.25f }, p1 );
+
+ if( cell->state & FLAG_FLIP_FLOP )
+ render_sprite( k_sprite_flare_y, p1 );
+ else
+ render_sprite( k_sprite_flare_b, p0 );
+ }
+ }
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glBlendEquation(GL_FUNC_ADD);
+
// I/O ARRAYS
// ========================================================================================================
//glEnable(GL_BLEND);
-
+ SHADER_USE( shader_tile_colour );
+
for( int i = 0; i < arrlen( world.io ); i ++ )
{
struct cell_terminal *term = &world.io[ i ];
.persistent = 1
});
+ vg_convar_push( (struct vg_convar){
+ .name = "theme",
+ .data = &world_theme_id,
+ .data_type = k_convar_dtype_i32,
+ .opt_i32 = { .min = 0, .max = vg_list_size( world_themes )-1, .clamp = 1 },
+ .persistent = 1,
+ });
+
// Combined quad, long quad / empty circle / filled circle mesh
{
float combined_mesh[6*6 + 32*6*3] = {