Skip to content

Commit

Permalink
Added $extra_draw_info
Browse files Browse the repository at this point in the history
extra_draw_info annotates draw calls; predominately when they are drawingthe background. This doesn't currently change how they are drawn, but could in the future.
Changed draw_rect_translucent_on_the_right to work via this mechanism.
  • Loading branch information
onelivesleft authored and focus-editor committed Oct 1, 2024
1 parent 2337837 commit 80a36af
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 58 deletions.
10 changes: 7 additions & 3 deletions modules/Simp/shader.jai
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Shader :: struct {
using platform: Shader_Platform;
}

Extra_Draw_Info :: struct {
is_background := false; // This doesn't currently have any effect on drawing, but could be extended in future.
is_translucent_on_the_right := false;
}

set_projection :: () {
t := context.simp.texture_render_target;
if t {
Expand All @@ -14,7 +19,7 @@ set_projection :: () {
}
}

set_shader_for_color :: (enable_blend := false) {
set_shader_for_color :: (enable_blend := false, $extra_draw_info := Extra_Draw_Info.{}) {
CheckInit();
shader := ifx enable_blend then *shader_color_with_blend else *shader_color;
if state.current_shader != shader {
Expand Down Expand Up @@ -42,15 +47,14 @@ set_shader_for_images :: (texture: *Texture) {
immediate_set_texture(texture);
}

set_shader_for_rects :: () {
set_shader_for_rects :: ($extra_draw_info := Extra_Draw_Info.{}) {
CheckInit();
if state.current_shader != *shader_rounded_rect {
immediate_set_shader(*shader_rounded_rect);
set_projection();
}
}


set_shader_for_gradient :: (rect: Vector4, mode: u8, value: float) {
CheckInit();
immediate_set_shader(*shader_gradient);
Expand Down
Loading

0 comments on commit 80a36af

Please sign in to comment.