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

No way to execute code after a resource has been loaded. #68

Closed
cat-haines opened this issue Feb 12, 2016 · 3 comments
Closed

No way to execute code after a resource has been loaded. #68

cat-haines opened this issue Feb 12, 2016 · 3 comments

Comments

@cat-haines
Copy link
Contributor

The following snippet demonstrates the problem:

(function() {
  var rocky = Rocky.bindCanvas(document.getElementById("pebble"));
  rocky.export_global_c_symbols();

  var bmp = rocky.gbitmap_create('http://github.com/apple-touch-icon-57x57.png');

  rocky.update_proc = function(ctx, bounds) {
    graphics_draw_bitmap_in_rect(ctx, bmp, [43, 55, 57, 57]);
  };

  rocky.mark_dirty();
})();

We call mark_dirty after setting up our app to initialize the view, however because the image hasn't loaded yet, it's not displayed. Because we're not calling rocky.mark_dirty() on a regular basis, the image is never redrawn.

@HBehrens
Copy link
Contributor

Does bmp.onload = function(){rocky.mark_dirty();} ? I think we should finally implement the more user-friendly solution and always call .mark_dirty() after a resource was loaded.

@cat-haines
Copy link
Contributor Author

I didn't realize created bitmaps had an onload property - this works great. We should make sure this is properly documented.

I'm not sure we would want to always call .mark_dirty() after loading a resource.. you might load a series of resources at app start, and not use them until later.

@cat-haines
Copy link
Contributor Author

Closed and replaced with #69

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

No branches or pull requests

2 participants