From eaed47f7ecfc3279494ae0dab0c7e6788d5b48ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Mon, 29 Apr 2013 17:03:36 -0300 Subject: [PATCH] Changed the texture loader, added ETC1 support. Some minor changes to Android port. And other minor changes. --- include/eepp/graphics/ctextureloader.hpp | 4 +- include/eepp/system/bitop.hpp | 9 +- include/eepp/window/cinput.hpp | 4 - include/eepp/window/cwindow.hpp | 2 +- projects/android-project/AndroidManifest.xml | 2 +- projects/android-project/README | 2 +- projects/android-project/assets.sh | 3 + projects/android-project/compile.sh | 4 +- projects/android-project/data.sh | 3 - projects/android-project/jni/Android.mk | 11 +- projects/android-project/jni/Application.mk | 12 +- projects/linux/ee.creator.user | 4 +- projects/linux/ee.files | 22 +++ src/eepp/graphics/ctextureloader.cpp | 179 ++++++++++--------- src/eepp/helper/android/openal-soft/config.h | 2 +- src/eepp/system/sys.cpp | 2 +- src/eepp/window/backend/SDL2/cwindowsdl2.cpp | 6 +- src/eepp/window/cinput.cpp | 30 +--- src/eepp/window/cwindow.cpp | 4 +- 19 files changed, 161 insertions(+), 144 deletions(-) create mode 100755 projects/android-project/assets.sh delete mode 100755 projects/android-project/data.sh diff --git a/include/eepp/graphics/ctextureloader.hpp b/include/eepp/graphics/ctextureloader.hpp index 4ab4a26fc..a00a30450 100644 --- a/include/eepp/graphics/ctextureloader.hpp +++ b/include/eepp/graphics/ctextureloader.hpp @@ -113,8 +113,8 @@ class EE_API cTextureLoader : public cObjectLoader { void Reset(); private: bool mTexLoaded; - bool mIsDDS; - bool mIsPVR; + bool mDirectUpload; + int mImgType; int mIsCompressed; cTimeElapsed mTE; diff --git a/include/eepp/system/bitop.hpp b/include/eepp/system/bitop.hpp index e51775cca..d4cd063ef 100755 --- a/include/eepp/system/bitop.hpp +++ b/include/eepp/system/bitop.hpp @@ -13,7 +13,8 @@ class BitOp { * @param Pos The Position of the bit * @param BitWrite 0 for write 0, any other to write 1. */ - static inline void WriteBitKey( unsigned int * Key, unsigned int Pos, unsigned int BitWrite ) { + template + static inline void WriteBitKey( T * Key, unsigned int Pos, unsigned int BitWrite ) { ( BitWrite ) ? ( * Key ) |= ( 1 << Pos ) : ( * Key ) &= ~( 1 << Pos ); } @@ -22,7 +23,8 @@ class BitOp { * @param Pos The Position in the key to read * @return True if the bit is 1 */ - static inline bool ReadBitKey( Uint32 * Key, Uint32 Pos ) { + template + static inline bool ReadBitKey( T * Key, Uint32 Pos ) { return 0 != ( ( * Key ) & ( 1 << Pos ) ); } @@ -31,7 +33,8 @@ class BitOp { * @param Val The Value to write or remove * @param BitWrite 0 to remove, any value to write */ - static inline void SetBitFlagValue( Uint32 * Key, Uint32 Val, Uint32 BitWrite ) { + template + static inline void SetBitFlagValue( T * Key, Uint32 Val, Uint32 BitWrite ) { ( BitWrite ) ? ( * Key ) |= Val : ( * Key ) &= ~Val; } diff --git a/include/eepp/window/cinput.hpp b/include/eepp/window/cinput.hpp index 15f30a74c..3bc21d392 100644 --- a/include/eepp/window/cinput.hpp +++ b/include/eepp/window/cinput.hpp @@ -212,10 +212,6 @@ class EE_API cInput { std::map mCallbacks; - bool GetKey( Uint8 * Key, Uint8 Pos ); - - void PushKey( Uint8 * Key, Uint8 Pos, bool BitWrite ); - void ProcessEvent( InputEvent * Event ); cInputFinger * GetFingerId( const Int64& fingerId ); diff --git a/include/eepp/window/cwindow.hpp b/include/eepp/window/cwindow.hpp index 43b99533d..1bf681359 100644 --- a/include/eepp/window/cwindow.hpp +++ b/include/eepp/window/cwindow.hpp @@ -479,7 +479,7 @@ class EE_API cWindow { void ViewCheckUpdate(); - void LogSuccessfulInit( const std::string& BackendName ); + void LogSuccessfulInit( const std::string& BackendName, const std::string& ProcessPath = "" ); void LogFailureInit( const std::string& ClassName, const std::string& BackendName ); }; diff --git a/projects/android-project/AndroidManifest.xml b/projects/android-project/AndroidManifest.xml index f7ac728b8..574b52bd3 100644 --- a/projects/android-project/AndroidManifest.xml +++ b/projects/android-project/AndroidManifest.xml @@ -18,5 +18,5 @@ - + diff --git a/projects/android-project/README b/projects/android-project/README index eac676b3d..f082ac766 100644 --- a/projects/android-project/README +++ b/projects/android-project/README @@ -1,5 +1,5 @@ Inside: -src/eepp/helper/android/SDL2/include/ +src/eepp/helper/SDL2/include add a symbolic link to the same folder in a subfolder called SDL ( ln -s . SDL ) diff --git a/projects/android-project/assets.sh b/projects/android-project/assets.sh new file mode 100755 index 000000000..682669a01 --- /dev/null +++ b/projects/android-project/assets.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +adb push ../../assets /sdcard/assets diff --git a/projects/android-project/compile.sh b/projects/android-project/compile.sh index cfa1ed8ec..f76c6dd70 100755 --- a/projects/android-project/compile.sh +++ b/projects/android-project/compile.sh @@ -1,8 +1,8 @@ #!/bin/sh cd $(dirname "$0") export NDK_PROJECT_PATH=$(dirname "$0") -ndk-build -j4 +ndk-build NDK_LOG=1 NDK_DEBUG=1 -j4 rm -rf ./bin ant debug adb install -r bin/EEPPApp-debug.apk -ndk-gdb --force --start +ndk-gdb --force --start --verbose diff --git a/projects/android-project/data.sh b/projects/android-project/data.sh deleted file mode 100755 index 1e9bbd7bc..000000000 --- a/projects/android-project/data.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -adb push data /sdcard/data diff --git a/projects/android-project/jni/Android.mk b/projects/android-project/jni/Android.mk index f7f5613a1..3be30d1fb 100644 --- a/projects/android-project/jni/Android.mk +++ b/projects/android-project/jni/Android.mk @@ -7,7 +7,7 @@ MY_SDL_PATH := $(MY_PATH)/helper/SDL2 MY_SDL_MAIN_PATH := helper/SDL2/src/main/android/*.cpp MY_C_INCLUDES := \ - $(MY_PATH)/helper/android/openal/include/ \ + $(MY_PATH)/helper/android/openal-soft/include/ \ $(MY_PATH)/helper/freetype2/include \ $(MY_SDL_PATH)/include \ $(MY_PATH)/helper/chipmunk \ @@ -161,10 +161,9 @@ LOCAL_PATH := $(MY_SDL_PATH) LOCAL_MODULE := SDL2 -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include \ - $(MY_PATH)/helper/android/openal/include/ +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_CFLAGS := -O3 -D__ANDROID__ -DANDROID -DGL_GLEXT_PROTOTYPES \ +LOCAL_CFLAGS := -D__ANDROID__ -DANDROID -DGL_GLEXT_PROTOTYPES \ $(EE_GLES_VERSION) LOCAL_SRC_FILES := \ @@ -207,7 +206,7 @@ include $(CLEAR_VARS) LOCAL_PATH := $(MY_PATH) -LOCAL_MODULE := main +LOCAL_MODULE := empty_window LOCAL_LDLIBS := $(MY_LDLIBS) @@ -255,7 +254,7 @@ include $(CLEAR_VARS) LOCAL_PATH := $(MY_PATH) -LOCAL_MODULE := eetest +LOCAL_MODULE := main LOCAL_LDLIBS := $(MY_LDLIBS) diff --git a/projects/android-project/jni/Application.mk b/projects/android-project/jni/Application.mk index 523fbdf63..a729a34ae 100644 --- a/projects/android-project/jni/Application.mk +++ b/projects/android-project/jni/Application.mk @@ -13,12 +13,14 @@ APP_STL := stlport_static APP_LDLIBS := -llog $(EE_GLES_LINK) -lm -lz -lOpenSLES #Debug Build -#APP_CFLAGS := -g -DDEBUG -DEE_DEBUG -DEE_MEMORY_MANAGER # arm-linux-androideabi-4.4.3 crashes in -O0 mode on SDL sources +# arm-linux-androideabi-4.4.3 crashes in -O0 mode on SDL sources +APP_CFLAGS := -g -DDEBUG -DEE_DEBUG -DEE_MEMORY_MANAGER +APP_OPTIM :=debug #Release Build -APP_CFLAGS := -fno-strict-aliasing -O3 -s -DNDEBUG -ffast-math +#APP_CFLAGS := -fno-strict-aliasing -O3 -s -DNDEBUG -ffast-math -APP_PLATFORM := android-7 +APP_PLATFORM := android-9 APP_MODULES := main -#APP_ABI := armeabi-v7a -APP_ABI := x86 +APP_ABI := armeabi-v7a +#APP_ABI := x86 diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 4cb5267be..a0bab4496 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -13,7 +13,7 @@ false true - Cpp + Cpp CppGlobal diff --git a/projects/linux/ee.files b/projects/linux/ee.files index 5711b50a6..8dee748ae 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -586,3 +586,25 @@ ../../src/eepp/system/clock.cpp ../../src/eepp/ui/cuidefaulttheme.cpp ../../include/eepp/ui/cuidefaulttheme.hpp +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_pvr_c.h +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_pvr.h +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_pkm_c.h +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_pkm.h +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_DDS_c.h +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_DDS.h +../../src/eepp/helper/SOIL2/src/SOIL2/stb_image_write.h +../../src/eepp/helper/SOIL2/src/SOIL2/stb_image.h +../../src/eepp/helper/SOIL2/src/SOIL2/pvr_helper.h +../../src/eepp/helper/SOIL2/src/SOIL2/pkm_helper.h +../../src/eepp/helper/SOIL2/src/SOIL2/image_helper.h +../../src/eepp/helper/SOIL2/src/SOIL2/image_DXT.h +../../src/eepp/helper/SOIL2/src/SOIL2/etc1_utils.h +../../src/eepp/helper/SOIL2/src/SOIL2/SOIL2.h +../../src/eepp/helper/SOIL2/src/SOIL2/stb_image_write.c +../../src/eepp/helper/SOIL2/src/SOIL2/stb_image.c +../../src/eepp/helper/SOIL2/src/SOIL2/image_helper.c +../../src/eepp/helper/SOIL2/src/SOIL2/image_DXT.c +../../src/eepp/helper/SOIL2/src/SOIL2/etc1_utils.c +../../src/eepp/helper/SOIL2/src/SOIL2/SOIL2.c +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_ext_c.h +../../src/eepp/helper/SOIL2/src/SOIL2/stbi_ext.h diff --git a/src/eepp/graphics/ctextureloader.cpp b/src/eepp/graphics/ctextureloader.cpp index 7be31b1b4..bdabfff66 100644 --- a/src/eepp/graphics/ctextureloader.cpp +++ b/src/eepp/graphics/ctextureloader.cpp @@ -80,8 +80,8 @@ cTextureLoader::cTextureLoader( cIOStream& Stream, mSize(0), mColorKey(NULL), mTexLoaded(false), - mIsDDS(false), - mIsPVR(false), + mDirectUpload(false), + mImgType(STBI_unknown), mIsCompressed(0) { } @@ -110,8 +110,8 @@ cTextureLoader::cTextureLoader( const std::string& Filepath, mSize(0), mColorKey(NULL), mTexLoaded(false), - mIsDDS(false), - mIsPVR(false), + mDirectUpload(false), + mImgType(STBI_unknown), mIsCompressed(0) { } @@ -142,8 +142,8 @@ cTextureLoader::cTextureLoader( const unsigned char * ImagePtr, mSize(Size), mColorKey(NULL), mTexLoaded(false), - mIsDDS(false), - mIsPVR(false), + mDirectUpload(false), + mImgType(STBI_unknown), mIsCompressed(0) { } @@ -174,8 +174,8 @@ cTextureLoader::cTextureLoader( cPack * Pack, mSize(0), mColorKey(NULL), mTexLoaded(false), - mIsDDS(false), - mIsPVR(false), + mDirectUpload(false), + mImgType(STBI_unknown), mIsCompressed(0) { } @@ -209,8 +209,8 @@ cTextureLoader::cTextureLoader( const unsigned char * Pixels, mSize(0), mColorKey(NULL), mTexLoaded(false), - mIsDDS(false), - mIsPVR(false), + mDirectUpload(false), + mImgType(STBI_unknown), mIsCompressed(0) { } @@ -252,27 +252,24 @@ void cTextureLoader::LoadFile() { void cTextureLoader::LoadFromPath() { if ( FileSystem::FileExists( mFilepath ) ) { - if ( GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) - mIsDDS = 0 != stbi_dds_test_filename( mFilepath.c_str() ); + mImgType = stbi_test( mFilepath.c_str() ); - if ( !mIsDDS ) - mIsPVR = 0 != stbi_pvr_test_filename( mFilepath.c_str() ); - - if ( mIsDDS ) { + if ( STBI_dds == mImgType && GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) { LoadFile(); + mDirectUpload = true; stbi_dds_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ); - } else if ( mIsPVR ) { + } else if ( STBI_pvr == mImgType && + stbi_pvr_info_from_path( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) && + ( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) ) + { // If the PVR is valid, and the pvrtc extension is present or it's not compressed ( so it doesn't need the extension ) - // means that it can be upload directly to the GPU. - if ( stbi_pvr_info_from_path( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) && - ( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) ) - { - LoadFile(); - stbi_pvr_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ); - } else { - mIsPVR = false; - mPixels = stbi_load( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, STBI_default ); - } + // means that it can be uploaded directly to the GPU. + LoadFile(); + mDirectUpload = true; + } else if ( STBI_pkm == mImgType && GLi->IsExtension( EEGL_OES_compressed_ETC1_RGB8_texture ) ) { + LoadFile(); + mIsCompressed = mDirectUpload = true; + stbi_pkm_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels ); } else { mPixels = stbi_load( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, STBI_default ); } @@ -280,7 +277,7 @@ void cTextureLoader::LoadFromPath() { if ( NULL == mPixels ) { cLog::instance()->Write( "Filed to load: " + mFilepath + " Reason: " + std::string( stbi_failure_reason() ) ); - if ( !mIsDDS && !mIsPVR ) { + if ( STBI_jpeg == mImgType ) { mPixels = jpgd::decompress_jpeg_image_from_file( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, 3 ); if ( NULL != mPixels ) { @@ -311,26 +308,25 @@ void cTextureLoader::LoadFromPack() { } void cTextureLoader::LoadFromMemory() { - if ( GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) - mIsDDS = 0 != stbi_dds_test_memory( mImagePtr, mSize ); + mImgType = stbi_test_from_memory( mImagePtr, mSize ); - if ( !mIsDDS ) - mIsPVR = 0 != stbi_pvr_test_memory( mImagePtr, mSize ); - - if ( mIsDDS ) { + if ( STBI_dds == mImgType && GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) { mPixels = (Uint8*) eeMalloc( mSize ); memcpy( mPixels, mImagePtr, mSize ); stbi_dds_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ); - } else if ( mIsPVR ) { - if ( stbi_pvr_info_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) && - ( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) ) - { - mPixels = (Uint8*) eeMalloc( mSize ); - memcpy( mPixels, mImagePtr, mSize ); - } else { - mIsPVR = false; - mPixels = stbi_load_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, STBI_default ); - } + mDirectUpload = true; + } else if ( STBI_pvr == mImgType && + stbi_pvr_info_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) && + ( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) ) + { + mPixels = (Uint8*) eeMalloc( mSize ); + memcpy( mPixels, mImagePtr, mSize ); + mDirectUpload = true; + } else if ( STBI_pkm == mImgType && GLi->IsExtension( EEGL_OES_compressed_ETC1_RGB8_texture ) ) { + mPixels = (Uint8*) eeMalloc( mSize ); + memcpy( mPixels, mImagePtr, mSize ); + stbi_pkm_info_from_memory( mPixels, mSize, &mImgWidth, &mImgHeight, &mChannels ); + mIsCompressed = mDirectUpload = true; } else { mPixels = stbi_load_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, STBI_default ); } @@ -338,7 +334,7 @@ void cTextureLoader::LoadFromMemory() { if ( NULL == mPixels ) { cLog::instance()->Write( stbi_failure_reason() ); - if ( !mIsDDS && !mIsPVR ) { + if ( STBI_jpeg == mImgType ) { mPixels = jpgd::decompress_jpeg_image_from_memory( mImagePtr, mSize, &mImgWidth, &mImgHeight, &mChannels, 3 ); if ( NULL != mPixels ) { @@ -357,13 +353,9 @@ void cTextureLoader::LoadFromStream() { callbacks.skip = &IOCb::skip; callbacks.eof = &IOCb::eof; - if ( GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) - mIsDDS = 0 != stbi_dds_test_callbacks( &callbacks, mStream ); + mImgType = stbi_test_from_callbacks( &callbacks, mStream ); - if ( !mIsDDS ) - mIsPVR = 0 != stbi_pvr_test_callbacks( &callbacks, mStream ); - - if ( mIsDDS ) { + if ( STBI_dds == mImgType && GLi->IsExtension( EEGL_EXT_texture_compression_s3tc ) ) { mSize = mStream->GetSize(); mPixels = (Uint8*) eeMalloc( mSize ); mStream->Seek( 0 ); @@ -371,23 +363,26 @@ void cTextureLoader::LoadFromStream() { mStream->Seek( 0 ); stbi_dds_info_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ); mStream->Seek( 0 ); - } else if ( mIsPVR ) { - // If the PVR is valid, and the pvrtc extension is present or it's not compressed ( so it doesn't need the extension ) - // means that it can be upload directly to the GPU. - if ( stbi_pvr_info_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) && - ( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) ) - { - mSize = mStream->GetSize(); - mPixels = (Uint8*) eeMalloc( mSize ); - mStream->Seek( 0 ); - mStream->Read( reinterpret_cast ( mPixels ), mSize ); - mStream->Seek( 0 ); - } else { - mIsPVR = false; - mPixels = stbi_load( mFilepath.c_str(), &mImgWidth, &mImgHeight, &mChannels, STBI_default ); - } - + mDirectUpload = true; + } else if ( STBI_pvr == mImgType && + stbi_pvr_info_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels, &mIsCompressed ) && + ( !mIsCompressed || GLi->IsExtension( EEGL_IMG_texture_compression_pvrtc ) ) ) + { + mSize = mStream->GetSize(); + mPixels = (Uint8*) eeMalloc( mSize ); mStream->Seek( 0 ); + mStream->Read( reinterpret_cast ( mPixels ), mSize ); + mStream->Seek( 0 ); + mDirectUpload = true; + } else if ( STBI_pkm == mImgType && GLi->IsExtension( EEGL_OES_compressed_ETC1_RGB8_texture ) ) { + mSize = mStream->GetSize(); + mPixels = (Uint8*) eeMalloc( mSize ); + mStream->Seek( 0 ); + mStream->Read( reinterpret_cast ( mPixels ), mSize ); + mStream->Seek( 0 ); + stbi_pkm_info_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels ); + mStream->Seek( 0 ); + mIsCompressed = mDirectUpload = true; } else { mStream->Seek( 0 ); mPixels = stbi_load_from_callbacks( &callbacks, mStream, &mImgWidth, &mImgHeight, &mChannels, STBI_default ); @@ -397,7 +392,7 @@ void cTextureLoader::LoadFromStream() { if ( NULL == mPixels ) { cLog::instance()->Write( stbi_failure_reason() ); - if ( !mIsDDS && !mIsPVR ) { + if ( STBI_jpeg == mImgType ) { jpeg::jpeg_decoder_stream_steam stream( mStream ); mPixels = jpgd::decompress_jpeg_image_from_stream( &stream, &mImgWidth, &mImgHeight, &mChannels, 3 ); @@ -412,8 +407,8 @@ void cTextureLoader::LoadFromPixels() { Uint32 tTexId = 0; if ( NULL != mPixels ) { - int width = mImgWidth; - int height = mImgHeight; + int width = mImgWidth; + int height = mImgHeight; Uint32 flags = mMipmap ? SOIL_FLAG_MIPMAPS : 0; @@ -423,22 +418,37 @@ void cTextureLoader::LoadFromPixels() { GLint PreviousTexture; glGetIntegerv(GL_TEXTURE_BINDING_2D, &PreviousTexture); - if ( mIsDDS ) { - tTexId = SOIL_direct_load_DDS_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags, 0 ); - } else if ( mIsPVR ) { - tTexId = SOIL_direct_load_PVR_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags, 0 ); + if ( mDirectUpload ) { + if ( STBI_dds == mImgType ) { + tTexId = SOIL_direct_load_DDS_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags, 0 ); + } else if ( STBI_pvr == mImgType ) { + tTexId = SOIL_direct_load_PVR_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags, 0 ); + } else if ( STBI_pkm == mImgType ) { + tTexId = SOIL_direct_load_ETC1_from_memory( mPixels, mSize, SOIL_CREATE_NEW_ID, flags ); + } } else { tTexId = SOIL_create_OGL_texture( mPixels, &width, &height, mChannels, SOIL_CREATE_NEW_ID, flags ); } - glBindTexture(GL_TEXTURE_2D, PreviousTexture); + glBindTexture( GL_TEXTURE_2D, PreviousTexture ); if ( tTexId ) { - if ( mIsDDS && mIsCompressed && mSize > 128 ) { - mSize -= 128; // Remove the header size + mWidth = width; + mHeight = height; + + if ( STBI_dds == mImgType ) { + if ( mIsCompressed && mSize > 128 ) { + mSize -= 128; // Remove the DDS header size + } + } else if ( STBI_pvr == mImgType ) { + if ( mIsCompressed && mSize > 52 ) { + mSize -= 52; // Remove the PVR header size + } + } else if ( STBI_pkm == mImgType ) { + if ( mIsCompressed && mSize > 16 ) { + mSize -= 16; // Remove the PKM header size + } } else { - mWidth = width; - mHeight = height; mSize = mWidth * mHeight * mChannels; } @@ -453,11 +463,10 @@ void cTextureLoader::LoadFromPixels() { } if ( TEX_LT_PIXELS != mLoadType ) { - if ( mIsDDS || mIsPVR ) { + if ( mDirectUpload ) { eeFree( mPixels ); - } else { - if ( mPixels ) - free( mPixels ); + } else if ( NULL != mPixels ) { + free( mPixels ); } } @@ -523,8 +532,8 @@ void cTextureLoader::Reset() { mChannels = 0; mSize = 0; mTexLoaded = false; - mIsDDS = false; - mIsPVR = false; + mDirectUpload = false; + mImgType = STBI_unknown; mIsCompressed = 0; } diff --git a/src/eepp/helper/android/openal-soft/config.h b/src/eepp/helper/android/openal-soft/config.h index 60acd23e6..a9ccac41f 100644 --- a/src/eepp/helper/android/openal-soft/config.h +++ b/src/eepp/helper/android/openal-soft/config.h @@ -111,7 +111,7 @@ #define HAVE_MALLOC_H /* Define if we have cpuid.h */ -#define HAVE_CPUID_H +/* #define HAVE_CPUID_H */ /* Define if we have guiddef.h */ /* #undef HAVE_GUIDDEF_H */ diff --git a/src/eepp/system/sys.cpp b/src/eepp/system/sys.cpp index a900a5731..057c4efbd 100644 --- a/src/eepp/system/sys.cpp +++ b/src/eepp/system/sys.cpp @@ -443,7 +443,7 @@ static std::string sGetProcessPath() { return FileRemoveFileName( std::string( info.name ) ); #elif EE_PLATFORM == EE_PLATFORM_ANDROID - if ( NULL != Window::cEngine::instance() ) + if ( NULL != Window::cEngine::instance() && NULL != Window::cEngine::instance()->GetCurrentWindow() ) return Window::cEngine::instance()->GetCurrentWindow()->GetExternalStoragePath(); return "/sdcard/"; diff --git a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp index 33a30a3de..f91c24e26 100644 --- a/src/eepp/window/backend/SDL2/cwindowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/cwindowsdl2.cpp @@ -215,8 +215,6 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { mCursorManager->Set( Cursor::SYS_CURSOR_DEFAULT ); - LogSuccessfulInit( GetVersion() ); - #if EE_PLATFORM == EE_PLATFORM_ANDROID std::string apkPath( SDL_AndroidGetApkPath() ); @@ -226,6 +224,10 @@ bool cWindowSDL::Create( WindowSettings Settings, ContextSettings Context ) { cLog::instance()->Write( "APK opened succesfully!" ); else cLog::instance()->Write( "Failed to open APK!" ); + + LogSuccessfulInit( GetVersion(), apkPath ); + #else + LogSuccessfulInit( GetVersion() ); #endif return true; diff --git a/src/eepp/window/cinput.cpp b/src/eepp/window/cinput.cpp index 0c65ddffa..0b627a5ed 100644 --- a/src/eepp/window/cinput.cpp +++ b/src/eepp/window/cinput.cpp @@ -49,7 +49,7 @@ void cInput::ProcessEvent( InputEvent * Event ) { if ( Event->key.keysym.mod != eeINDEX_NOT_FOUND ) mInputMod = Event->key.keysym.mod; - PushKey( &mKeysDown [ Event->key.keysym.sym / 8 ], Event->key.keysym.sym % 8, true ); + BitOp::WriteBitKey( &mKeysDown [ Event->key.keysym.sym / 8 ], Event->key.keysym.sym % 8, 1 ); break; } case InputEvent::KeyUp: @@ -57,8 +57,8 @@ void cInput::ProcessEvent( InputEvent * Event ) { if ( Event->key.keysym.sym > EE_KEYS_NUM ) break; - PushKey( &mKeysDown [ Event->key.keysym.sym / 8 ], Event->key.keysym.sym % 8, false ); - PushKey( &mKeysUp [ Event->key.keysym.sym / 8 ], Event->key.keysym.sym % 8, true ); + BitOp::WriteBitKey( &mKeysDown [ Event->key.keysym.sym / 8 ], Event->key.keysym.sym % 8, 0 ); + BitOp::WriteBitKey( &mKeysUp [ Event->key.keysym.sym / 8 ], Event->key.keysym.sym % 8, 1 ); break; } case InputEvent::MouseMotion: @@ -244,36 +244,20 @@ void cInput::ResetFingerWasDown() { } } -bool cInput::GetKey( Uint8 * Key, Uint8 Pos ) { - if ( ( * Key ) & ( 1 << Pos ) ) - return true; - - return false; -} - -void cInput::PushKey( Uint8 * Key, Uint8 Pos, bool BitWrite ) { - if ( BitWrite ) - ( * Key ) |= ( 1 << Pos ); - else { - if ( ( * Key ) & ( 1 << Pos ) ) - ( * Key ) &= ~( 1 << Pos ); - } -} - bool cInput::IsKeyDown( const EE_KEY& Key ) { - return GetKey( &mKeysDown[ Key / 8 ], Key % 8 ); + return 0 != BitOp::ReadBitKey( &mKeysDown[ Key / 8 ], Key % 8 ); } bool cInput::IsKeyUp( const EE_KEY& Key ) { - return GetKey( &mKeysUp[ Key / 8 ], Key % 8 ); + return 0 != BitOp::ReadBitKey( &mKeysUp[ Key / 8 ], Key % 8 ); } void cInput::InjectKeyDown( const EE_KEY& Key ) { - PushKey( &mKeysDown [ Key / 8 ], Key % 8, true ); + BitOp::WriteBitKey( &mKeysDown [ Key / 8 ], Key % 8, 1 ); } void cInput::InjectKeyUp( const EE_KEY& Key ) { - PushKey( &mKeysUp [ Key / 8 ], Key % 8, true ); + BitOp::WriteBitKey( &mKeysUp [ Key / 8 ], Key % 8, 1 ); } void cInput::InjectButtonPress( const Uint32& Button ) { diff --git a/src/eepp/window/cwindow.cpp b/src/eepp/window/cwindow.cpp index 0733003ce..0837080a0 100644 --- a/src/eepp/window/cwindow.cpp +++ b/src/eepp/window/cwindow.cpp @@ -375,12 +375,12 @@ void cWindow::SendVideoResizeCb() { } } -void cWindow::LogSuccessfulInit( const std::string& BackendName ) { +void cWindow::LogSuccessfulInit(const std::string& BackendName , const std::string&ProcessPath ) { cLog::instance()->Write( "Engine Initialized Succesfully.\n\tVersion: " + Version::GetVersionName() + " (codename: \"" + Version::GetCodename() + "\")" + "\n\tOS: " + Sys::GetOSName() + "\n\tArch: " + Sys::GetOSArchitecture() + "\n\tCPU Cores: " + String::ToStr( Sys::GetCPUCount() ) + - "\n\tProcess Path: " + Sys::GetProcessPath() + + "\n\tProcess Path: " + ( !ProcessPath.empty() ? ProcessPath : Sys::GetProcessPath() ) + "\n\tDisk Free Space: " + String::ToStr( FileSystem::SizeToString( Sys::GetDiskFreeSpace( Sys::GetProcessPath() ) ) ) + "\n\tWindow/Input Backend: " + BackendName + "\n\tGL Backend: " + GLi->VersionStr() +