Skip to content

Commit

Permalink
add rudimentary drag
Browse files Browse the repository at this point in the history
  • Loading branch information
slowriot committed Dec 8, 2024
1 parent 9e4d014 commit a6d7b12
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
5 changes: 3 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class game_manager {
render::webgpu_renderer renderer{logger}; // WebGPU rendering system
gui::gui_renderer gui{logger}; // GUI top level

vec2f mouse_pos_rel{}; // relative mouse position

void loop_main();

public:
Expand All @@ -40,8 +42,7 @@ game_manager::game_manager() {
void game_manager::loop_main() {
/// Main pseudo-loop
gui.draw();
vec2f mouse_pos_rel;
// TODO: populate from screen coords
mouse_pos_rel += vec2f{ImGui::GetMouseDragDelta()} * 0.00001f * vec2f{-1.0f, 1.0f};
renderer.draw(mouse_pos_rel);
}

Expand Down
3 changes: 1 addition & 2 deletions render/shaders/default.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ struct vertex_output {

struct uniform_struct {
interactive_input: vec2f,
// TODO: use this
};

@group(0) @binding(0) var<uniform> uniforms: uniform_struct;
Expand Down Expand Up @@ -46,7 +45,7 @@ fn mandelbrot(c: vec2f) -> mandelbrot_out {
fn vs_main(in: vertex_input) -> vertex_output {
var out: vertex_output;
out.position = vec4f(in.position, 0.0, 1.0);
out.uv = in.uv;
out.uv = in.uv + uniforms.interactive_input;
return out;
}

Expand Down
8 changes: 4 additions & 4 deletions render/shaders/default.wgsl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace render::shaders {

inline constexpr char const *default_wgsl{R"890c9c6d52412f30(struct vertex_input {
inline constexpr char const *default_wgsl{R"bdb11fea3583576b(struct vertex_input {
@location(0) position: vec2f,
@location(1) uv: vec2f,
};
Expand All @@ -29,7 +29,7 @@ fn mandelbrot(c: vec2f) -> mandelbrot_out {
z.x * z.x - z.y * z.y,
2.0 * z.x * z.y
) + c;
if(dot(z, z) > 4096.0) {
if(dot(z, z) > 128.0) {
out.unbounded = f32(i) - log2(log2(dot(z, z)));
return out;
}
Expand All @@ -43,7 +43,7 @@ fn mandelbrot(c: vec2f) -> mandelbrot_out {
fn vs_main(in: vertex_input) -> vertex_output {
var out: vertex_output;
out.position = vec4f(in.position, 0.0, 1.0);
out.uv = in.uv;
out.uv = in.uv + uniforms.interactive_input;
return out;
}
@fragment
Expand All @@ -60,6 +60,6 @@ fn fs_main(in: vertex_output) -> @location(0) vec4f {
);
return vec4f(color, 1.0);
}
)890c9c6d52412f30"};
)bdb11fea3583576b"};

} // namespace render::shaders

0 comments on commit a6d7b12

Please sign in to comment.