mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Don't throw an exception on 0 width/height canvas, addresses #669
This commit is contained in:
parent
de833c3124
commit
d1766b252d
10
src/Window.c
10
src/Window.c
@ -3009,8 +3009,14 @@ static void RescaleXY(int srcX, int srcY, int* dstX, int* dstY) {
|
||||
double css_width, css_height;
|
||||
emscripten_get_element_css_size("#canvas", &css_width, &css_height);
|
||||
|
||||
*dstX = (int)(srcX * WindowInfo.Width / css_width);
|
||||
*dstY = (int)(srcY * WindowInfo.Height / css_height);
|
||||
if (css_width && css_height) {
|
||||
*dstX = (int)(srcX * WindowInfo.Width / css_width );
|
||||
*dstY = (int)(srcY * WindowInfo.Height / css_height);
|
||||
} else {
|
||||
/* If css width or height is 0, something is bogus */
|
||||
/* It's still better to avoid divsision by 0 anyways */
|
||||
*dstX = srcX; *dstY = srcY;
|
||||
}
|
||||
}
|
||||
|
||||
static EM_BOOL OnMouseMove(int type, const EmscriptenMouseEvent* ev, void* data) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user