Hi all,

there are two Emscripten functions that are getting deprecated. In
#include <emscripten.h>, there are

void emscripten_set_canvas_size(int width, int height);
void emscripten_get_canvas_size(int *width, int *height, int *isFullscreen);

which should not be relied on in the future. The replacing functions are

EMSCRIPTEN_RESULT emscripten_set_canvas_element_size(const char
*target, int width, int height);
EMSCRIPTEN_RESULT emscripten_get_canvas_element_size(const char
*target, int *width, int *height);
EMSCRIPTEN_RESULT
emscripten_get_fullscreen_status(EmscriptenFullscreenChangeEvent
*fullscreenStatus);

that can be found in #include <emscripten/html5.h>

Instead of calling

   emscripten_set_canvas_size(myWidth, myHeight);

call

   EMSCRIPTEN_RESULT r = emscripten_set_canvas_element_size("#canvas",
myWidth, myHeight);
   if (r != EMSCRIPTEN_RESULT_SUCCESS) /* handle error */

and instead of

   int w, h, fs;
   emscripten_get_canvas_size(&w, &h, &fs);

call

   int w, h, fs;
   EMSCRIPTEN_RESULT r = emscripten_get_canvas_element_size("#canvas", &w, &h);
   if (r != EMSCRIPTEN_RESULT_SUCCESS) /* handle error */
   EmscriptenFullscreenChangeEvent e;
   r = emscripten_get_fullscreen_status(&e);
   if (r != EMSCRIPTEN_RESULT_SUCCESS) /* handle error */
   fs = e.isFullscreen;


This change expands C applications to be able to specify which canvas
they want to get the size from, instead of being hardcoded to access
the singleton "Module['canvas']" object. Also, the new functions will
be readily multithreading aware, which, due to a few overloaded
features, the old functions are not. For detailed information, see
https://github.com/kripken/emscripten/pull/5481.

The old functions will still be present for quite some time, though
unfortunately cannot function properly in multithreaded applications
when called from a pthread and OffscreenCanvas is being used.

Cheers,
   Jukka

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to