Some minor changes for the android port.

This commit is contained in:
spartanj@gmail.com
2012-01-16 03:34:35 -03:00
parent cfc22fa297
commit 2227798ee2
12 changed files with 1360 additions and 672 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -815,3 +815,4 @@ src/bnb/cgamedata.cpp
src/bnb/cgameobjectdoor.hpp
src/bnb/cgameobjectdoor.cpp
src/audio/openal.cpp
src/test/empty_window/empty_window.cpp

View File

@@ -62,13 +62,7 @@
#define EE_PLATFORM EE_PLATFORM_HAIKU
#endif
#if EE_PLATFORM == EE_PLATFORM_ANDROID
#if !defined( EE_GLES1 ) && !defined( EE_GLES2 )
#define EE_GLES2
#endif
#endif
#if EE_PLATFORM == EE_PLATFORM_IOS
#if EE_PLATFORM == EE_PLATFORM_ANDROID || EE_PLATFORM == EE_PLATFORM_IOS
#if !defined( EE_GLES1 ) && !defined( EE_GLES2 )
#define EE_GLES2
#endif
@@ -95,6 +89,28 @@
#define EE_COMPILER_GCC
#endif
#if defined(arm) || defined(__arm__)
#define EE_ARM
#endif
#if EE_PLATFORM == EE_PLATFORM_ANDROID
#define EE_NO_WIDECHAR
#define main SDL_main
#ifndef EE_MAIN_FUNC
#ifdef __cplusplus
#define EE_MAIN_FUNC extern "C"
#else
#define EE_MAIN_FUNC
#endif
#endif
#else
#ifndef EE_MAIN_FUNC
#define EE_MAIN_FUNC
#endif
#endif
#ifndef EE_DEBUG
#if defined( DEBUG ) || defined( _DEBUG ) || defined( __DEBUG ) || defined( __DEBUG__ )
#define EE_DEBUG
@@ -118,6 +134,8 @@
#ifdef EE_PLATFORM
#define EE_SUPPORTED_PLATFORM
#else
#error Platform not supported
#endif
#if ( __GNUC__ >= 4 ) && defined( EE_DYNAMIC ) && defined( EE_EXPORTS )

View File

@@ -30,7 +30,7 @@ void eeREPORT_ASSERT( const char * File, int Line, const char * Exp ) {
if ( PrintDebugInLog )
cLog::instance()->Writef( "ASSERT: %s file:%s line:%d", Exp, File, Line );
#if defined(EE_COMPILER_GCC) && defined(EE_32BIT)
#if defined(EE_COMPILER_GCC) && defined(EE_32BIT) && !defined(EE_ARM)
asm("int3");
#else
assert( false );

View File

@@ -15,7 +15,7 @@ String::String(char ansiChar, const std::locale& locale)
mString += Utf32::DecodeAnsi(ansiChar, locale);
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
String::String(wchar_t wideChar)
{
mString += Utf32::DecodeWide(wideChar);
@@ -46,7 +46,7 @@ String::String(const std::string& ansiString, const std::locale& locale)
Utf32::FromAnsi(ansiString.begin(), ansiString.end(), std::back_inserter(mString), locale);
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
String::String(const wchar_t* wideString)
{
if (wideString)
@@ -99,7 +99,7 @@ String::operator std::string() const
return ToAnsiString();
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
String::operator std::wstring() const
{
return ToWideString();
@@ -118,7 +118,7 @@ std::string String::ToAnsiString(const std::locale& locale) const
return output;
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
String String::ToWideString() const
{
// Prepare the output string

View File

@@ -62,7 +62,7 @@ class EE_API String {
**/
String( char ansiChar, const std::locale& locale = std::locale() );
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
/** @brief Construct from single wide character
** @param wideChar Wide character to convert
**/
@@ -92,7 +92,7 @@ class EE_API String {
**/
String( const std::string& ansiString, const std::locale& locale = std::locale() );
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
/** @brief Construct from null-terminated C-style wide string
** @param wideString Wide string to convert
**/
@@ -132,7 +132,7 @@ class EE_API String {
**/
operator std::string() const;
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
/** @brief Implicit cast operator to String (wide string)
** Characters that do not fit in the target encoding are
** discarded from the returned string.
@@ -157,7 +157,7 @@ class EE_API String {
**/
std::string ToAnsiString( const std::locale& locale = std::locale() ) const;
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
/** @brief Convert the unicode string to a wide string
** Characters that do not fit in the target encoding are
** discarded from the returned string.

View File

@@ -172,7 +172,7 @@ public :
template <typename In, typename Out>
static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
////////////////////////////////////////////////////////////
/// \brief Convert an UTF-8 characters range to wide characters
///
@@ -382,7 +382,7 @@ public :
template <typename In, typename Out>
static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
////////////////////////////////////////////////////////////
/// \brief Convert an UTF-16 characters range to wide characters
///
@@ -593,7 +593,7 @@ public :
template <typename In, typename Out>
static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
////////////////////////////////////////////////////////////
/// \brief Convert an UTF-32 characters range to wide characters
///
@@ -716,7 +716,7 @@ public :
template <typename Out>
static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale());
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
////////////////////////////////////////////////////////////
/// \brief Encode a single UTF-32 character to wide
///

View File

@@ -170,7 +170,7 @@ Out Utf<8>::ToAnsi(In begin, In end, Out output, char replacement, const std::lo
return output;
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
template <typename In, typename Out>
Out Utf<8>::ToWide(In begin, In end, Out output, wchar_t replacement)
{
@@ -376,7 +376,7 @@ Out Utf<16>::ToAnsi(In begin, In end, Out output, char replacement, const std::l
return output;
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
template <typename In, typename Out>
Out Utf<16>::ToWide(In begin, In end, Out output, wchar_t replacement)
{
@@ -504,7 +504,7 @@ Out Utf<32>::ToAnsi(In begin, In end, Out output, char replacement, const std::l
return output;
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
template <typename In, typename Out>
Out Utf<32>::ToWide(In begin, In end, Out output, wchar_t replacement)
{
@@ -627,7 +627,7 @@ Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const st
#endif
}
#if EE_PLATFORM != EE_PLATFORM_ANDROID
#ifndef EE_NO_WIDECHAR
template <typename Out>
Out Utf<32>::EncodeWide(Uint32 codepoint, Out output, wchar_t replacement)
{

View File

@@ -71,7 +71,7 @@ void cThread::Terminate() {
#elif defined( EE_PLATFORM_POSIX )
#ifndef ANDROID
#if EE_PLATFORM != EE_PLATFORM_ANDROID
pthread_cancel( mThread );
#else
pthread_kill( mThread , SIGUSR1 );

View File

@@ -1792,7 +1792,7 @@ void cEETest::End() {
cEngine::DestroySingleton();
}
int main (int argc, char * argv []) {
EE_MAIN_FUNC int main (int argc, char * argv []) {
cEETest * Test = eeNew( cEETest, () );
Test->Process();

View File

@@ -0,0 +1,58 @@
#include "../../ee.h"
// EE_MAIN_FUNC is needed for some platforms to export the main function as C function.
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( ) );
// Check if created
if ( win->Created() )
{
// Get input pointer
cInput * imp = win->GetInput();
// 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();
}
// Create an instance of the primitive renderer
cPrimitives p;
// Set the primitive color
p.SetColor( eeColorA( 0, 150, 0, 150 ) );
// Draw a rectangle
p.DrawRectangle( 100, 100, win->GetWidth() - 200, win->GetHeight() - 200 );
// Change the color
p.SetColor( eeColorA( 0, 255, 0, 150 ) );
// Draw a circle
p.DrawCircle( win->GetWidth() / 2, win->GetHeight() / 2, 200 );
// Draw frame
win->Display();
// Sleep thread for 10 ms
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;
}

View File

@@ -389,6 +389,8 @@ std::string GetProcessPath() {
}
return FileRemoveFileName( std::string( info.name ) );
#elif EE_PLATFORM == EE_PLATFORM_ANDROID
return "/sdcard/";
#else
#warning GetProcessPath() not implemented on this platform. ( will return "./" )
return "./";