Skip to content

Commit

Permalink
pico_gfx: scene graph demo is working again
Browse files Browse the repository at this point in the history
  • Loading branch information
empyreanx committed Jul 3, 2024
1 parent 3b24de8 commit 95df1a5
Showing 1 changed file with 16 additions and 43 deletions.
59 changes: 16 additions & 43 deletions examples_pico_gfx/scenegraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,7 @@ void node_render(node_t* node, double alpha)
// Linearly interpolate between the last and current world transforms
// by the amount alpha in [0,1]
pt2 render = pt2_lerp(&last, &world, alpha);
//pt2 mvp = pt2_mult(&app.proj, &render);

/*pt2 mvp = app.proj;
float mat[16] =
{
mvp.t00, mvp.t10, 0.0f, 0.0f,
mvp.t01, mvp.t11, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
mvp.tx, mvp.ty, 0.0f, 1.0f,
};
memcpy(&app.block.u_mvp, mat, sizeof(mat));*/
pt2 mvp = pt2_mult(&app.proj, &render);

int w = app.screen_w;
int h = app.screen_h;
Expand All @@ -218,10 +206,10 @@ void node_render(node_t* node, double alpha)
{
.u_mvp =
{
2.0f / w, 0.0f, 0.0f, 0.0f,
0.0f, -2.0/ h, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f,
mvp.t00, mvp.t10, 0.0f, 0.0f,
mvp.t01, mvp.t11, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
mvp.tx, mvp.ty, 0.0f, 1.0f,
}
};

Expand Down Expand Up @@ -420,27 +408,8 @@ int main(int argc, char *argv[])

pg_init_uniform_block(app.shader, PG_STAGE_VS, "vs_block");

/*app.proj = (pt2)
{
2.0f / w, 0.0f, -1.0f,
0.0f, -2.0f / h, 1.0f
};
vs_block_t block =
{
.u_mvp =
{
2.0f / w, 0.0f, 0.0f, 0.0f,
0.0f, -2.0/ h, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f,
-1.0f, 1.0f, 0.0f, 1.0f,
}
};
pg_init_uniform_block(app.shader, PG_STAGE_VS, "vs_block");
pg_set_uniform_block(app.shader, "vs_block", &block);*/
app.proj = pt2_make(2.0f / w, 0.0f, -1.0f,
0.0f, -2.0f / h, 1.0f);

pg_pipeline_t* pipeline = pg_create_pipeline(app.ctx, app.shader,
&(pg_pipeline_opts_t)
Expand All @@ -459,7 +428,13 @@ int main(int argc, char *argv[])
.offset = offsetof(vertex_t, uv) },
},
},
.element_size = sizeof(vertex_t)
.element_size = sizeof(vertex_t),
.blend_enabled = true,
.blend =
{
.color_src = PG_SRC_ALPHA,
.color_dst = PG_ONE_MINUS_SRC_ALPHA
}
});

pg_set_pipeline(app.ctx, pipeline);
Expand All @@ -478,7 +453,7 @@ int main(int argc, char *argv[])

while (!done)
{
/*// Calculate delta
// Calculate delta
now = pt_now();
delta = pt_to_sec(now - last);
last = now;
Expand Down Expand Up @@ -507,7 +482,7 @@ int main(int argc, char *argv[])
pt2_translate(&sg->pivot_node->local, pv2_scale(scene_center, -1.0f));
pt2_rotate(&sg->pivot_node->local, -(PM_PI / 8.0f) * FIXED_STEP);
pt2_translate(&sg->pivot_node->local, scene_center);
}*/
}

SDL_Event event;
while (SDL_PollEvent(&event))
Expand Down Expand Up @@ -536,8 +511,6 @@ int main(int argc, char *argv[])

pg_begin_pass(app.ctx, NULL, true);
node_render(sg->root_node, accumulator / FIXED_STEP);
//pg_bind_texture(app.shader, "u_tex", sg->ship_sprite->tex);
//pg_draw_buffers(app.ctx, 6, 1, (const pg_buffer_t*[]){ sg->ship_sprite->buf , NULL });
pg_end_pass(app.ctx);
pg_flush(app.ctx);

Expand Down

0 comments on commit 95df1a5

Please sign in to comment.