summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_html5.cpp
diff options
context:
space:
mode:
author Miodrag Milanović <mmicko@gmail.com>2023-01-05 15:32:40 +0100
committer GitHub <noreply@github.com>2023-01-05 09:32:40 -0500
commit812e6094f47bb8d1da5a6b421aa4c724cf2035c0 (patch)
tree0f5bab2fe9393d1f629e9bf63e76cecca74ec0c9 /3rdparty/bgfx/examples/common/entry/entry_html5.cpp
parent4a1b41854bba8fc2567906b88bab8ca81e75d187 (diff)
Update BGFX, BX and BIMG (#10789)
* Update to bgfx a93a714632b79b5ddbf5c86ac323fa9b76ed3433 Co-authored-by: Бранимир Караџић <branimirkaradzic@gmail.com>
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_html5.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_html5.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_html5.cpp b/3rdparty/bgfx/examples/common/entry/entry_html5.cpp
index 6482942ff51..884a563b783 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_html5.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_html5.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
+ * Copyright 2011-2022 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
*/
#include "entry_p.h"
@@ -28,8 +28,6 @@ extern "C" void entry_emscripten_yield()
namespace entry
{
- static WindowHandle s_defaultWindow = { 0 };
-
static uint8_t s_translateKey[256];
struct Context
@@ -102,8 +100,6 @@ namespace entry
static const char* canvas = "#canvas";
EMSCRIPTEN_CHECK(emscripten_set_mousedown_callback(canvas, this, true, mouseCb) );
-
- EMSCRIPTEN_CHECK(emscripten_set_mousedown_callback(canvas, this, true, mouseCb) );
EMSCRIPTEN_CHECK(emscripten_set_mouseup_callback(canvas, this, true, mouseCb) );
EMSCRIPTEN_CHECK(emscripten_set_mousemove_callback(canvas, this, true, mouseCb) );
@@ -128,11 +124,6 @@ namespace entry
EMSCRIPTEN_CHECK(emscripten_set_focusin_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) );
EMSCRIPTEN_CHECK(emscripten_set_focusout_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, this, true, focusCb) );
- bgfx::PlatformData pd;
- bx::memSet(&pd, 0, sizeof(pd) );
- pd.nwh = (void*)canvas;
- bgfx::setPlatformData(pd);
-
int32_t result = main(_argc, _argv);
return result;
}
@@ -165,7 +156,7 @@ namespace entry
case EMSCRIPTEN_EVENT_MOUSEMOVE:
s_ctx.m_mx = _event->targetX;
s_ctx.m_my = _event->targetY;
- s_ctx.m_eventQueue.postMouseEvent(s_defaultWindow, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
+ s_ctx.m_eventQueue.postMouseEvent(kDefaultWindowHandle, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
return true;
case EMSCRIPTEN_EVENT_MOUSEDOWN:
@@ -178,7 +169,7 @@ namespace entry
? MouseButton::Middle : MouseButton::Left)
;
s_ctx.m_eventQueue.postMouseEvent(
- s_defaultWindow
+ kDefaultWindowHandle
, s_ctx.m_mx
, s_ctx.m_my
, s_ctx.m_scroll
@@ -205,7 +196,7 @@ namespace entry
s_ctx.m_scrollf += _event->deltaY;
s_ctx.m_scroll = (int32_t)s_ctx.m_scrollf;
- s_ctx.m_eventQueue.postMouseEvent(s_defaultWindow, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
+ s_ctx.m_eventQueue.postMouseEvent(kDefaultWindowHandle, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
return true;
}
}
@@ -305,14 +296,14 @@ namespace entry
else
{
enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift };
- s_ctx.m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar);
- s_ctx.m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
+ s_ctx.m_eventQueue.postCharEvent(kDefaultWindowHandle, 1, pressedChar);
+ s_ctx.m_eventQueue.postKeyEvent(kDefaultWindowHandle, key, modifiers, true);
return true;
}
break;
case EMSCRIPTEN_EVENT_KEYUP:
- s_ctx.m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, false);
+ s_ctx.m_eventQueue.postKeyEvent(kDefaultWindowHandle, key, modifiers, false);
return true;
}
}
@@ -342,19 +333,19 @@ namespace entry
switch (_eventType)
{
case EMSCRIPTEN_EVENT_BLUR:
- s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::DidSuspend);
+ s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::DidSuspend);
return true;
case EMSCRIPTEN_EVENT_FOCUS:
- s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::DidResume);
+ s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::DidResume);
return true;
case EMSCRIPTEN_EVENT_FOCUSIN:
- s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::WillResume);
+ s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::WillResume);
return true;
case EMSCRIPTEN_EVENT_FOCUSOUT:
- s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::WillSuspend);
+ s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::WillSuspend);
return true;
}
}
@@ -421,6 +412,21 @@ namespace entry
{
BX_UNUSED(_handle, _lock);
}
+
+ void* getNativeWindowHandle(WindowHandle _handle)
+ {
+ if (kDefaultWindowHandle.idx == _handle.idx)
+ {
+ return (void*)"#canvas";
+ }
+
+ return NULL;
+ }
+
+ void* getNativeDisplayHandle()
+ {
+ return NULL;
+ }
}
int main(int _argc, const char* const* _argv)