summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_html5.cpp
diff options
context:
space:
mode:
author R. Belmont <rb6502@users.noreply.github.com>2023-01-04 23:29:18 -0500
committer GitHub <noreply@github.com>2023-01-04 23:29:18 -0500
commit94b1e168b2b97b48b81f7a8f64406b0a6f64184e (patch)
treef57362a0fa01bfe8f0ad75a447c4c9e10bc15756 /3rdparty/bgfx/examples/common/entry/entry_html5.cpp
parent5581eaa50a42256242f32569f59ce10d70ddd8c2 (diff)
Revert "Update BGFX, BX and BIMG (#10750)" (#10787)
This reverts commit 5581eaa50a42256242f32569f59ce10d70ddd8c2 due to link failure on macOS.
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, 21 insertions, 27 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_html5.cpp b/3rdparty/bgfx/examples/common/entry/entry_html5.cpp
index 884a563b783..6482942ff51 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-2022 Branimir Karadzic. All rights reserved.
- * License: https://github.com/bkaradzic/bgfx/blob/master/LICENSE
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
+ * License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
#include "entry_p.h"
@@ -28,6 +28,8 @@ extern "C" void entry_emscripten_yield()
namespace entry
{
+ static WindowHandle s_defaultWindow = { 0 };
+
static uint8_t s_translateKey[256];
struct Context
@@ -100,6 +102,8 @@ 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) );
@@ -124,6 +128,11 @@ 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;
}
@@ -156,7 +165,7 @@ namespace entry
case EMSCRIPTEN_EVENT_MOUSEMOVE:
s_ctx.m_mx = _event->targetX;
s_ctx.m_my = _event->targetY;
- s_ctx.m_eventQueue.postMouseEvent(kDefaultWindowHandle, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
+ s_ctx.m_eventQueue.postMouseEvent(s_defaultWindow, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
return true;
case EMSCRIPTEN_EVENT_MOUSEDOWN:
@@ -169,7 +178,7 @@ namespace entry
? MouseButton::Middle : MouseButton::Left)
;
s_ctx.m_eventQueue.postMouseEvent(
- kDefaultWindowHandle
+ s_defaultWindow
, s_ctx.m_mx
, s_ctx.m_my
, s_ctx.m_scroll
@@ -196,7 +205,7 @@ namespace entry
s_ctx.m_scrollf += _event->deltaY;
s_ctx.m_scroll = (int32_t)s_ctx.m_scrollf;
- s_ctx.m_eventQueue.postMouseEvent(kDefaultWindowHandle, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
+ s_ctx.m_eventQueue.postMouseEvent(s_defaultWindow, s_ctx.m_mx, s_ctx.m_my, s_ctx.m_scroll);
return true;
}
}
@@ -296,14 +305,14 @@ namespace entry
else
{
enum { ShiftMask = Modifier::LeftShift|Modifier::RightShift };
- s_ctx.m_eventQueue.postCharEvent(kDefaultWindowHandle, 1, pressedChar);
- s_ctx.m_eventQueue.postKeyEvent(kDefaultWindowHandle, key, modifiers, true);
+ s_ctx.m_eventQueue.postCharEvent(s_defaultWindow, 1, pressedChar);
+ s_ctx.m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, true);
return true;
}
break;
case EMSCRIPTEN_EVENT_KEYUP:
- s_ctx.m_eventQueue.postKeyEvent(kDefaultWindowHandle, key, modifiers, false);
+ s_ctx.m_eventQueue.postKeyEvent(s_defaultWindow, key, modifiers, false);
return true;
}
}
@@ -333,19 +342,19 @@ namespace entry
switch (_eventType)
{
case EMSCRIPTEN_EVENT_BLUR:
- s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::DidSuspend);
+ s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::DidSuspend);
return true;
case EMSCRIPTEN_EVENT_FOCUS:
- s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::DidResume);
+ s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::DidResume);
return true;
case EMSCRIPTEN_EVENT_FOCUSIN:
- s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::WillResume);
+ s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::WillResume);
return true;
case EMSCRIPTEN_EVENT_FOCUSOUT:
- s_ctx.m_eventQueue.postSuspendEvent(kDefaultWindowHandle, Suspend::WillSuspend);
+ s_ctx.m_eventQueue.postSuspendEvent(s_defaultWindow, Suspend::WillSuspend);
return true;
}
}
@@ -412,21 +421,6 @@ 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)