Fixed Android compilation.

--HG--
branch : dev
This commit is contained in:
Martín Lucas Golini
2017-07-30 02:42:47 -03:00
parent f7b8b41677
commit feee056b40
14 changed files with 78 additions and 61 deletions

View File

@@ -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

View File

@@ -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) );

View File

@@ -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

View File

@@ -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();

View File

@@ -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

View File

@@ -22,7 +22,7 @@
<supports-screens android:anyDensity="true" />
<!-- Android 2.3.3 -->
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
<!-- OpenGL ES 2.0 -->
<uses-feature android:glEsVersion="0x00020000" />

View File

@@ -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

View File

@@ -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<SoundFile> 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...

View File

@@ -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

View File

@@ -2,6 +2,7 @@
#include <eepp/core/string.hpp>
#include <eepp/math/math.hpp>
#include <cstdlib>
#include <ctype.h>
namespace EE { namespace System {

View File

@@ -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");

View File

@@ -21,7 +21,7 @@
#include <eepp/system/zip.hpp>
#include <jni.h>
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

View File

@@ -115,7 +115,7 @@ class EE_API WindowSDL : public Window {
void SetGLConfig();
std::string GetVersion();
std::string getVersion();
void UpdateDesktopResolution();
};

View File

@@ -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 );