mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-02 11:36:30 +03:00
Changed the texture loader, added ETC1 support.
Some minor changes to Android port. And other minor changes.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 <typename T>
|
||||
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 <typename T>
|
||||
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 <typename T>
|
||||
static inline void SetBitFlagValue( T * Key, Uint32 Val, Uint32 BitWrite ) {
|
||||
( BitWrite ) ? ( * Key ) |= Val : ( * Key ) &= ~Val;
|
||||
}
|
||||
|
||||
|
||||
@@ -212,10 +212,6 @@ class EE_API cInput {
|
||||
|
||||
std::map<Uint32, InputCallback> mCallbacks;
|
||||
|
||||
bool GetKey( Uint8 * Key, Uint8 Pos );
|
||||
|
||||
void PushKey( Uint8 * Key, Uint8 Pos, bool BitWrite );
|
||||
|
||||
void ProcessEvent( InputEvent * Event );
|
||||
|
||||
cInputFinger * GetFingerId( const Int64& fingerId );
|
||||
|
||||
@@ -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 );
|
||||
};
|
||||
|
||||
@@ -18,5 +18,5 @@
|
||||
|
||||
<supports-screens android:anyDensity="true" />
|
||||
|
||||
<uses-sdk android:minSdkVersion="7" />
|
||||
<uses-sdk android:minSdkVersion="9" />
|
||||
</manifest>
|
||||
|
||||
@@ -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 )
|
||||
|
||||
3
projects/android-project/assets.sh
Executable file
3
projects/android-project/assets.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
adb push ../../assets /sdcard/assets
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
adb push data /sdcard/data
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by Qt Creator 2.6.1, 2013-01-26T03:04:03. -->
|
||||
<!-- Written by QtCreator 2.7.0, 2013-04-29T17:01:39. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
@@ -13,7 +13,7 @@
|
||||
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
|
||||
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
|
||||
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
|
||||
<value type="QString" key="language">Cpp</value>
|
||||
<value type="QByteArray" key="language">Cpp</value>
|
||||
<valuemap type="QVariantMap" key="value">
|
||||
<value type="QString" key="CurrentPreferences">CppGlobal</value>
|
||||
</valuemap>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<char*> ( 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<char*> ( 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<char*> ( 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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/";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
@@ -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() +
|
||||
|
||||
Reference in New Issue
Block a user