parent
f7496654ae
commit
a9d4fed205
3 changed files with 35 additions and 18 deletions
|
@ -149,7 +149,7 @@ pub const WindowState = struct {
|
|||
}
|
||||
|
||||
// TODO: this should take a utf8 graphme instead
|
||||
pub fn generateGlyph(state: *WindowState, font: Font, codepoint: u21) u32 {
|
||||
pub fn generateGlyph(state: *WindowState, font: Font, codepoint: u21, right_half: bool) u32 {
|
||||
// for now we'll just use 1 texture and leverage the entire thing
|
||||
const texture_cell_count: XY(u16) = getD3d11TextureMaxCellCount(font.cell_size);
|
||||
const texture_cell_count_total: u32 =
|
||||
|
@ -187,12 +187,15 @@ pub const WindowState = struct {
|
|||
switch (glyph_index_cache.reserve(
|
||||
global.glyph_cache_arena.allocator(),
|
||||
codepoint,
|
||||
right_half,
|
||||
) catch |e| oom(e)) {
|
||||
.newly_reserved => |reserved| {
|
||||
// var render_success = false;
|
||||
// defer if (!render_success) state.glyph_index_cache.remove(reserved.index);
|
||||
const pos: XY(u16) = cellPosFromIndex(reserved.index, texture_cell_count.x);
|
||||
const coord = coordFromCellPos(font.cell_size, pos);
|
||||
var staging_size = font.cell_size;
|
||||
staging_size.x = if (right_half) staging_size.x * 2 else staging_size.x;
|
||||
const staging = global.staging_texture.update(font.cell_size);
|
||||
var utf8_buf: [7]u8 = undefined;
|
||||
const utf8_len: u3 = std.unicode.utf8Encode(codepoint, &utf8_buf) catch |e| std.debug.panic(
|
||||
|
@ -204,10 +207,10 @@ pub const WindowState = struct {
|
|||
utf8_buf[0..utf8_len],
|
||||
);
|
||||
const box: win32.D3D11_BOX = .{
|
||||
.left = 0,
|
||||
.left = if (right_half) font.cell_size.x else 0,
|
||||
.top = 0,
|
||||
.front = 0,
|
||||
.right = font.cell_size.x,
|
||||
.right = if (right_half) font.cell_size.x * 2 else font.cell_size.x,
|
||||
.bottom = font.cell_size.y,
|
||||
.back = 1,
|
||||
};
|
||||
|
@ -289,7 +292,7 @@ pub fn paint(
|
|||
}
|
||||
|
||||
const copy_col_count: u16 = @min(col_count, shader_col_count);
|
||||
const blank_space_glyph_index = state.generateGlyph(font, ' ');
|
||||
const blank_space_glyph_index = state.generateGlyph(font, ' ', false);
|
||||
|
||||
const cell_count: u32 = @as(u32, shader_col_count) * @as(u32, shader_row_count);
|
||||
state.shader_cells.updateCount(cell_count);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue