switched to command based rendering
[fishladder.git] / fishladder_resources.h
index 82efc47100aee05fcf6954141cd26c17cd6816dc..7b12859d44f94bb993c23fab06b9dd5627826e4f 100644 (file)
@@ -124,8 +124,11 @@ vg_tex2d tex_ball_noise =  { .path = "textures/bnoise.qoi" };
 vg_tex2d tex_monofur   =  { .path = "textures/ascii.qoi", .flags = VG_TEXTURE_NO_MIP };
 vg_tex2d tex_unkown            =  { .path = "textures/unkown.qoi" };
 vg_tex2d tex_buttons           =  { .path = "textures/buttons.qoi" };
+vg_tex2d tex_sprites           =  { .path = "textures/autocombine.qoi" };
 
-vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_ball_noise, &tex_monofur, &tex_unkown, &tex_buttons, &tex_ubuntu };
+vg_tex2d *texture_list[] = { &tex_tile_detail, &tex_tile_data, &tex_wood, &tex_ball_noise, &tex_monofur, &tex_unkown, &tex_buttons, &tex_ubuntu, &tex_sprites };
+
+#include "sprites_autocombine.h"
 
 // AUDIO
 // ===========================================================================================================
@@ -600,7 +603,6 @@ SHADER_DEFINE( shader_sdf,
        "out vec4 FragColor;"
        ""
        "in vec2 aTexCoords;"
-       "in vec4 aColour;"
        ""
        "void main()"
        "{"
@@ -612,6 +614,40 @@ SHADER_DEFINE( shader_sdf,
        UNIFORMS({ "uPv", "uTexGlyphs", "uColour" })
 )
 
+SHADER_DEFINE( shader_sprite,
+
+       // VERTEX
+       "layout (location=0) in vec2 a_co;" // quad mesh
+       "layout (location=1) in vec4 ins_uv;"  // instanced data (uv)
+       "layout (location=2) in vec3 ins_pos;" // position + scale
+       ""
+       "uniform mat3 uPv;"
+       ""
+       "out vec2 aTexCoords;"
+       ""
+       "void main()"
+       "{"
+               "vec2 vertex_world = ins_uv.zw * a_co * ins_pos.z + ins_pos.xy;"
+               "gl_Position = vec4( uPv * vec3( vertex_world, 1.0 ), 1.0 );"
+               "aTexCoords = ins_uv.xy + (a_co+0.5)*ins_uv.zw;"
+       "}",
+       
+       // FRAGMENT
+       "uniform sampler2D uTexMain;"
+       "uniform vec4 uColour;"
+       "out vec4 FragColor;"
+       ""
+       "in vec2 aTexCoords;"
+       ""
+       "void main()"
+       "{"
+               "vec4 glyph = texture( uTexGlyphs, aTexCoords );"
+               "FragColor = glyph;"
+       "}"
+       ,
+       UNIFORMS({ "uPv", "uTexMain", "uColour" })
+)
+
 void vg_register(void)
 {
        SHADER_INIT( shader_tile_colour );