diff --git a/android-project/AndroidManifest.xml b/android-project/AndroidManifest.xml index ebe49fb89..a14d0d91d 100644 --- a/android-project/AndroidManifest.xml +++ b/android-project/AndroidManifest.xml @@ -5,7 +5,10 @@ android:versionName="1.0"> + android:label="@string/app_name" + android:screenOrientation="landscape" + android:theme="@android:style/Theme.NoTitleBar.Fullscreen" + > diff --git a/android-project/compile.sh b/android-project/compile.sh new file mode 100755 index 000000000..cfa1ed8ec --- /dev/null +++ b/android-project/compile.sh @@ -0,0 +1,8 @@ +#!/bin/sh +cd $(dirname "$0") +export NDK_PROJECT_PATH=$(dirname "$0") +ndk-build -j4 +rm -rf ./bin +ant debug +adb install -r bin/EEPPApp-debug.apk +ndk-gdb --force --start diff --git a/android-project/jni/Android.mk b/android-project/jni/Android.mk index 447def997..fa54da165 100644 --- a/android-project/jni/Android.mk +++ b/android-project/jni/Android.mk @@ -15,7 +15,7 @@ MY_C_FLAGS := -DANDROID \ $(EE_GLES_VERSION) \ -DEE_NO_SNDFILE -MY_LDLIBS := -llog -landroid -lEGL $(EE_GLES_LINK) -lm +MY_LDLIBS := -llog -landroid -lEGL $(EE_GLES_LINK) -lm -lz include $(call all-subdir-makefiles) @@ -62,7 +62,7 @@ LOCAL_SRC_FILES := $(foreach F, $(CODE_SRCS), $(addprefix $(dir $(F)),$(notdir $ LOCAL_STATIC_LIBRARIES := sdl-1.3 chipmunk freetype openal -include $(BUILD_SHARED_LIBRARY) +include $(BUILD_STATIC_LIBRARY) #*************** EEPP *************** #*************** CHIPMUNK *************** @@ -227,7 +227,7 @@ CORE_SRCS := \ LOCAL_SRC_FILES := $(foreach F, $(CORE_SRCS), $(addprefix $(dir $(F)),$(notdir $(wildcard $(LOCAL_PATH)/$(F))))) -LOCAL_SHARED_LIBRARIES := eepp +LOCAL_STATIC_LIBRARIES := eepp include $(BUILD_SHARED_LIBRARY) #************ empty_window ************ @@ -253,7 +253,7 @@ LOCAL_C_INCLUDES := $(MY_C_INCLUDES) LOCAL_SRC_FILES := $(foreach F, $(CORE_SRCS), $(addprefix $(dir $(F)),$(notdir $(wildcard $(LOCAL_PATH)/$(F))))) -LOCAL_SHARED_LIBRARIES := eepp +LOCAL_STATIC_LIBRARIES := eepp include $(BUILD_SHARED_LIBRARY) #************ BnB ************ diff --git a/android-project/jni/Application.mk b/android-project/jni/Application.mk index ecc041f84..52f7506f8 100644 --- a/android-project/jni/Application.mk +++ b/android-project/jni/Application.mk @@ -35,4 +35,4 @@ APP_STL := gnustl_static APP_CFLAGS := -DDEBUG APP_PLATFORM := android-10 -APP_MODULES := main +APP_MODULES := bnb diff --git a/android-project/src/org/libsdl/app/SDLActivity.java b/android-project/src/org/libsdl/app/SDLActivity.java index 6b384756c..839e56ba7 100644 --- a/android-project/src/org/libsdl/app/SDLActivity.java +++ b/android-project/src/org/libsdl/app/SDLActivity.java @@ -34,8 +34,9 @@ public class SDLActivity extends Activity { // Load the .so static { - System.loadLibrary("eepp"); - System.loadLibrary("main"); + //System.loadLibrary("eepp"); + System.loadLibrary("bnb"); + //System.loadLibrary("main"); } // Setup diff --git a/src/base.hpp b/src/base.hpp index d2aecf1a1..b9d2f4560 100644 --- a/src/base.hpp +++ b/src/base.hpp @@ -198,6 +198,15 @@ #define eeSAFE_DELETE_ARRAY(p) { if(p) { eeDeleteArray(p); (p)=NULL; } } #define eeINDEX_NOT_FOUND 0xFFFFFFFF +#if EE_PLATFORM == EE_PLATFORM_ANDROID +#include +#define ANDROID_LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, "eepp", __VA_ARGS__) +#define ANDROID_LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , "eepp", __VA_ARGS__) +#define ANDROID_LOGI(...) __android_log_print(ANDROID_LOG_INFO , "eepp", __VA_ARGS__) +#define ANDROID_LOGW(...) __android_log_print(ANDROID_LOG_WARN , "eepp", __VA_ARGS__) +#define ANDROID_LOGE(...) __android_log_print(ANDROID_LOG_ERROR , "eepp", __VA_ARGS__) +#endif + namespace EE { #if 1 == EE_USE_DOUBLES #define EE_SIZE_OF_FLOAT 8 diff --git a/src/base/utf.inl b/src/base/utf.inl index 82e222581..fe721e489 100644 --- a/src/base/utf.inl +++ b/src/base/utf.inl @@ -572,10 +572,13 @@ Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale) return static_cast(character); #else - // Get the facet of the locale which deals with character conversion + #if EE_PLATFORM != EE_PLATFORM_ANDROID const std::ctype& facet = std::use_facet< std::ctype >(locale); - + #else + const std::ctype& facet = std::use_facet< std::ctype >(locale); + #endif + // Use the facet to convert each character of the input string return static_cast(facet.widen(input)); @@ -615,9 +618,12 @@ Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const st return output; #else - // Get the facet of the locale which deals with character conversion + #if EE_PLATFORM != EE_PLATFORM_ANDROID const std::ctype& facet = std::use_facet< std::ctype >(locale); + #else + const std::ctype& facet = std::use_facet< std::ctype >(locale); + #endif // Use the facet to convert each character of the input string *output++ = facet.narrow(static_cast(codepoint), replacement); diff --git a/src/graphics/cfont.cpp b/src/graphics/cfont.cpp index 8c973da36..b6e306432 100644 --- a/src/graphics/cfont.cpp +++ b/src/graphics/cfont.cpp @@ -323,7 +323,7 @@ void cFont::SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, con cTextureFactory::instance()->Bind( mTexId ); cTextureFactory::instance()->SetPreBlendFunc( Effect ); - if ( !Cached && ( Text.size() != mRenderCoords.size() / 4 || Angle != 0.f || Scale != 1.f || FontHAlignGet( Flags ) == FONT_DRAW_CENTER || FontHAlignGet( Flags ) == FONT_DRAW_RIGHT ) ) { + if ( !Cached && ( Text.size() != mRenderCoords.size() / EE_QUAD_VERTEX || Angle != 0.f || Scale != 1.f || FontHAlignGet( Flags ) == FONT_DRAW_CENTER || FontHAlignGet( Flags ) == FONT_DRAW_RIGHT ) ) { SetText( Text ); } diff --git a/src/graphics/ctextureloader.cpp b/src/graphics/ctextureloader.cpp index 8d084b02e..147b79714 100644 --- a/src/graphics/ctextureloader.cpp +++ b/src/graphics/ctextureloader.cpp @@ -170,7 +170,7 @@ void cTextureLoader::LoadFromPath() { } if ( NULL == mPixels ) - cLog::instance()->Write( stbi_failure_reason() ); + cLog::instance()->Write( "Filed to load: " + mFilepath + " Reason: " + std::string( stbi_failure_reason() ) ); } else if ( cPackManager::instance()->FallbackToPacks() ) { mPack = cPackManager::instance()->Exists( mFilepath ); diff --git a/src/helper/android/sdl-1.3/src/core/android/SDL_android.cpp b/src/helper/android/sdl-1.3/src/core/android/SDL_android.cpp index 5291b0558..4c5d4d006 100644 --- a/src/helper/android/sdl-1.3/src/core/android/SDL_android.cpp +++ b/src/helper/android/sdl-1.3/src/core/android/SDL_android.cpp @@ -67,10 +67,12 @@ static float fLastAccelerometer[3]; *******************************************************************************/ // Library init +/* extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved) { return JNI_VERSION_1_4; } +* */ // Called before SDL_main() to initialize JNI bindings extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls) diff --git a/src/system/clog.cpp b/src/system/clog.cpp index c9e86cb39..81c7a438f 100755 --- a/src/system/clog.cpp +++ b/src/system/clog.cpp @@ -41,15 +41,23 @@ void cLog::Write( const std::string& Text, const bool& newLine ) { if ( newLine ) { mData += '\n'; } - + if ( mConsoleOutput ) { + #if EE_PLATFORM == EE_PLATFORM_ANDROID + if ( newLine ) { + ANDROID_LOGI( ( Text + std::string( "\n" ) ).c_str() ); + } else { + ANDROID_LOGI( Text.c_str() ); + } + #else if ( newLine ) { std::cout << Text << std::endl; } else { std::cout << Text; } + #endif } - + if ( mLiveWrite ) { openfs(); @@ -96,7 +104,11 @@ void cLog::Writef( const char* format, ... ) { mData += tstr + '\n'; if ( mConsoleOutput ) { + #if EE_PLATFORM != EE_PLATFORM_ANDROID std::cout << tstr << std::endl; + #else + ANDROID_LOGI( ( tstr + std::string( "\n" ) ).c_str() ); + #endif } if ( mLiveWrite ) { diff --git a/src/system/tsingleton.hpp b/src/system/tsingleton.hpp index 32946abd1..1fd758c0b 100755 --- a/src/system/tsingleton.hpp +++ b/src/system/tsingleton.hpp @@ -1,7 +1,8 @@ #ifndef EE_SYSTEMSINGLETON_H #define EE_SYSTEMSINGLETON_H - -#include "../base.hpp" + +#include "../base.hpp" +#include namespace EE { namespace System { @@ -13,9 +14,10 @@ class tSingleton { public: /** Get the singleton pointer */ static T* CreateSingleton() { - if (ms_singleton == 0) + if (ms_singleton == 0) { ms_singleton = eeNew( T, () ); - + } + return ms_singleton; } diff --git a/src/test/empty_window/empty_window.cpp b/src/test/empty_window/empty_window.cpp index 435b66f68..9a1372bee 100644 --- a/src/test/empty_window/empty_window.cpp +++ b/src/test/empty_window/empty_window.cpp @@ -5,33 +5,33 @@ EE_MAIN_FUNC int main (int argc, char * argv []) { // Create a new window cWindow * win = cEngine::instance()->CreateWindow( WindowSettings( 800, 600, 32, WindowStyle::Default, "", "eepp - Empty Window" ), ContextSettings( ) ); - + // Set window background color win->BackColor( eeColor( 50, 50, 50 ) ); - + // Check if created if ( win->Created() ) { // Get input pointer cInput * imp = win->GetInput(); - + eeFloat ang = 0; - + // Application loop while ( win->Running() ) { // Update the input imp->Update(); - + // Check if ESCAPE key is pressed if ( imp->IsKeyDown( KEY_ESCAPE ) ) { // Close the window win->Close(); } - + ang += cEngine::instance()->Elapsed() * 0.01; - + // Create an instance of the primitive renderer cPrimitives p; @@ -46,7 +46,7 @@ EE_MAIN_FUNC int main (int argc, char * argv []) // Draw a circle p.DrawCircle( win->GetWidth() / 2, win->GetHeight() / 2, 200 ); - + // Draw frame win->Display(); @@ -54,12 +54,12 @@ EE_MAIN_FUNC int main (int argc, char * argv []) eeSleep( 10 ); } } - + // Destroy the engine instance. Destroys all the windows and engine singletons. cEngine::DestroySingleton(); - + // If was compiled in debug mode it will print the memory manager report EE::MemoryManager::LogResults(); - + return 0; } diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index d6f8f8168..79c2c95a6 100755 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -9,6 +9,13 @@ #elif EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_ANDROID #include #include + #if EE_PLATFORM != EE_PLATFORM_ANDROID + #include + #else + #include + #define statvfs statfs + #define fstatvfs fstatfs + #endif #elif EE_PLATFORM == EE_PLATFORM_HAIKU #include #include @@ -16,6 +23,8 @@ #include #endif + + #if EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_BSD #include #endif @@ -570,7 +579,7 @@ std::vector FilesGetInPath( const std::string& path ) { #endif } -Uint32 FileSize( const std::string& Filepath ) { +Uint64 FileSize( const std::string& Filepath ) { struct stat st; int res = stat( Filepath.c_str(), &st ); @@ -758,7 +767,7 @@ eeInt GetCPUCount() { GetSystemInfo(&info); nprocs = (eeInt) info.dwNumberOfProcessors; - #elif EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_SOLARIS + #elif EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_SOLARIS || EE_PLATFORM == EE_PLATFORM_ANDROID nprocs = sysconf(_SC_NPROCESSORS_ONLN); #elif EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_BSD int mib[2]; @@ -914,4 +923,21 @@ void SetFlagValue( Uint32 * Key, Uint32 Val, Uint32 BitWrite ) { } } +Int64 GetDiskFreeSpace(const std::string& path) { +#if defined( EE_PLATFORM_POSIX ) + struct statvfs data; + statvfs(path.c_str(), &data); + return (Int64)data.f_bsize * (Int64)data.f_bfree; +#elif EE_PLATFORM == EE_PLATFORM_WIN + Int64 AvailableBytes; + Int64 TotalBytes; + Int64 FreeBytes; + GetDiskFreeSpaceEx(path.c_str(),(PULARGE_INTEGER) &AvailableBytes, + (PULARGE_INTEGER) &TotalBytes, (PULARGE_INTEGER) &FreeBytes); + return FreeBytes; +#else + return -1; +#endif +} + }} diff --git a/src/utils/utils.hpp b/src/utils/utils.hpp index de7fac02b..9b6cc5a52 100755 --- a/src/utils/utils.hpp +++ b/src/utils/utils.hpp @@ -24,7 +24,7 @@ namespace EE { namespace Utils { std::vector EE_API FilesGetInPath( const String& path ); /** @return The size of a file */ - Uint32 EE_API FileSize( const std::string& Filepath ); + Uint64 EE_API FileSize( const std::string& Filepath ); /** @return The System Time */ eeDouble EE_API GetSystemTime(); @@ -134,6 +134,9 @@ namespace EE { namespace Utils { /** @return The OS Architecture */ std::string EE_API GetOSArchitecture(); + + /** @return Returns free disk space for a given path */ + Int64 EE_API GetDiskFreeSpace(const std::string& path); } }