From ba55084ad8c88e14da1d980ed367792ae5ed5d8d Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Thu, 18 Apr 2013 23:32:12 -0700 Subject: [PATCH] Android wip. --- README.md | 28 ++++++++++++++++++---------- examples/common/dbg.cpp | 19 ++++++++----------- examples/common/entry_android.cpp | 1 + include/bgfxplatform.h | 4 ++-- src/bgfx.cpp | 8 ++++---- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index b4b638273..3384ddf04 100644 --- a/README.md +++ b/README.md @@ -53,14 +53,29 @@ Windows users download GNU make utility from: cd bgfx make -After calling make, .build/projects/* directory will be generated. All +After calling `make`, .build/projects/* directory will be generated. All intermediate files generated by compiler will be inside .build directory structure. Deleting .build directory at any time is safe. +### Prerequisites for Android + +Download AndroidNDK from: +[https://developer.android.com/tools/sdk/ndk/index.html](https://developer.android.com/tools/sdk/ndk/index.html) + + setx ANDROID_NDK_ROOT + setx ANDROID_NDK_ARM \toolchains\arm-linux-androideabi-4.7\prebuilt\windows-x86_64 + ### Prerequisites for Linux sudo apt-get install libgl1-mesa-dev +### Prerequisites for Native Client (Pepper 22) on Windows + +Download Native Client SDK from: +[https://developers.google.com/native-client/sdk/download](https://developers.google.com/native-client/sdk/download) + + setx NACL \toolchain\win_x86_newlib + ### Prerequisites for Windows When building on Windows, you have to set DXSDK_DIR environment variable to @@ -77,13 +92,6 @@ directory link to directory without spaces in the path. mklink /D c:\dxsdk setx DXSDK_DIR c:\dxsdk -### Prerequisites for Native Client (Pepper 22) on Windows - -Download Native Client SDK from: -[https://developers.google.com/native-client/sdk/download](https://developers.google.com/native-client/sdk/download) - - setx NACL \toolchain\win_x86_newlib - ### Building Visual Studio 2008 command line: @@ -102,9 +110,9 @@ Other platforms: make -Configuration is `-<32/64>`. For example: +Configuration is `-[32/64]`. For example: - linux-release32, nacl-debug64, android-release32, etc. + linux-release32, nacl-debug64, android-release, etc. Examples -------- diff --git a/examples/common/dbg.cpp b/examples/common/dbg.cpp index 2f03092df..6e671e28b 100755 --- a/examples/common/dbg.cpp +++ b/examples/common/dbg.cpp @@ -13,20 +13,17 @@ #include "dbg.h" #include -#if BX_COMPILER_MSVC -# define snprintf _snprintf -#endif // BX_COMPILER_MSVC - -#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 -extern "C" -{ - __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str); -} +#if BX_PLATFORM_ANDROID +# include +#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 +extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str); #endif // BX_PLATFORM_WINDOWS void dbgOutput(const char* _out) { -#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 +#if BX_PLATFORM_ANDROID + __android_log_write(ANDROID_LOG_DEBUG, "", _out); +#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 OutputDebugStringA(_out); #elif BX_PLATFORM_NACL || BX_PLATFORM_LINUX || BX_PLATFORM_OSX fputs(_out, stderr); @@ -80,7 +77,7 @@ void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...) uint32_t asciiPos = 0; for (uint32_t ii = 0; ii < _size; ++ii) { - snprintf(&hex[hexPos], sizeof(hex)-hexPos, "%02x ", data[asciiPos]); + bx::snprintf(&hex[hexPos], sizeof(hex)-hexPos, "%02x ", data[asciiPos]); hexPos += 3; ascii[asciiPos] = isprint(data[asciiPos]) ? data[asciiPos] : '.'; diff --git a/examples/common/entry_android.cpp b/examples/common/entry_android.cpp index 54dd41f37..3fd258b76 100644 --- a/examples/common/entry_android.cpp +++ b/examples/common/entry_android.cpp @@ -222,6 +222,7 @@ extern int _main_(int _argc, char** _argv); extern "C" void android_main(android_app* _app) { + DBG("entry_android"); using namespace entry; app_dummy(); s_ctx.run(_app); diff --git a/include/bgfxplatform.h b/include/bgfxplatform.h index 1df77171e..331faa9e4 100755 --- a/include/bgfxplatform.h +++ b/include/bgfxplatform.h @@ -44,7 +44,7 @@ namespace bgfx namespace bgfx { - void osxSetNSWindow(void* _nsWindow); + void osxSetNSWindow(void* _window); } // namespace bgfx #elif BX_PLATFORM_WINDOWS @@ -52,7 +52,7 @@ namespace bgfx namespace bgfx { - void winSetHwnd(::HWND _hwnd); + void winSetHwnd(::HWND _window); } // namespace bgfx #endif // BX_PLATFORM_ diff --git a/src/bgfx.cpp b/src/bgfx.cpp index f5ba8e448..3bef2583d 100755 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -42,16 +42,16 @@ namespace bgfx #elif BX_PLATFORM_OSX void* g_bgfxNSWindow = NULL; - void osxSetNSWindow(void* _nsWindow) + void osxSetNSWindow(void* _window) { - g_bgfxNSWindow = _nsWindow; + g_bgfxNSWindow = _window; } #elif BX_PLATFORM_WINDOWS ::HWND g_bgfxHwnd = NULL; - void winSetHwnd(::HWND _hwnd) + void winSetHwnd(::HWND _window) { - g_bgfxHwnd = _hwnd; + g_bgfxHwnd = _window; } #endif // BX_PLATFORM_*