mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-18 06:55:48 +03:00
Port to android working :) ( not finished, but working )
This commit is contained in:
@@ -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 <android/log.h>
|
||||
#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
|
||||
|
||||
@@ -572,10 +572,13 @@ Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale)
|
||||
return static_cast<Uint32>(character);
|
||||
|
||||
#else
|
||||
|
||||
// Get the facet of the locale which deals with character conversion
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID
|
||||
const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
|
||||
|
||||
#else
|
||||
const std::ctype<char>& facet = std::use_facet< std::ctype<char> >(locale);
|
||||
#endif
|
||||
|
||||
// Use the facet to convert each character of the input string
|
||||
return static_cast<Uint32>(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<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
|
||||
#else
|
||||
const std::ctype<char>& facet = std::use_facet< std::ctype<char> >(locale);
|
||||
#endif
|
||||
|
||||
// Use the facet to convert each character of the input string
|
||||
*output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef EE_SYSTEMSINGLETON_H
|
||||
#define EE_SYSTEMSINGLETON_H
|
||||
|
||||
#include "../base.hpp"
|
||||
|
||||
#include "../base.hpp"
|
||||
#include <typeinfo>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,13 @@
|
||||
#elif EE_PLATFORM == EE_PLATFORM_LINUX || EE_PLATFORM == EE_PLATFORM_ANDROID
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
#if EE_PLATFORM != EE_PLATFORM_ANDROID
|
||||
#include <sys/statvfs.h>
|
||||
#else
|
||||
#include <sys/vfs.h>
|
||||
#define statvfs statfs
|
||||
#define fstatvfs fstatfs
|
||||
#endif
|
||||
#elif EE_PLATFORM == EE_PLATFORM_HAIKU
|
||||
#include <kernel/OS.h>
|
||||
#include <kernel/image.h>
|
||||
@@ -16,6 +23,8 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if EE_PLATFORM == EE_PLATFORM_MACOSX || EE_PLATFORM == EE_PLATFORM_BSD
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
@@ -570,7 +579,7 @@ std::vector<std::string> 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
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace EE { namespace Utils {
|
||||
std::vector<String> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user