From feee056b407ca39d2ff1918153c6cc9f11f4e987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 30 Jul 2017 02:42:47 -0300 Subject: [PATCH] Fixed Android compilation. --HG-- branch : dev --- include/eepp/graphics/renderer/opengl.hpp | 12 +++++ include/eepp/graphics/subtexture.hpp | 2 +- include/eepp/graphics/texture.hpp | 6 +-- include/eepp/maps/gameobjectsubtextureex.hpp | 2 +- include/eepp/window/window.hpp | 2 +- projects/android-project/AndroidManifest.xml | 2 +- projects/android-project/jni/Application.mk | 7 +-- src/eepp/audio/soundbuffer.cpp | 7 ++- src/eepp/graphics/renderer/renderer.cpp | 54 ++++++++++---------- src/eepp/system/color.cpp | 1 + src/eepp/system/sys.cpp | 4 +- src/eepp/window/backend/SDL2/windowsdl2.cpp | 34 ++++++------ src/eepp/window/backend/SDL2/windowsdl2.hpp | 2 +- src/test/eetest.cpp | 4 +- 14 files changed, 78 insertions(+), 61 deletions(-) diff --git a/include/eepp/graphics/renderer/opengl.hpp b/include/eepp/graphics/renderer/opengl.hpp index 99f4703fa..465426001 100644 --- a/include/eepp/graphics/renderer/opengl.hpp +++ b/include/eepp/graphics/renderer/opengl.hpp @@ -103,6 +103,18 @@ #define glBindVertexArray glBindVertexArrayOES #define GL_VERTEX_ARRAY_BINDING GL_VERTEX_ARRAY_BINDING_OES +#ifndef GL_STENCIL_INDEX +#define GL_STENCIL_INDEX GL_STENCIL_INDEX_OES +#endif + +#ifndef GL_FRAMEBUFFER_EXT +#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER +#endif + +#ifndef GL_RENDERBUFFER_EXT +#define GL_RENDERBUFFER_EXT GL_RENDERBUFFER +#endif + #endif /// Exclusive only when its compiling only for GLES2 diff --git a/include/eepp/graphics/subtexture.hpp b/include/eepp/graphics/subtexture.hpp index cd3bbf73b..2d7591f89 100644 --- a/include/eepp/graphics/subtexture.hpp +++ b/include/eepp/graphics/subtexture.hpp @@ -81,7 +81,7 @@ class EE_API SubTexture : public Drawable { /** Set the SubTexture offset. */ void setOffset( const Vector2i& offset ); - void draw( const Float& X, const Float& Y, const Color& Color = Color(), const Float& Angle = 0.f, const Vector2f& Scale = Vector2f::One, const EE_BLEND_MODE& Blend = ALPHA_NORMAL, const EE_RENDER_MODE& Effect = RN_NORMAL, OriginPoint Center = OriginPoint(OriginPoint::OriginCenter) ); + void draw( const Float& X, const Float& Y, const Color& color = Color(), const Float& Angle = 0.f, const Vector2f& Scale = Vector2f::One, const EE_BLEND_MODE& Blend = ALPHA_NORMAL, const EE_RENDER_MODE& Effect = RN_NORMAL, OriginPoint Center = OriginPoint(OriginPoint::OriginCenter) ); void draw( const Float& X, const Float& Y, const Float& Angle, const Vector2f& Scale, const Color& Color0 = Color(), const Color& Color1 = Color(), const Color& Color2 = Color(), const Color& Color3 = Color(), const EE_BLEND_MODE& Blend = ALPHA_NORMAL, const EE_RENDER_MODE& Effect = RN_NORMAL, OriginPoint Center = OriginPoint(OriginPoint::OriginCenter) ); diff --git a/include/eepp/graphics/texture.hpp b/include/eepp/graphics/texture.hpp index 6b0ff1d52..5dd2f3441 100755 --- a/include/eepp/graphics/texture.hpp +++ b/include/eepp/graphics/texture.hpp @@ -158,7 +158,7 @@ class EE_API Texture : public Image, public Drawable, private NonCopyable { * @param width The width of the texture rendered * @param height The height of the texture rendered */ - void drawFast( const Float& x, const Float& y, const Float& Angle = 0.0f, const Vector2f& scale = Vector2f::One, const Color& Color = Color(), const EE_BLEND_MODE &Blend = ALPHA_NORMAL, const Float &width = 0, const Float &height = 0 ); + void drawFast( const Float& x, const Float& y, const Float& Angle = 0.0f, const Vector2f& scale = Vector2f::One, const Color& color = Color(), const EE_BLEND_MODE &Blend = ALPHA_NORMAL, const Float &width = 0, const Float &height = 0 ); /** Render the texture on screen * @param x The x position on screen @@ -171,7 +171,7 @@ class EE_API Texture : public Image, public Drawable, private NonCopyable { * @param Center The rotation and scaling center. The center point is relative to the top-left corner of the object. * @param texSector The texture sector to render. You can render only a part of the texture. ( default render all the texture ) */ - void draw( const Float &x, const Float &y, const Float &Angle = 0, const Vector2f &scale = Vector2f::One, const Color& Color = Color(255,255,255,255), const EE_BLEND_MODE &Blend = ALPHA_NORMAL, const EE_RENDER_MODE &Effect = RN_NORMAL, OriginPoint Center = OriginPoint(OriginPoint::OriginCenter), const Rect& texSector = Rect(0,0,0,0) ); + void draw( const Float &x, const Float &y, const Float &Angle = 0, const Vector2f &scale = Vector2f::One, const Color& color = Color(255,255,255,255), const EE_BLEND_MODE &Blend = ALPHA_NORMAL, const EE_RENDER_MODE &Effect = RN_NORMAL, OriginPoint Center = OriginPoint(OriginPoint::OriginCenter), const Rect& texSector = Rect(0,0,0,0) ); /** Render the texture on screen. Extended because can set the vertex colors individually * @param x The x position on screen @@ -200,7 +200,7 @@ class EE_API Texture : public Image, public Drawable, private NonCopyable { * @param Blend Set the Blend Mode ( default ALPHA_NORMAL ) * @param texSector The texture sector to render. You can render only a part of the texture. ( default render all the texture ) */ - void drawQuad( const Quad2f& Q, const Vector2f& Offset = Vector2f(), const Float &Angle = 0.0f, const Vector2f &scale = Vector2f::One, const Color& Color = Color(255,255,255,255), const EE_BLEND_MODE &Blend = ALPHA_NORMAL, const Rect& texSector = Rect(0,0,0,0) ); + void drawQuad( const Quad2f& Q, const Vector2f& Offset = Vector2f(), const Float &Angle = 0.0f, const Vector2f &scale = Vector2f::One, const Color& color = Color(255,255,255,255), const EE_BLEND_MODE &Blend = ALPHA_NORMAL, const Rect& texSector = Rect(0,0,0,0) ); /** Render a quad on Screen * @param Q The Quad2f diff --git a/include/eepp/maps/gameobjectsubtextureex.hpp b/include/eepp/maps/gameobjectsubtextureex.hpp index 08f80611f..1896e3493 100644 --- a/include/eepp/maps/gameobjectsubtextureex.hpp +++ b/include/eepp/maps/gameobjectsubtextureex.hpp @@ -8,7 +8,7 @@ namespace EE { namespace Maps { class EE_API GameObjectSubTextureEx : public GameObjectSubTexture { public: - GameObjectSubTextureEx( const Uint32& Flags, MapLayer * Layer, Graphics::SubTexture * SubTexture = NULL, const Vector2f& Pos = Vector2f(), EE_BLEND_MODE Blend = ALPHA_NORMAL, EE_RENDER_MODE Render = RN_NORMAL, Float Angle = 0.f, Vector2f Scale = Vector2f::One, Color Color = Color() ); + GameObjectSubTextureEx( const Uint32& Flags, MapLayer * Layer, Graphics::SubTexture * SubTexture = NULL, const Vector2f& Pos = Vector2f(), EE_BLEND_MODE Blend = ALPHA_NORMAL, EE_RENDER_MODE Render = RN_NORMAL, Float Angle = 0.f, Vector2f Scale = Vector2f::One, Color color = Color() ); virtual ~GameObjectSubTextureEx(); diff --git a/include/eepp/window/window.hpp b/include/eepp/window/window.hpp index 40e7a0d4e..6fe20f2b0 100644 --- a/include/eepp/window/window.hpp +++ b/include/eepp/window/window.hpp @@ -23,7 +23,7 @@ namespace WindowStyle { Fullscreen = ( 1 << 3 ), UseDesktopResolution = ( 1 << 4 ), #if EE_PLATFORM == EE_PLATFORM_IOS || EE_PLATFORM == EE_PLATFORM_ANDROID - Default = NoBorder + Default = Borderless #else Default = Titlebar | Resize #endif diff --git a/projects/android-project/AndroidManifest.xml b/projects/android-project/AndroidManifest.xml index 253efd07f..c27fad9a3 100644 --- a/projects/android-project/AndroidManifest.xml +++ b/projects/android-project/AndroidManifest.xml @@ -22,7 +22,7 @@ - + diff --git a/projects/android-project/jni/Application.mk b/projects/android-project/jni/Application.mk index 2cded4c47..7e8584a7b 100644 --- a/projects/android-project/jni/Application.mk +++ b/projects/android-project/jni/Application.mk @@ -5,7 +5,7 @@ EE_SDL_VERSION := EE_SDL_VERSION_2 EE_GLES_VERSION := -DEE_GLES2 -DSOIL_GLES2 -DSDL_GLES2 -DEE_GLES1 -DSOIL_GLES1 -DSDL_GLES1 EE_GLES_LINK := -lGLESv2 -lGLESv1_CM -APP_STL := stlport_static +APP_STL := c++_static APP_LDLIBS := -llog $(EE_GLES_LINK) -lm -lz -lOpenSLES -lEGL -landroid @@ -15,9 +15,10 @@ APP_LDLIBS := -llog $(EE_GLES_LINK) -lm -lz -lOpenSLES -lEGL -landroid #Release Build APP_CFLAGS := -fno-strict-aliasing -O3 -s -DNDEBUG -ffast-math +APP_CPPFLAGS := -std=c++11 -frtti -fexceptions -APP_PLATFORM := android-10 +APP_PLATFORM := android-14 APP_MODULES := main APP_ABI := armeabi-v7a x86 -NDK_TOOLCHAIN_VERSION := 4.8 +NDK_TOOLCHAIN_VERSION := clang diff --git a/src/eepp/audio/soundbuffer.cpp b/src/eepp/audio/soundbuffer.cpp index bca1cfd49..7172e31d0 100755 --- a/src/eepp/audio/soundbuffer.cpp +++ b/src/eepp/audio/soundbuffer.cpp @@ -149,11 +149,14 @@ bool SoundBuffer::loadFromSamples( const Int16 * Samples, std::size_t SamplesCou bool SoundBuffer::saveToFile(const std::string& Filename) const { // Create the sound file in write mode - std::unique_ptr File( SoundFile::createWrite( Filename, getChannelCount(), getSampleRate() ) ); + SoundFile * File = SoundFile::createWrite( Filename, getChannelCount(), getSampleRate() ); - if ( File.get() ) { + if ( NULL != File ) { // Write the samples to the opened file File->write( &mSamples[0], mSamples.size() ); + + eeSAFE_DELETE( File ); + return true; } else { // Error... diff --git a/src/eepp/graphics/renderer/renderer.cpp b/src/eepp/graphics/renderer/renderer.cpp index d14bb7141..3395e9e65 100644 --- a/src/eepp/graphics/renderer/renderer.cpp +++ b/src/eepp/graphics/renderer/renderer.cpp @@ -79,11 +79,11 @@ Renderer * Renderer::createSingleton( EEGL_version ver ) { Renderer * Renderer::createSingleton() { if ( sSingleton == 0 ) { #if defined( EE_GLES_BOTH ) - ms_singleton = eeNew( RendererGL, () ); + sSingleton = eeNew( RendererGL, () ); #elif defined( EE_GLES2 ) - ms_singleton = eeNew( RendererGLES2, () ); + sSingleton = eeNew( RendererGLES2, () ); #elif defined( EE_GLES1 ) - ms_singleton = eeNew( RendererGL, () ); + sSingleton = eeNew( RendererGL, () ); #else sSingleton = eeNew( RendererGL, () ); #endif @@ -192,45 +192,45 @@ void Renderer::init() { #ifdef EE_GLES - WriteExtension( EEGL_ARB_point_parameters , 1 ); - WriteExtension( EEGL_ARB_point_sprite , 1 ); - WriteExtension( EEGL_ARB_multitexture , 1 ); + writeExtension( EEGL_ARB_point_parameters , 1 ); + writeExtension( EEGL_ARB_point_sprite , 1 ); + writeExtension( EEGL_ARB_multitexture , 1 ); - WriteExtension( EEGL_IMG_texture_compression_pvrtc , IsExtension( "GL_IMG_texture_compression_pvrtc" ) ); + writeExtension( EEGL_IMG_texture_compression_pvrtc , isExtension( "GL_IMG_texture_compression_pvrtc" ) ); - if ( !IsExtension( EEGL_EXT_texture_compression_s3tc ) ) { - WriteExtension( EEGL_EXT_texture_compression_s3tc , IsExtension( "GL_OES_texture_compression_S3TC" ) ); + if ( !isExtension( EEGL_EXT_texture_compression_s3tc ) ) { + writeExtension( EEGL_EXT_texture_compression_s3tc , isExtension( "GL_OES_texture_compression_S3TC" ) ); } - if ( !IsExtension( EEGL_EXT_framebuffer_object ) ) { - WriteExtension( EEGL_EXT_framebuffer_object , IsExtension( "GL_OES_framebuffer_object" ) ); + if ( !isExtension( EEGL_EXT_framebuffer_object ) ) { + writeExtension( EEGL_EXT_framebuffer_object , isExtension( "GL_OES_framebuffer_object" ) ); } - if ( !IsExtension( EEGL_ARB_texture_non_power_of_two ) ) { - WriteExtension( EEGL_ARB_texture_non_power_of_two , IsExtension( "GL_IMG_texture_npot" ) || - IsExtension( "GL_OES_texture_npot" ) || - IsExtension( "GL_APPLE_texture_2D_limited_npot" ) ); + if ( !isExtension( EEGL_ARB_texture_non_power_of_two ) ) { + writeExtension( EEGL_ARB_texture_non_power_of_two , isExtension( "GL_IMG_texture_npot" ) || + isExtension( "GL_OES_texture_npot" ) || + isExtension( "GL_APPLE_texture_2D_limited_npot" ) ); } - if ( !IsExtension( EEGL_ARB_vertex_array_object ) ) { - WriteExtension( EEGL_ARB_vertex_array_object , IsExtension( "GL_OES_vertex_array_object" ) ); + if ( !isExtension( EEGL_ARB_vertex_array_object ) ) { + writeExtension( EEGL_ARB_vertex_array_object , isExtension( "GL_OES_vertex_array_object" ) ); } #endif #ifdef EE_GLES2 - WriteExtension( EEGL_EXT_framebuffer_object , 1 ); - WriteExtension( EEGL_ARB_vertex_buffer_object , 1 ); - WriteExtension( EEGL_ARB_shader_objects , 1 ); - WriteExtension( EEGL_ARB_vertex_shader , 1 ); - WriteExtension( EEGL_ARB_fragment_shader , 1 ); + writeExtension( EEGL_EXT_framebuffer_object , 1 ); + writeExtension( EEGL_ARB_vertex_buffer_object , 1 ); + writeExtension( EEGL_ARB_shader_objects , 1 ); + writeExtension( EEGL_ARB_vertex_shader , 1 ); + writeExtension( EEGL_ARB_fragment_shader , 1 ); #endif #if EE_PLATFORM == EE_PLATFORM_EMSCRIPTEN - if ( !IsExtension( EEGL_EXT_texture_compression_s3tc ) ) { - WriteExtension( EEGL_EXT_texture_compression_s3tc , IsExtension( "WEBGL_compressed_texture_s3tc" ) || - IsExtension( "WEBKIT_WEBGL_compressed_texture_s3tc" ) || - IsExtension( "MOZ_WEBGL_compressed_texture_s3tc" ) ); + if ( !isExtension( EEGL_EXT_texture_compression_s3tc ) ) { + writeExtension( EEGL_EXT_texture_compression_s3tc , isExtension( "WEBGL_compressed_texture_s3tc" ) || + isExtension( "WEBKIT_WEBGL_compressed_texture_s3tc" ) || + isExtension( "MOZ_WEBGL_compressed_texture_s3tc" ) ); } #endif } @@ -257,7 +257,7 @@ bool Renderer::pointSpriteSupported() { bool Renderer::shadersSupported() { #ifdef EE_GLES - return ( GLv_ES2 == Version() || GLv_3 == Version() || GLv_3CP == Version() ); + return ( GLv_ES2 == version() || GLv_3 == version() || GLv_3CP == version() ); #else return GLv_3CP == version() || ( isExtension( EEGL_ARB_shader_objects ) && isExtension( EEGL_ARB_vertex_shader ) && isExtension( EEGL_ARB_fragment_shader ) ); #endif diff --git a/src/eepp/system/color.cpp b/src/eepp/system/color.cpp index db31ea24c..1e4f65537 100644 --- a/src/eepp/system/color.cpp +++ b/src/eepp/system/color.cpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace EE { namespace System { diff --git a/src/eepp/system/sys.cpp b/src/eepp/system/sys.cpp index baa2f7bf4..24ee60a3a 100644 --- a/src/eepp/system/sys.cpp +++ b/src/eepp/system/sys.cpp @@ -656,9 +656,9 @@ std::string Sys::getTempPath() { } #elif EE_PLATFORM == EE_PLATFORM_ANDROID if ( NULL != Window::Engine::instance() ) { - String::StrCopy( path, Window::Engine::instance()->getCurrentWindow()->getInternalStoragePath().c_str(), EE_MAX_CFG_PATH_LEN ); + String::strCopy( path, Window::Engine::instance()->getCurrentWindow()->getInternalStoragePath().c_str(), EE_MAX_CFG_PATH_LEN ); } else { - String::StrCopy( path, "/tmp", EE_MAX_CFG_PATH_LEN ); + String::strCopy( path, "/tmp", EE_MAX_CFG_PATH_LEN ); } #else char * tmpdir = getenv("TMPDIR"); diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index d4b6388a2..17b2d60b5 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -21,7 +21,7 @@ #include #include -static std::string SDL_AndroidgetApkPath() { +static std::string SDL_AndroidGetApkPath() { static std::string apkPath = ""; if ( "" == apkPath ) { @@ -30,9 +30,9 @@ static std::string SDL_AndroidgetApkPath() { jobject fileObject; const char *path; - JNIEnv *env = (JNIEnv*)SDL_AndroidgetJNIEnv(); + JNIEnv *env = (JNIEnv*)SDL_AndroidGetJNIEnv(); - jclass ActivityClass = env->GetObjectClass((jobject)SDL_AndroidgetActivity()); + jclass ActivityClass = env->GetObjectClass((jobject)SDL_AndroidGetActivity()); // context = SDLActivity.getContext(); mid = env->GetStaticMethodID(ActivityClass,"getContext","()Landroid/content/Context;"); @@ -109,7 +109,7 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { if ( SDL_Init( SDL_INIT_VIDEO ) != 0 ) { eePRINTL( "Unable to initialize SDL: %s", SDL_GetError() ); - logFailureInit( "WindowSDL", GetVersion() ); + logFailureInit( "WindowSDL", getVersion() ); return false; } @@ -151,7 +151,7 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { if ( NULL == mSDLWindow ) { eePRINTL( "Unable to create window: %s", SDL_GetError() ); - logFailureInit( "WindowSDL", GetVersion() ); + logFailureInit( "WindowSDL", getVersion() ); return false; } @@ -220,7 +220,7 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { { eePRINTL( "Unable to create context: %s", SDL_GetError() ); - logFailureInit( "WindowSDL", GetVersion() ); + logFailureInit( "WindowSDL", getVersion() ); return false; } @@ -259,18 +259,18 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { mCursorManager->set( SYS_CURSOR_ARROW ); #if EE_PLATFORM == EE_PLATFORM_ANDROID - std::string apkPath( SDL_AndroidgetApkPath() ); + std::string apkPath( SDL_AndroidGetApkPath() ); eePRINTL( "Opening application APK in: %s", apkPath.c_str() ); - if ( mZip->Open( apkPath ) ) + if ( mZip->open( apkPath ) ) eePRINTL( "APK opened succesfully!" ); else eePRINTL( "Failed to open APK!" ); - LogSuccessfulInit( GetVersion(), apkPath ); + logSuccessfulInit( getVersion(), apkPath ); #else - logSuccessfulInit( GetVersion() ); + logSuccessfulInit( getVersion() ); #endif return true; @@ -292,7 +292,7 @@ void WindowSDL::unsetGLContextThread() { SDL_GL_MakeCurrent( mSDLWindow, NULL ); } -std::string WindowSDL::GetVersion() { +std::string WindowSDL::getVersion() { SDL_version ver; SDL_GetVersion( &ver ); @@ -635,27 +635,27 @@ bool WindowSDL::isScreenKeyboardShown() { #if EE_PLATFORM == EE_PLATFORM_ANDROID void * WindowSDL::getJNIEnv() { - return SDL_AndroidgetJNIEnv(); + return SDL_AndroidGetJNIEnv(); } void * WindowSDL::getActivity() { - return SDL_AndroidgetActivity(); + return SDL_AndroidGetActivity(); } int WindowSDL::getExternalStorageState() { - return SDL_AndroidgetExternalStorageState(); + return SDL_AndroidGetExternalStorageState(); } std::string WindowSDL::getInternalStoragePath() { - return std::string( SDL_AndroidgetInternalStoragePath() ); + return std::string( SDL_AndroidGetInternalStoragePath() ); } std::string WindowSDL::getExternalStoragePath() { - return std::string( SDL_AndroidgetExternalStoragePath() ); + return std::string( SDL_AndroidGetExternalStoragePath() ); } std::string WindowSDL::getApkPath() { - return SDL_AndroidgetApkPath(); + return SDL_AndroidGetApkPath(); } #endif diff --git a/src/eepp/window/backend/SDL2/windowsdl2.hpp b/src/eepp/window/backend/SDL2/windowsdl2.hpp index 2de0a0900..27b32e8e3 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.hpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.hpp @@ -115,7 +115,7 @@ class EE_API WindowSDL : public Window { void SetGLConfig(); - std::string GetVersion(); + std::string getVersion(); void UpdateDesktopResolution(); }; diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index b94a3ef2a..c4115432c 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -1106,8 +1106,8 @@ void EETest::loadTextures() { #ifdef EE_GLES Image tImg( MyPath + "sprites/objects/2.png", 4 ); - tImg.CreateMaskFromColor( ColorA(0,0,0,255), 0 ); - Tiles[7] = SG->Add( TF->loadFromPixels( tImg.getPixelsPtr(), tImg.getWidth(), tImg.getHeight(), tImg.getChannels() ), "8" ); + tImg.createMaskFromColor( ColorA(0,0,0,255), 0 ); + Tiles[7] = SG->add( TF->loadFromPixels( tImg.getPixelsPtr(), tImg.getWidth(), tImg.getHeight(), tImg.getChannels() ), "8" ); #else Tiles[7] = SG->add( TF->loadFromFile( MyPath + "sprites/objects/2.png" ), "8" ); Tiles[7]->getTexture()->createMaskFromColor( Color(0,0,0,255), 0 );