Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textures_logo_raylib example #30

Merged
merged 5 commits into from
Feb 17, 2024
Merged

Conversation

jkisor
Copy link
Contributor

@jkisor jkisor commented Feb 14, 2024

Implements:

  • LoadTexture
  • DrawTexture

@jkisor jkisor force-pushed the textures_logo_raylib branch from 8e03136 to bb2e77d Compare February 14, 2024 05:27
Comment on lines +250 to +251
result[1] = 256; // width
result[2] = 256; // height
Copy link
Contributor Author

@jkisor jkisor Feb 14, 2024

Choose a reason for hiding this comment

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

It's possible to add an event listener load that provides the true width and height. I couldn't quite get it to work. I think due to async. Any tips?

Choose a reason for hiding this comment

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

async does not work unless you use asyncify (see #25 and #26). You sadly can't write to the result_ptr when the load callback finishes in the general case, because the result_ptr lives on the stack and might already have different data on it.

You could add the images to RaylibJs in a preload step (as an argument to start, or the constructor) from JavaScript (like emscripten --preload-file).

DrawTexture(texture_ptr, posX, posY, color_ptr) {
const buffer = this.wasm.instance.exports.memory.buffer;
const [id, width, height, mipmaps, format] = new Uint32Array(buffer, texture_ptr, 5);
// const tint = getColorFromMemory(buffer, color_ptr);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no tinting yet

@rexim
Copy link
Member

rexim commented Feb 17, 2024

LGTM! Thank you!

@rexim rexim merged commit 95693a9 into tsoding:main Feb 17, 2024
@jkisor jkisor mentioned this pull request Feb 18, 2024
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.

3 participants