- Fix Android compilation issues

- Added a "cachesize" option (not available from the menu, but can be manually edited in players/options.txt, for example cachesize=200 means 200MB of cache). The hardcoded cache on windows/linux is 20MB, which is not enough for Hi Res cards (60 is better, 200 is great)
This commit is contained in:
wagic.the.homebrew
2011-10-02 09:05:39 +00:00
parent 9e572ee416
commit 3decbe7f1d
5 changed files with 16 additions and 12 deletions

View File

@@ -133,7 +133,6 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
$(MTG_PATH)/src/WFont.cpp \
$(MTG_PATH)/src/WGui.cpp \
$(MTG_PATH)/src/WResourceManager.cpp \
$(MTG_PATH)/src/NetworkPlayer.cpp \
$(JGE_PATH)/src/SDLmain.cpp \
$(JGE_PATH)/src/Encoding.cpp \
$(JGE_PATH)/src/JAnimator.cpp \

View File

@@ -25,7 +25,7 @@ public:
bool tryToUnlock(GameObserver * game);
static void load();
static map <string, Unlockable *> unlockables;
static void Unlockable::Destroy();
static void Destroy();
};

View File

@@ -10,7 +10,7 @@
#include "JLogger.h"
#include <sstream>
#define HUGE_CACHE_LIMIT 20000000 // Size of the cache for Windows and Linux
#define HUGE_CACHE_LIMIT 20000000 // Size of the cache for Windows and Linux (in bytes)
#define SAMPLES_CACHE_SIZE 1500000 // Size in bytes of the cached samples
#define PSI_CACHE_SIZE 500000 // Size in bytes of the cached particles
#define TEXTURES_CACHE_MINSIZE 2000000 // Minimum size of the cache on the PSP. The program should complain if the cache ever gets smaller than this

View File

@@ -96,8 +96,6 @@ void GameApp::Create()
//_CrtSetBreakAlloc(368);
LOG("starting Game");
WResourceManager::Instance()->ResetCacheLimits();
string systemFolder = "Res/";
string foldersRoot = "";
@@ -149,6 +147,11 @@ void GameApp::Create()
LOG("options.reloadProfile()");
options.reloadProfile();
//Setup Cache before calling any gfx/sfx functions
WResourceManager::Instance()->ResetCacheLimits();
LOG("Checking for music files");
//Test for Music files presence
JFileSystem * jfs = JFileSystem::GetInstance();

View File

@@ -894,13 +894,7 @@ void ResourceManagerImpl::RemoveWFonts()
void ResourceManagerImpl::ResetCacheLimits()
{
#if defined WIN32 || defined LINUX || defined (IOS)
#ifdef FORCE_LOW_CACHE_MEMORY
textureWCache.Resize(kConstrainedCacheLimit, MAX_CACHE_OBJECTS);
#else
textureWCache.Resize(HUGE_CACHE_LIMIT,MAX_CACHE_OBJECTS);
#endif
#else
#if defined PSP
unsigned int ram = ramAvailable();
unsigned int myNewSize = ram - OPERATIONAL_SIZE + textureWCache.totalSize;
if (myNewSize < TEXTURES_CACHE_MINSIZE)
@@ -908,6 +902,14 @@ void ResourceManagerImpl::ResetCacheLimits()
DebugTrace( "Error, Not enough RAM for Cache: " << myNewSize << " - total Ram: " << ram);
}
textureWCache.Resize(MIN(myNewSize, HUGE_CACHE_LIMIT), MAX_CACHE_OBJECTS);
#else
#ifdef FORCE_LOW_CACHE_MEMORY
textureWCache.Resize(kConstrainedCacheLimit, MAX_CACHE_OBJECTS);
#else
unsigned long cacheSize = options["cachesize"].number ? (unsigned long)(options["cachesize"].number) * 1024 * 1024 : HUGE_CACHE_LIMIT;
textureWCache.Resize(cacheSize,MAX_CACHE_OBJECTS);
#endif
#endif
return;
}