Fix failure at runtime with latest emscripten

This commit is contained in:
UnknownShadow200 2020-06-05 18:32:25 +10:00
parent 3a0354be8f
commit 29a719d68b

View File

@ -2973,7 +2973,7 @@ void Window_FreeFramebuffer(Bitmap* bmp) {
static cc_bool keyboardOpen; static cc_bool keyboardOpen;
static void RefreshWindowBounds(void) { static void RefreshWindowBounds(void) {
emscripten_get_canvas_element_size(NULL, &WindowInfo.Width, &WindowInfo.Height); emscripten_get_canvas_element_size("#canvas", &WindowInfo.Width, &WindowInfo.Height);
} }
static void CorrectPointerFocus(void) { static void CorrectPointerFocus(void) {
@ -3007,7 +3007,7 @@ static EM_BOOL OnMouseButton(int type, const EmscriptenMouseEvent* ev, void* dat
/* input coordinates are CSS pixels, remap to internal pixels */ /* input coordinates are CSS pixels, remap to internal pixels */
static void RescaleXY(int srcX, int srcY, int* dstX, int* dstY) { static void RescaleXY(int srcX, int srcY, int* dstX, int* dstY) {
double css_width, css_height; double css_width, css_height;
emscripten_get_element_css_size(NULL, &css_width, &css_height); emscripten_get_element_css_size("#canvas", &css_width, &css_height);
*dstX = (int)(srcX * WindowInfo.Width / css_width); *dstX = (int)(srcX * WindowInfo.Width / css_width);
*dstY = (int)(srcY * WindowInfo.Height / css_height); *dstY = (int)(srcY * WindowInfo.Height / css_height);
@ -3340,7 +3340,7 @@ cc_result Window_EnterFullscreen(void) {
cc_result Window_ExitFullscreen(void) { return emscripten_exit_fullscreen(); } cc_result Window_ExitFullscreen(void) { return emscripten_exit_fullscreen(); }
void Window_SetSize(int width, int height) { void Window_SetSize(int width, int height) {
emscripten_set_canvas_element_size(NULL, width, height); emscripten_set_canvas_element_size("#canvas", width, height);
RefreshWindowBounds(); RefreshWindowBounds();
Event_RaiseVoid(&WindowEvents.Resized); Event_RaiseVoid(&WindowEvents.Resized);
} }
@ -3439,7 +3439,7 @@ void Window_CloseKeyboard(void) {
void Window_EnableRawMouse(void) { void Window_EnableRawMouse(void) {
RegrabMouse(); RegrabMouse();
emscripten_request_pointerlock(NULL, true); emscripten_request_pointerlock("#canvas", true);
Input_RawMode = true; Input_RawMode = true;
} }
void Window_UpdateRawMouse(void) { } void Window_UpdateRawMouse(void) { }
@ -4428,7 +4428,7 @@ void GLContext_Init(void) {
attribs.stencil = false; attribs.stencil = false;
attribs.antialias = false; attribs.antialias = false;
ctx_handle = emscripten_webgl_create_context(NULL, &attribs); ctx_handle = emscripten_webgl_create_context("#canvas", &attribs);
emscripten_webgl_make_context_current(ctx_handle); emscripten_webgl_make_context_current(ctx_handle);
emscripten_set_webglcontextlost_callback("#canvas", NULL, 0, GLContext_OnLost); emscripten_set_webglcontextlost_callback("#canvas", NULL, 0, GLContext_OnLost);
} }