mirror of
https://github.com/Ed94/VEFontCache-Odin.git
synced 2025-08-06 06:52:44 -07:00
fixing some normalized space calculation issues
I need to review the convention I'm using for the "view" or at least how I interpret these coordinate spaces so its inutitive for the interface. At the end of the day, the draw_list should be in normalized space, however how it gets digested to that state needs to be better documented or made more explicit in its transformation from the usual user calls.
This commit is contained in:
@@ -154,8 +154,7 @@ draw_text_string_pos_norm :: proc( content : string, font : Font_ID, size : f32,
|
|||||||
{
|
{
|
||||||
color_norm := normalize_rgba8(color)
|
color_norm := normalize_rgba8(color)
|
||||||
def := demo_ctx.font_ids[ font.label ]
|
def := demo_ctx.font_ids[ font.label ]
|
||||||
|
size := size > 2.0 ? size : f32(def.default_size)
|
||||||
size := size > 2.0 ? size : f32(def.default_size)
|
|
||||||
|
|
||||||
ve.draw_text_normalized_space( & demo_ctx.ve_ctx,
|
ve.draw_text_normalized_space( & demo_ctx.ve_ctx,
|
||||||
def.ve_id,
|
def.ve_id,
|
||||||
@@ -163,7 +162,7 @@ draw_text_string_pos_norm :: proc( content : string, font : Font_ID, size : f32,
|
|||||||
color_norm,
|
color_norm,
|
||||||
demo_ctx.screen_size,
|
demo_ctx.screen_size,
|
||||||
pos,
|
pos,
|
||||||
scale * 1 / demo_ctx.screen_size,
|
scale,
|
||||||
1.0,
|
1.0,
|
||||||
content
|
content
|
||||||
)
|
)
|
||||||
@@ -257,7 +256,18 @@ init :: proc "c" ()
|
|||||||
case .DUMMY: fmt.println(">> using dummy backend")
|
case .DUMMY: fmt.println(">> using dummy backend")
|
||||||
}
|
}
|
||||||
|
|
||||||
ve.startup( & demo_ctx.ve_ctx, .STB_TrueType, allocator = context.allocator )
|
glyph_draw_opts := ve.Init_Glyph_Draw_Params_Default
|
||||||
|
glyph_draw_opts.snap_glyph_height = false
|
||||||
|
|
||||||
|
shaper_opts := ve.Init_Shaper_Params_Default
|
||||||
|
shaper_opts.snap_glyph_position = false
|
||||||
|
|
||||||
|
ve.startup( & demo_ctx.ve_ctx, .STB_TrueType, allocator = context.allocator,
|
||||||
|
glyph_draw_params = glyph_draw_opts,
|
||||||
|
shaper_params = shaper_opts,
|
||||||
|
px_scalar = 1.5,
|
||||||
|
alpha_sharpen = 0.1,
|
||||||
|
)
|
||||||
ve_sokol.setup_gfx_objects( & demo_ctx.render_ctx, & demo_ctx.ve_ctx, vert_cap = 1024 * 1024, index_cap = 1024 * 1024 )
|
ve_sokol.setup_gfx_objects( & demo_ctx.render_ctx, & demo_ctx.ve_ctx, vert_cap = 1024 * 1024, index_cap = 1024 * 1024 )
|
||||||
|
|
||||||
error : mem.Allocator_Error
|
error : mem.Allocator_Error
|
||||||
|
@@ -686,7 +686,7 @@ draw_text_shape_normalized_space :: #force_inline proc( ctx : ^Context,
|
|||||||
font : Font_ID,
|
font : Font_ID,
|
||||||
px_size : f32,
|
px_size : f32,
|
||||||
colour : RGBAN,
|
colour : RGBAN,
|
||||||
view : Vec2,
|
view : Vec2, // Screen
|
||||||
position : Vec2,
|
position : Vec2,
|
||||||
scale : Vec2,
|
scale : Vec2,
|
||||||
zoom : f32, // TODO(Ed): Implement zoom support
|
zoom : f32, // TODO(Ed): Implement zoom support
|
||||||
@@ -702,10 +702,13 @@ draw_text_shape_normalized_space :: #force_inline proc( ctx : ^Context,
|
|||||||
entry := ctx.entries[ font ]
|
entry := ctx.entries[ font ]
|
||||||
|
|
||||||
adjusted_colour := colour
|
adjusted_colour := colour
|
||||||
adjusted_colour.a = 1.0 + ctx.alpha_sharpen
|
adjusted_colour.a += ctx.alpha_sharpen
|
||||||
|
|
||||||
|
view_norm := 1 / view
|
||||||
|
scale_norm := scale * view_norm
|
||||||
|
|
||||||
target_px_size := px_size * ctx.px_scalar
|
target_px_size := px_size * ctx.px_scalar
|
||||||
target_scale := scale * (1 / ctx.px_scalar)
|
target_scale := scale_norm * (1 / ctx.px_scalar)
|
||||||
target_font_scale := parser_scale( entry.parser_info, target_px_size )
|
target_font_scale := parser_scale( entry.parser_info, target_px_size )
|
||||||
|
|
||||||
ctx.cursor_pos = generate_shape_draw_list( & ctx.draw_list, shape, & ctx.atlas, & ctx.glyph_buffer,
|
ctx.cursor_pos = generate_shape_draw_list( & ctx.draw_list, shape, & ctx.atlas, & ctx.glyph_buffer,
|
||||||
@@ -743,12 +746,15 @@ draw_text_normalized_space :: proc( ctx : ^Context,
|
|||||||
|
|
||||||
adjusted_position := get_snapped_position( position, view )
|
adjusted_position := get_snapped_position( position, view )
|
||||||
|
|
||||||
adjusted_colour := colour
|
adjusted_colour := colour
|
||||||
adjusted_colour.a = 1.0 + ctx.alpha_sharpen
|
adjusted_colour.a += ctx.alpha_sharpen
|
||||||
|
|
||||||
|
view_norm := 1 / view
|
||||||
|
scale_norm := scale * view_norm
|
||||||
|
|
||||||
// Does nothing when px_scalar is 1.0
|
// Does nothing when px_scalar is 1.0
|
||||||
target_px_size := px_size * ctx.px_scalar
|
target_px_size := px_size * ctx.px_scalar
|
||||||
target_scale := scale * (1 / ctx.px_scalar)
|
target_scale := scale_norm * (1 / ctx.px_scalar)
|
||||||
target_font_scale := parser_scale( entry.parser_info, target_px_size )
|
target_font_scale := parser_scale( entry.parser_info, target_px_size )
|
||||||
|
|
||||||
shape := shaper_shape_text_cached( text_utf8, & ctx.shaper_ctx, & ctx.shape_cache, ctx.atlas, vec2(ctx.glyph_buffer.size),
|
shape := shaper_shape_text_cached( text_utf8, & ctx.shaper_ctx, & ctx.shape_cache, ctx.atlas, vec2(ctx.glyph_buffer.size),
|
||||||
|
Reference in New Issue
Block a user