shape glyphs, ui drawcall colour
authorhgn <hgodden00@gmail.com>
Sun, 12 Nov 2023 20:53:57 +0000 (20:53 +0000)
committerhgn <hgodden00@gmail.com>
Sun, 12 Nov 2023 20:53:57 +0000 (20:53 +0000)
src/fonts/vg_font_thin.png
src/fonts/vg_font_thin.xcf
vg_imgui.h
vg_pxfont_thin.h

index f03727a147c6f797820617366b557806590b2a07..82d031aab39660f6c01895f4f758fb31051c9c79 100644 (file)
Binary files a/src/fonts/vg_font_thin.png and b/src/fonts/vg_font_thin.png differ
index 9d991f0a0fb16a39e166c68de9078271b233702e..80cf62f193f549ca87b93462fa06257badd70d63 100644 (file)
Binary files a/src/fonts/vg_font_thin.xcf and b/src/fonts/vg_font_thin.xcf differ
index 0a83a53f714e6fe6e59bac27fe03eedfa2582e7d..53d8472302f8f3f5e6acb07a81e1860d654a5084 100644 (file)
@@ -220,6 +220,8 @@ struct{
    cursor;
 
    SDL_Cursor *cursor_map[ k_ui_cursor_max ];
+
+   v4f colour;
 } 
 static vg_ui = {
    .scheme = {
@@ -258,7 +260,8 @@ static vg_ui = {
       [ k_ui_purple + k_ui_brighter ] = UI_RGB( 0xd3869b ),
       [ k_ui_gray   + k_ui_brighter ] = UI_RGB( 0xa89984 ),
    },
-   .font = &vg_ui_font_small
+   .font = &vg_ui_font_small,
+   .colour = {1.0f,1.0f,1.0f,1.0f}
 };
 
 static struct vg_shader _shader_ui =
@@ -292,6 +295,7 @@ static struct vg_shader _shader_ui =
       .orig_file = NULL,
       .static_src = 
        "uniform sampler2D uTexGlyphs;"
+   "uniform vec4 uColour;"
        "out vec4 FragColor;"
        ""
        "in vec2 aTexCoords;"
@@ -309,7 +313,7 @@ static struct vg_shader _shader_ui =
                        "diffuse.a = texture( uTexGlyphs, aTexCoords ).r;"
                "}"
                
-               "FragColor = diffuse;"
+               "FragColor = diffuse * uColour;"
        "}"
    }
 };
@@ -344,6 +348,7 @@ static struct vg_shader _shader_ui_image = {
       .orig_file = NULL,
       .static_src = 
        "uniform sampler2D uTexImage;"
+   "uniform vec4 uColour;"
        "out vec4 FragColor;"
 
        "in vec2 aTexCoords;"
@@ -353,7 +358,7 @@ static struct vg_shader _shader_ui_image = {
        "void main()"
        "{"
                "vec4 colour = texture( uTexImage, aTexCoords );"
-               "FragColor = colour;"
+               "FragColor = colour * uColour;"
        "}"
    }
 };
@@ -512,6 +517,8 @@ static void ui_flush( enum ui_shader shader ){
       
       glUniformMatrix3fv( glGetUniformLocation( _shader_ui.id, "uPv" ), 1, 
                           GL_FALSE, (float *)view );
+      glUniform4fv( glGetUniformLocation( _shader_ui.id, "uColour" ), 1,
+                     vg_ui.colour );
        
       glActiveTexture( GL_TEXTURE0 );
       glBindTexture( GL_TEXTURE_2D, vg_ui.tex_glyphs );
@@ -522,6 +529,8 @@ static void ui_flush( enum ui_shader shader ){
       glUniformMatrix3fv( glGetUniformLocation( _shader_ui_image.id, "uPv" ), 1, 
                           GL_FALSE, (float *)view );
       glUniform1i( glGetUniformLocation(_shader_ui_image.id,"uTexImage"), 0 );
+      glUniform4fv( glGetUniformLocation( _shader_ui_image.id, "uColour" ), 1,
+                     vg_ui.colour );
    }
    else
       vg_fatal_error( "Invalid UI shader (%d)\n", shader );
index 198c9cd85787f7a13e9b3edb6ac8bb33f7bfff31..96a6bc167e0d4121b4628af891b4dd00f8a0d82f 100644 (file)
@@ -1,4 +1,4 @@
-/* Font buffer generated from source file: 'vg/src/fonts/vg_font_thin.png' */
+/* Font buffer generated from source file: 'src/fonts/vg_font_thin.png' */
 0xc3002800,0x8000020,0x8100000,0,0,0,0,0,
 0x81102800,0x1c000020,0x10080010,0x2,0x3c103c7c,0x407c387c,0x38380000,0,
 0x102822,0x22202020,0x20040010,0x2,0x46304208,0x48404404,0x44440000,0x38,
 0,0,0,0,0,0,0,0,
 0,0x40700,0,0,0,0,0,0,
 0xdc,0x87300,0,0,0,0,0,0,
-0xe8000090,0x104500,0,0,0,0,0,0,
-0xa80000dc,0x6c104800,0,0,0,0,0,0,
-0xe8002284,0xaa104200,0,0,0,0,0,0,
-0xae0042dc,0xaa0e4200,0,0,0,0,0,0,
-0x429e00,0xaa007e00,0,0,0,0,0,0,
-0xe0424070,0xee000000,0,0,0,0,0,0,
-0x407e2040,0x82000000,0,0,0,0,0,0,
+0xe8000090,0x1045fe,0x10380000,0,0,0,0,0,
+0xa80000dc,0x6c1048fe,0x387c0000,0,0,0,0,0,
+0xe8002284,0xaa1042fe,0x38fe0000,0,0,0,0,0,
+0xae0042dc,0xaa0e42fe,0x7cfe0000,0,0,0,0,0,
+0x429e00,0xaa007efe,0x7cfe0000,0,0,0,0,0,
+0xe0424070,0xee0000fe,0xfe7c0000,0,0,0,0,0,
+0x407e2040,0x820000fe,0xfe380000,0,0,0,0,0,
 0x40000070,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0x8,0,0,0,0,0,
 0,0,0x10,0x1e00000,0,0,0,0,
 0,0,0x20,0x7c600000,0,0,0,0,
-0,0,0x40,0x60a00000,0,0,0,0,
-0,0,0x80,0x61200000,0,0,0,0,
-0xc01b800,0,0x738080,0x62000000,0,0,0,0,
-0x12021000,0,0x924080,0x60400000,0,0,0,0,
-0x21021000,0x1040,0x924040,0x60400000,0,0,0,0,
-0x40819024,0xe0002042,0x6692403c,0x60400000,0,0,0,0,
-0x80400054,0x40004044,0x88924000,0x7fc00000,0,0,0,0,
-0x8041a054,0x40008f86,0x48924000,0x7fc00000,0,0,0,0,
-0xf3c22074,0x44044004,0x28f3c000,0,0,0,0,0,
-0x12022053,0x44042002,0xc6804000,0,0,0,0,0,
-0x12021800,0x7fc1000,0x804000,0,0,0,0,0,
+0,0,0x40,0x60a0000c,0x3f00000,0,0,0,
+0,0,0x80,0x612ffc1e,0x7f80000,0,0,0,
+0xc01b800,0,0x738080,0x620ffc1e,0xffc0000,0,0,0,
+0x12021000,0,0x924080,0x604ffc3f,0xffc0000,0,0,0,
+0x21021000,0x1040,0x924040,0x604ffc3f,0xffc0000,0,0,0,
+0x40819024,0xe0002042,0x6692403c,0x604ffc7f,0x8ffc0000,0,0,0,
+0x80400054,0x40004044,0x88924000,0x7fcffc7f,0x8ffc0000,0,0,0,
+0x8041a054,0x40008f86,0x48924000,0x7fcffc7f,0x8ffc0000,0,0,0,
+0xf3c22074,0x44044004,0x28f3c000,0xffcff,0xcffc0000,0,0,0,
+0x12022053,0x44042002,0xc6804000,0xffcff,0xc7f80000,0,0,0,
+0x12021800,0x7fc1000,0x804000,0xffcff,0xc3f00000,0,0,0,
 0x1e000000,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,
 0,0,0,0,0,0,0,0,