"void main()"
"{"
"gl_Position = vec4( uPv * vec3( a_co, 1.0 ), 1.0 );"
- "aTexCoords = a_uv * 0.01388888888;"
+ "aTexCoords = a_uv * 0.0078125;"
"aColour = a_colour;"
"aWsp = a_co;"
// ===========================================================================================================
// Opengl
-int ui_glyph_override = 0;
-ui_px ui_glyph_spacing_x = 6;
-GLuint ui_glyph_texture = 0;
+static ui_px ui_glyph_spacing_x = 9;
+static GLuint ui_glyph_texture = 0;
ui_colourset ui_default_colours = {
.main = 0xff00ff00,
free( ctx->indices );
}
-static void ui_override_font( GLuint new_tex, ui_px space_x )
-{
- if( ui_glyph_texture )
- glDeleteTextures( 1, &ui_glyph_texture );
-
- ui_glyph_texture = new_tex;
- ui_glyph_override = 1;
- ui_glyph_spacing_x = space_x;
-}
-
static void ui_default_init(void)
{
// Load default font
- if( !ui_glyph_override )
- {
- u32 compressed[] = {
- #include "fonts/weiholmir.h"
- };
-
- u32 pixels = 0, total = 72*72, data = 0;
- u8 *image = malloc( total );
-
- while( pixels < total )
- {
- for( int b = 31; b >= 0; b-- )
- {
- image[ pixels ++ ] = (compressed[data] & (0x1 << b))? 0xff: 0x00;
-
- if( pixels >= total )
- {
- total = 0;
- break;
- }
- }
- data++;
- }
-
- glGenTextures( 1, &ui_glyph_texture );
- glBindTexture( GL_TEXTURE_2D, ui_glyph_texture );
-
- glTexImage2D( GL_TEXTURE_2D, 0, GL_R8, 72, 72, 0, GL_RED, GL_UNSIGNED_BYTE, image );
-
- vg_tex2d_clamp();
- vg_tex2d_nearest();
-
- free( image );
- }
+ u32 compressed[] = {
+ #include "vg/vg_pxfont.h"
+ };
+
+ u32 pixels = 0, total = 256*256, data = 0;
+ u8 *image = malloc( total );
+
+ while( pixels < total )
+ {
+ for( int b = 31; b >= 0; b-- )
+ {
+ image[ pixels ++ ] = (compressed[data] & (0x1 << b))? 0xff: 0x00;
+
+ if( pixels >= total )
+ {
+ total = 0;
+ break;
+ }
+ }
+ data++;
+ }
+
+ glGenTextures( 1, &ui_glyph_texture );
+ glBindTexture( GL_TEXTURE_2D, ui_glyph_texture );
+
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_R8, 256, 256, 0, GL_RED, GL_UNSIGNED_BYTE, image );
+
+ vg_tex2d_clamp();
+ vg_tex2d_nearest();
+
+ free( image );
// Setup OpenGL memory
SHADER_INIT( shader_ui );
static void ui_default_free(void)
{
- if( !ui_glyph_override )
- glDeleteTextures( 1, &ui_glyph_texture );
+ glDeleteTextures( 1, &ui_glyph_texture );
ui_context_free( &ui_global_ctx );
}
static struct ui_vert *ui_fill_rect( ui_ctx *ctx, ui_rect rect, u32 colour )
{
- return ui_fill_rect_uv( ctx, rect, colour, (ui_px[4]){ 4,124,4,124 } );
+ return ui_fill_rect_uv( ctx, rect, colour, (ui_px[4]){ 4,4, 4,4 } );
}
static void ui_text( ui_ctx *ctx, const char *str, ui_px scale )
text_cursor[0] = ctx->cursor[0];
text_cursor[1] = ctx->cursor[1];
- text_cursor[2] = 7*scale;
- text_cursor[3] = 7*scale;
+ text_cursor[2] = 8*scale;
+ text_cursor[3] = 14*scale;
u32 current_colour = 0x00ffffff;
{
if( c == '\n' )
{
- text_cursor[1] += 10*scale;
+ text_cursor[1] += 14*scale;
text_cursor[0] = ctx->cursor[0];
continue;
}
else if( c >= 33 && c <= 126 )
{
u8 glyph_base[2];
- u8 glyph_index = c - 32;
- glyph_base[0] = glyph_index%10;
- glyph_base[1] = (glyph_index-glyph_base[0])/10;
+ u8 glyph_index = c;
+ glyph_base[0] = glyph_index & 0xf;
+ glyph_base[1] = (glyph_index-glyph_base[0])>>4;
- glyph_base[0] *= 7;
- glyph_base[1] *= 7;
+ glyph_base[0] *= 8;
+ glyph_base[1] *= 8;
- ui_fill_rect_uv( ctx, text_cursor, current_colour, (ui_px[4]){glyph_base[0],glyph_base[1],glyph_base[0]+7,glyph_base[1]+7} );
+ ui_fill_rect_uv( ctx, text_cursor, current_colour, (ui_px[4]){glyph_base[0]+2,glyph_base[1]+1,glyph_base[0]+6,glyph_base[1]+8} );
}
else if( c == '\x1B' )
{
}
}
- text_cursor[0] += 6*scale;
+ text_cursor[0] += 9*scale;
}
}