Skip to content

[WIP] sokol-spritebatch sample#92

Open
stuartdadams wants to merge 19 commits into
floooh:masterfrom
stuartdadams:spritebatch
Open

[WIP] sokol-spritebatch sample#92
stuartdadams wants to merge 19 commits into
floooh:masterfrom
stuartdadams:spritebatch

Conversation

@stuartdadams

@stuartdadams stuartdadams commented Jul 24, 2021

Copy link
Copy Markdown

Creating a sample to demonstrate sokol-spritebatch.

Sample video

@floooh floooh left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things I stumbled over on macOS

Comment thread sapp/CMakeLists.txt Outdated
Comment thread sapp/CMakeLists.txt Outdated
Comment thread sapp/spritebatch-sapp.c Outdated
Comment thread sapp/spritebatch-sapp.c Outdated
Comment thread sapp/spritebatch-sapp.glsl Outdated
@stuartdadams

Copy link
Copy Markdown
Author

Tried testing it on sapp-webgl2-wasm-ninja-release to no avail, boo! Everything else works but my sample is a black page with no content.

@floooh

floooh commented Jul 29, 2021

Copy link
Copy Markdown
Owner

Here are two patch files with my changes to make emscripen work (using sokol_fetch.h instead of stbi_load(). The second wraps stm_round_to_common_refresh_rate() around stm_laptime() to help with microstutter.

But careful, some changes may collide with your latest fixes (like the flip_vert_y in the shader). (nevermind, I was seeing the new "SBATCH_FLIP" and thought that's related to the OpenGL version rendering upside down)

patches.zip

@floooh

floooh commented Aug 9, 2021

Copy link
Copy Markdown
Owner

I'm seeing an error and a couple of warnings on macOS with Xcode, the error is in GridVania.h, which is too big for the github review tool:

The error is:

GridVania.h:20395:26: Static declaration of 'LDtkGridVania' follows non-static declaration

...the first 'non-static declaration' is here (line 314):

extern const LDtkProject LDtkGridVania;

...and the second declaration is here (line 20395):

static const LDtkProject LDtkGridVania = { 0x132A3FFF, LDtkLevels, 19, LDtkTilesets, 2, 256, 256, LDtkWorldLayout_GridVania };

Replacing the extern with static makes it work.

For the warnings I'll add regular review comments :)

@floooh

floooh commented Aug 9, 2021

Copy link
Copy Markdown
Owner

Doh, what a confusing UI for code reviews :) I forgot to "approve" the previews review comments, so the new ones are above (it's 4 "signedness" warnings, and one formatting string warning in the sdtx_printf() call).

There's also one unused function warning in sokol_spritebatch.h (_sbatch_matmul), I'll add a review comment there.

Comment thread sapp/spritebatch-sapp.c Outdated
Comment thread sapp/spritebatch-sapp-crt.glsl
.position = {
.x = xOffset + (float)tile->px.x,
.y = yOffset + (float)tile->px.y },
.flags = tile->f,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Implicit conversion changes signedness" (.flags = tile-f)

.position = {
.x = xOffset + (float)tile->px.x,
.y = yOffset + (float)tile->px.y },
.flags = tile->f,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Implicit conversion changes signedness" (.flags = tile-f)

.position = {
.x = xOffset + (float)tile->px.x,
.y = yOffset + (float)tile->px.y },
.flags = tile->f,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Implicit conversion changes signedness" (.flags = tile-f)

void handle_key_press(size_t index) {
const size_t level_index = index - 1;
if (LDtkGridVania.levels[state.selected_level].neighboursLength >= index) {
state.selected_level = LDtkGridVania.levels[state.selected_level].neighbours[level_index].levelIndex;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Implicit conversion changes signedness" (state.selected_level = ...)

});

sdtx_pos(screen_space.x / 8.0f, screen_space.y / 8.0f);
sdtx_printf(level->identifier.data);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Format string is not a string literal (potentially insecure)"

Replace with: sdtx_printf("%s", level->identifier.data);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants