Skip to content

textures_logo_raylib example - #30

Merged
rexim merged 5 commits into
tsoding:mainfrom
jkisor:textures_logo_raylib
Feb 17, 2024
Merged

rexim merged 5 commits into
tsoding:mainfrom
jkisor:textures_logo_raylib

Conversation

@jkisor

@jkisor jkisor commented Feb 14, 2024

Copy link
Copy Markdown
Contributor

Implements:

  • LoadTexture
  • DrawTexture

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

@jkisor jkisor Feb 14, 2024 •

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown

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).

Comment thread raylib.js
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
Copy Markdown
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

rexim commented Feb 17, 2024

Copy link
Copy Markdown
Member

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