Skip to content

Commit

Permalink
fix clear order and handmade math safed
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed Dec 30, 2023
1 parent 2499d0d commit eca3dd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/examples/clear.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ void frame()
const g = pass_action.colors[0].clear_value.g + 0.01;
pass_action.colors[0].clear_value.g = g > 1.0 ? 0.0 : g;
sg.beginDefaultPass(pass_action, sapp.width(), sapp.height());
sg.commit();
sg.endPass();
sg.commit();
}

void cleanup()
Expand Down
9 changes: 6 additions & 3 deletions src/examples/cube.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct State
sg.Bindings bind;
sg.PassAction passAction;

static Mat4 view() @trusted
static Mat4 view()
{
return Mat4.lookAt(Vec3(0.0f, 1.5f, 6.0f), Vec3.zero(), Vec3.up());
}
Expand Down Expand Up @@ -102,6 +102,9 @@ void init()
state.passAction.colors[0].clear_value.a = 1;
}

sg.Range ranging(ref shd.VsParams params) @trusted{
return cast(sg.Range)&params;
}
void frame()
{
float dt = cast(float) app.frameDuration() * 60;
Expand All @@ -115,7 +118,7 @@ void frame()

sg.applyPipeline(state.pip);
sg.applyBindings(state.bind);
// sg.applyUniforms(sg.ShaderStage.Vs, shd.SLOT_VS_PARAMS, sg.asRange(&vsParams));
sg.applyUniforms(sg.ShaderStage.Vs, shd.SLOT_VS_PARAMS, ranging(vsParams));

sg.draw(0, 36, 1);

Expand Down Expand Up @@ -144,7 +147,7 @@ void main()
app.run(runner);
}

shd.VsParams computeVsParams(float rx, float ry) @trusted
shd.VsParams computeVsParams(float rx, float ry)
{
auto rxm = Mat4.rotate(rx, Vec3(1, 0, 0));
auto rym = Mat4.rotate(ry, Vec3(0, 1, 0));
Expand Down
2 changes: 2 additions & 0 deletions src/examples/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module handmade.math;

import std.math : PI, sqrt, sin, cos, tan, isClose;

@safe:

struct Vec2
{
float x, y;
Expand Down

0 comments on commit eca3dd5

Please sign in to comment.