Skip to content

Commit

Permalink
customresolve-sapp sample: ui tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Nov 16, 2024
1 parent 0487356 commit fe2d2e3
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions sapp/customresolve-sapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ static struct {
sg_sampler smp; // a common non-filtering sampler
} state;

const fs_params_t default_weights = {
.weight0 = 0.25f,
.weight1 = 0.25f,
.weight2 = 0.25f,
.weight3 = 0.25f,
};

static void draw_ui(void);

static void init(void) {
Expand Down Expand Up @@ -119,12 +126,7 @@ static void init(void) {
.images[IMG_texms] = state.msaa.img,
.samplers[SMP_smp] = state.smp,
};
state.resolve.fs_params = (fs_params_t){
.weight0 = 0.25f,
.weight1 = 0.25f,
.weight2 = 0.25f,
.weight3 = 0.25f,
};
state.resolve.fs_params = default_weights;

// swapchain-render-pass objects
state.display.pip = sg_make_pipeline(&(sg_pipeline_desc){
Expand Down Expand Up @@ -185,20 +187,15 @@ static void draw_ui(void) {
igEndMainMenuBar();
}
sgimgui_draw(&state.ui.sgimgui);
igSetNextWindowPos((ImVec2){10, 30}, ImGuiCond_Once, (ImVec2){0,0});
igSetNextWindowSize((ImVec2){100, 50}, ImGuiCond_Once);
igSetNextWindowPos((ImVec2){10, 20}, ImGuiCond_Once, (ImVec2){0,0});
if (igBegin("Sample Weights", 0, ImGuiWindowFlags_NoDecoration|ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoBackground)) {
igSliderFloat("Weight 0", &state.resolve.fs_params.weight0, 0.0f, 1.0f, "%.2f", 0);
igSliderFloat("Weight 1", &state.resolve.fs_params.weight1, 0.0f, 1.0f, "%.2f", 0);
igSliderFloat("Weight 2", &state.resolve.fs_params.weight2, 0.0f, 1.0f, "%.2f", 0);
igSliderFloat("Weight 3", &state.resolve.fs_params.weight3, 0.0f, 1.0f, "%.2f", 0);
igText("Sample Weights:");
igSliderFloat("0", &state.resolve.fs_params.weight0, 0.0f, 1.0f, "%.2f", 0);
igSliderFloat("1", &state.resolve.fs_params.weight1, 0.0f, 1.0f, "%.2f", 0);
igSliderFloat("2", &state.resolve.fs_params.weight2, 0.0f, 1.0f, "%.2f", 0);
igSliderFloat("3", &state.resolve.fs_params.weight3, 0.0f, 1.0f, "%.2f", 0);
if (igButton("Reset", (ImVec2){0,0})) {
state.resolve.fs_params = (fs_params_t){
.weight0 = 0.25,
.weight1 = 0.25,
.weight2 = 0.25,
.weight3 = 0.25,
};
state.resolve.fs_params = default_weights;
}
}
igEnd();
Expand Down

0 comments on commit fe2d2e3

Please sign in to comment.