fix font alpha channel
This commit is contained in:
parent
bca29c537c
commit
2e60e4c5b8
16
TODO
16
TODO
@ -1,32 +1,38 @@
|
||||
# TODOs, semi-random sorting
|
||||
|
||||
[x] Implement glyph draw command
|
||||
[x] Implement div.view and scrollbars
|
||||
[ ] Port font system from C to C3 (rewrite1)
|
||||
[x] Port font system from C to C3 (rewrite1)
|
||||
[ ] Update ARCHITECTURE.md
|
||||
[ ] Write a README.md
|
||||
[ ] Use an arena allocator for cache
|
||||
[ ] Do not redraw if there was no update (no layout and no draw)
|
||||
[ ] Better handling of the active and focused widgets, try
|
||||
to maintain focus until mouse release (fix scroll bars)
|
||||
to maintain focus until mouse release (fix scroll bars)
|
||||
|
||||
## Commands
|
||||
|
||||
[x] rect commads should have:
|
||||
* border width
|
||||
* border radius
|
||||
_ border width
|
||||
_ border radius
|
||||
[x] add a command to update an atlas
|
||||
|
||||
## Atlases
|
||||
|
||||
[ ] Add an interface to create, destroy, update and get atlases based on their ids
|
||||
[ ] Implement multiple font atlases
|
||||
|
||||
## Fonts
|
||||
[ ] Fix the missing alpha channel
|
||||
|
||||
[x] Fix the missing alpha channel
|
||||
[x] Fix the alignment
|
||||
|
||||
## Raylib
|
||||
|
||||
[ ] Implement type (Rect, Color, Point) conversion functions between rl:: and ugui::
|
||||
[x] Implement pixel radius rounding for border radius
|
||||
|
||||
## Widgets
|
||||
|
||||
[ ] Dynamic text box to implement an fps counter
|
||||
[ ] Button with label
|
||||
|
26
src/main.c3
26
src/main.c3
@ -23,6 +23,28 @@ fn void Times.print_stats(×)
|
||||
io::printfn("min=%s, max=%s, avg=%s", min, max, avg);
|
||||
}
|
||||
|
||||
const ZString FONT_FS = `
|
||||
#version 330
|
||||
|
||||
// Input vertex attributes (from vertex shader)
|
||||
in vec2 fragTexCoord;
|
||||
in vec4 fragColor;
|
||||
|
||||
// Input uniform values
|
||||
uniform sampler2D texture0;
|
||||
uniform vec4 colDiffuse;
|
||||
|
||||
// Output fragment color
|
||||
out vec4 finalColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 alpha = texture(texture0, fragTexCoord);
|
||||
finalColor = colDiffuse*fragColor;
|
||||
finalColor.a *= alpha.r;
|
||||
}
|
||||
`;
|
||||
|
||||
fn int main(String[] args)
|
||||
{
|
||||
ugui::Ctx ui;
|
||||
@ -42,6 +64,7 @@ fn int main(String[] args)
|
||||
time::Clock clock;
|
||||
Times ui_times;
|
||||
Times draw_times;
|
||||
rl::Shader font_shader = rl::load_shader_from_memory(null, FONT_FS);
|
||||
|
||||
// Main loop
|
||||
while (!rl::window_should_close()) {
|
||||
@ -173,8 +196,9 @@ fn int main(String[] args)
|
||||
.x = cmd.sprite.rect.x,
|
||||
.y = cmd.sprite.rect.y,
|
||||
};
|
||||
|
||||
rl::begin_shader_mode(font_shader);
|
||||
rl::draw_texture_rec(font_texture, source, position, rl::WHITE);
|
||||
rl::end_shader_mode();
|
||||
case ugui::CmdType.CMD_SCISSOR:
|
||||
if (cmd.scissor.rect.w == 0 && cmd.scissor.rect.h == 0) {
|
||||
rl::end_scissor_mode();
|
||||
|
@ -61,7 +61,7 @@ struct Font {
|
||||
bool should_update; // should send update_atlas command, resets at frame_end()
|
||||
}
|
||||
|
||||
fn void! Font.load(&font, String name, String path, uint height, float scale)
|
||||
fn void! Font.load(&font, String name, ZString path, uint height, float scale)
|
||||
{
|
||||
font.table.new_init(capacity: FONT_CACHED);
|
||||
font.id = name.hash();
|
||||
@ -161,7 +161,7 @@ fn void Font.free(&font)
|
||||
schrift::freefont(font.sft.font);
|
||||
}
|
||||
|
||||
fn void! Ctx.load_font(&ctx, String name, String path, uint height, float scale = 1.0)
|
||||
fn void! Ctx.load_font(&ctx, String name, ZString path, uint height, float scale = 1.0)
|
||||
{
|
||||
return ctx.font.load(name, path, height, scale);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user