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

Image width and height #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Image width and height #37

wants to merge 1 commit into from

Conversation

jkisor
Copy link
Contributor

@jkisor jkisor commented Feb 18, 2024

Previously in #30, image dimensions were hardcoded.

The async problem disappears if only worry about ID.

  • LoadTexture assigns an ID and returns it.
  • DrawTexture receives an ID, looks up loaded images, and uses data known about it locally to JS.

@AntonPieper
Copy link

This is a nice improvement!

This does indeed draw the correct image after some time, however in raylib, you have access to width and height on the C side as well through the Texture struct and the image draws correctly immediately (not after the first few frames). So the need for async does still exist, though not in the examples seen in zozlib.

@jkisor
Copy link
Contributor Author

jkisor commented Feb 18, 2024

@AntonPieper Regarding not drawing first few frames -- This is in line with how browser/canvas works. My mental sift around this problem is to remember we're implementing a raylib interface in the browser (not trying to trick a browser to work differently) Behaving like a browser feels okay.

You're correct about C potentially needing texture data -- that is still an open problem. Luckily the existing example doesn't need it.

Stepping stones... Small gain of not being hardcoded unblocks a few other texture based examples (which might also not need C-side texture data yet (other than id).

@AntonPieper
Copy link

I agree and think it is okay to not show an image in this case, however JS "game engines" like phaser do show images on the first game frame by having a preload function (and potentially showing a customizable loading scene).

This is a step in the right direction and I think this is mergeable by itself because of the width/height handling👍

P.S.: smart idea with the usage of dataset btw for storing the IDs in the images

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