summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/common/entry/entry_android.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/common/entry/entry_android.cpp')
-rw-r--r--3rdparty/bgfx/examples/common/entry/entry_android.cpp62
1 files changed, 34 insertions, 28 deletions
diff --git a/3rdparty/bgfx/examples/common/entry/entry_android.cpp b/3rdparty/bgfx/examples/common/entry/entry_android.cpp
index 644ed4aca4c..a99735b6df5 100644
--- a/3rdparty/bgfx/examples/common/entry/entry_android.cpp
+++ b/3rdparty/bgfx/examples/common/entry/entry_android.cpp
@@ -1,14 +1,12 @@
/*
- * Copyright 2011-2018 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"
#if ENTRY_CONFIG_USE_NATIVE && BX_PLATFORM_ANDROID
-#include <bgfx/platform.h>
-
#include <bx/thread.h>
#include <bx/file.h>
@@ -29,18 +27,6 @@ extern "C"
namespace entry
{
- ///
- inline void androidSetWindow(::ANativeWindow* _window)
- {
- bgfx::PlatformData pd;
- pd.ndt = NULL;
- pd.nwh = _window;
- pd.context = NULL;
- pd.backBuffer = NULL;
- pd.backBufferDS = NULL;
- bgfx::setPlatformData(pd);
- }
-
struct GamepadRemap
{
uint16_t m_keyCode;
@@ -108,18 +94,18 @@ namespace entry
virtual bool open(const bx::FilePath& _filePath, bx::Error* _err) override
{
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+ BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
if (NULL != m_file)
{
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_ALREADY_OPEN, "FileReader: File is already open.");
+ BX_ERROR_SET(_err, bx::kErrorReaderWriterAlreadyOpen, "FileReader: File is already open.");
return false;
}
- m_file = AAssetManager_open(m_assetManager, _filePath.get(), AASSET_MODE_RANDOM);
+ m_file = AAssetManager_open(m_assetManager, _filePath.getCPtr(), AASSET_MODE_RANDOM);
if (NULL == m_file)
{
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_OPEN, "FileReader: Failed to open file.");
+ BX_ERROR_SET(_err, bx::kErrorReaderWriterOpen, "FileReader: Failed to open file.");
return false;
}
@@ -139,22 +125,22 @@ namespace entry
virtual int64_t seek(int64_t _offset, bx::Whence::Enum _whence) override
{
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
+ BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
return AAsset_seek64(m_file, _offset, _whence);
}
virtual int32_t read(void* _data, int32_t _size, bx::Error* _err) override
{
- BX_CHECK(NULL != m_file, "Reader/Writer file is not open.");
- BX_CHECK(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
+ BX_ASSERT(NULL != m_file, "Reader/Writer file is not open.");
+ BX_ASSERT(NULL != _err, "Reader/Writer interface calling functions must handle errors.");
int32_t size = (int32_t)AAsset_read(m_file, _data, _size);
if (size != _size)
{
if (0 == AAsset_getRemainingLength(m_file) )
{
- BX_ERROR_SET(_err, BX_ERROR_READERWRITER_EOF, "FileReader: EOF.");
+ BX_ERROR_SET(_err, bx::kErrorReaderWriterEof, "FileReader: EOF.");
}
return size >= 0 ? size : 0;
@@ -197,8 +183,8 @@ namespace entry
, 0
);
- const char* const argv[1] = { "android.so" };
- m_mte.m_argc = 1;
+ static const char* const argv[] = { "android.so" };
+ m_mte.m_argc = BX_COUNTOF(argv);
m_mte.m_argv = argv;
while (0 == m_app->destroyRequested)
@@ -233,7 +219,6 @@ namespace entry
if (m_window != m_app->window)
{
m_window = m_app->window;
- androidSetWindow(m_window);
int32_t width = ANativeWindow_getWidth(m_window);
int32_t height = ANativeWindow_getHeight(m_window);
@@ -550,12 +535,33 @@ namespace entry
BX_UNUSED(_handle, _lock);
}
+ void* getNativeWindowHandle(WindowHandle _handle)
+ {
+ if (kDefaultWindowHandle.idx == _handle.idx)
+ {
+ return s_ctx.m_window;
+ }
+
+ return NULL;
+ }
+
+ void* getNativeDisplayHandle()
+ {
+ return NULL;
+ }
+
+ bgfx::NativeWindowHandleType::Enum getNativeWindowHandleType(WindowHandle _handle)
+ {
+ BX_UNUSED(_handle);
+ return bgfx::NativeWindowHandleType::Default;
+ }
+
int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData)
{
BX_UNUSED(_thread);
int32_t result = chdir("/sdcard/bgfx/examples/runtime");
- BX_CHECK(0 == result, "Failed to chdir to dir. android.permission.WRITE_EXTERNAL_STORAGE?", errno);
+ BX_ASSERT(0 == result, "Failed to chdir to dir. android.permission.WRITE_EXTERNAL_STORAGE?", errno);
MainThreadEntry* self = (MainThreadEntry*)_userData;
result = main(self->m_argc, self->m_argv);