diff options
author | 2023-01-05 05:12:10 +0100 | |
---|---|---|
committer | 2023-01-04 23:12:10 -0500 | |
commit | 5581eaa50a42256242f32569f59ce10d70ddd8c2 (patch) | |
tree | 0d79e41b381ebf6d50ab5b7e20c0993b7328b5b6 /3rdparty/bgfx/src/glcontext_html5.cpp | |
parent | 34c37d4f5415f886ec3ae462b008cebbf5fa22f9 (diff) |
Update BGFX, BX and BIMG (#10750)
* Update to bgfx a93a714632b79b5ddbf5c86ac323fa9b76ed3433
Co-authored-by: Бранимир Караџић <branimirkaradzic@gmail.com>
Diffstat (limited to '3rdparty/bgfx/src/glcontext_html5.cpp')
-rw-r--r-- | 3rdparty/bgfx/src/glcontext_html5.cpp | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/3rdparty/bgfx/src/glcontext_html5.cpp b/3rdparty/bgfx/src/glcontext_html5.cpp index a884ab7b35f..016b7c189b3 100644 --- a/3rdparty/bgfx/src/glcontext_html5.cpp +++ b/3rdparty/bgfx/src/glcontext_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 "bgfx_p.h" @@ -63,7 +63,7 @@ namespace bgfx { namespace gl char* m_canvas; }; - void GlContext::create(uint32_t _width, uint32_t _height) + void GlContext::create(uint32_t _width, uint32_t _height, uint32_t /*_flags*/) { // assert? if (m_primary != NULL) @@ -71,7 +71,23 @@ namespace bgfx { namespace gl const char* canvas = (const char*) g_platformData.nwh; - m_primary = createSwapChain((void*)canvas); + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context = (EMSCRIPTEN_WEBGL_CONTEXT_HANDLE) g_platformData.context; + if (context > 0) + { + if (emscripten_webgl_get_context_attributes(context, &s_attrs) >= 0) + { + import(s_attrs.majorVersion); + m_primary = BX_NEW(g_allocator, SwapChainGL)(context, canvas); + } + else + { + BX_TRACE("Invalid WebGL context. (Canvas handle: '%s', context handle: %d)", canvas, context); + } + } + else + { + m_primary = createSwapChain((void*)canvas); + } if (0 != _width && 0 != _height) @@ -121,7 +137,7 @@ namespace bgfx { namespace gl s_attrs.minorVersion = 0; const char* canvas = (const char*) _nwh; - int error = 0; + int32_t error = 0; for (int version = 2; version >= 1; --version) { @@ -138,10 +154,13 @@ namespace bgfx { namespace gl return swapChain; } - error = (int) context; + + error = (int32_t)context; } BX_TRACE("Failed to create WebGL context. (Canvas handle: '%s', last attempt error %d)", canvas, error); + BX_UNUSED(error); + return NULL; } |