From 7cd2d4809c3579614c397372467aa57fdc816058 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 4 Aug 2014 19:50:53 +0400 Subject: [PATCH] android-build --- components/files/linuxpath.cpp | 41 +++++++++++++++++++++++------ components/files/linuxpath.hpp | 1 - components/ogreinit/ogreinit.cpp | 28 ++++++++++++++++---- components/ogreinit/ogreinit.hpp | 13 ++++++++- extern/sdl4ogre/sdlwindowhelper.cpp | 25 +++++++++++++++--- libs/openengine/gui/manager.cpp | 2 +- libs/openengine/ogre/renderer.cpp | 2 +- 7 files changed, 92 insertions(+), 20 deletions(-) diff --git a/components/files/linuxpath.cpp b/components/files/linuxpath.cpp index d285f4229..aa0f20a68 100644 --- a/components/files/linuxpath.cpp +++ b/components/files/linuxpath.cpp @@ -7,7 +7,11 @@ #include #include #include - +/*bool flag=false; + #ifdef ENABLE_PLUGIN_GLES2 + flag=true; +#endif +*/ namespace { @@ -54,23 +58,40 @@ LinuxPath::LinuxPath(const std::string& application_name) boost::filesystem::path LinuxPath::getUserConfigPath() const { - return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName; +//if (flag==false) + // return getEnv("XDG_CONFIG_HOME", getUserHome() / ".config") / mName; +//else + return getEnv("XDG_CONFIG_HOME", "/sdcard/morrowind/config") / mName; + } boost::filesystem::path LinuxPath::getUserDataPath() const { - return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName; +//if (flag==false) + // return getEnv("XDG_DATA_HOME", getUserHome() / ".local/share") / mName; +//else + return getEnv("XDG_DATA_HOME", "/sdcard/morrowind/share") / mName; + + } boost::filesystem::path LinuxPath::getCachePath() const { - return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName; +//if (flag==false) + // return getEnv("XDG_CACHE_HOME", getUserHome() / ".cache") / mName; +//else + return getEnv("XDG_CACHE_HOME", "/sdcard/morrowind/cache") / mName; + } boost::filesystem::path LinuxPath::getGlobalConfigPath() const { - boost::filesystem::path globalPath("/etc/"); - return globalPath / mName; +//if (flag==false) + // boost::filesystem::path globalPath("/etc/"); +//else + boost::filesystem::path globalPath("/sdcard/morrowind/"); + +return globalPath / mName; } boost::filesystem::path LinuxPath::getLocalPath() const @@ -80,8 +101,12 @@ boost::filesystem::path LinuxPath::getLocalPath() const boost::filesystem::path LinuxPath::getGlobalDataPath() const { - boost::filesystem::path globalDataPath("/usr/share/games/"); - return globalDataPath / mName; +//if (flag==false) + // boost::filesystem::path globalDataPath("/usr/share/games/"); +//else + boost::filesystem::path globalDataPath("/sdcard/morrowind/data"); + +return globalDataPath / mName; } boost::filesystem::path LinuxPath::getInstallPath() const diff --git a/components/files/linuxpath.hpp b/components/files/linuxpath.hpp index b710165b4..cde29a7b2 100644 --- a/components/files/linuxpath.hpp +++ b/components/files/linuxpath.hpp @@ -4,7 +4,6 @@ #if defined(__linux__) || defined(__FreeBSD__) #include - /** * \namespace Files */ diff --git a/components/ogreinit/ogreinit.cpp b/components/ogreinit/ogreinit.cpp index 515c0875a..3a6902084 100644 --- a/components/ogreinit/ogreinit.cpp +++ b/components/ogreinit/ogreinit.cpp @@ -22,6 +22,7 @@ #include "ogreplugin.hpp" + namespace bfs = boost::filesystem; namespace @@ -82,13 +83,20 @@ namespace OgreInit #ifdef ENABLE_PLUGIN_GL , mGLPlugin(NULL) #endif - #ifdef ENABLE_PLUGIN_Direct3D9 + #ifdef ENABLE_PLUGIN_GLES2 + , mGLES2Plugin(NULL) + #endif + + #ifdef ENABLE_PLUGIN_Direct3D9 , mD3D9Plugin(NULL) #endif {} Ogre::Root* OgreInit::init(const std::string &logPath) { +/* + if (flag1==false) + { // Set up logging first new Ogre::LogManager; Ogre::Log *log = Ogre::LogManager::getSingleton().createLog(logPath); @@ -100,10 +108,10 @@ namespace OgreInit // Disable logging to cout/cerr log->setDebugOutputEnabled(false); - + }*/ mRoot = new Ogre::Root("", "", ""); - #if defined(ENABLE_PLUGIN_GL) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) + #if defined(ENABLE_PLUGIN_GL) || (ENABLE_PLUGIN_GLES2) || defined(ENABLE_PLUGIN_Direct3D9) || defined(ENABLE_PLUGIN_CgProgramManager) || defined(ENABLE_PLUGIN_OctreeSceneManager) || defined(ENABLE_PLUGIN_ParticleFX) loadStaticPlugins(); #else loadPlugins(); @@ -133,7 +141,12 @@ namespace OgreInit delete mGLPlugin; mGLPlugin = NULL; #endif - #ifdef ENABLE_PLUGIN_Direct3D9 + #ifdef ENABLE_PLUGIN_GLES2 + delete mGLES2Plugin; + mGLES2Plugin = NULL; + #endif + + #ifdef ENABLE_PLUGIN_Direct3D9 delete mD3D9Plugin; mD3D9Plugin = NULL; #endif @@ -157,7 +170,12 @@ namespace OgreInit mGLPlugin = new Ogre::GLPlugin(); mRoot->installPlugin(mGLPlugin); #endif - #ifdef ENABLE_PLUGIN_Direct3D9 + #ifdef ENABLE_PLUGIN_GLES2 + mGLES2Plugin = new Ogre::GLES2Plugin(); + mRoot->installPlugin(mGLES2Plugin); + #endif + + #ifdef ENABLE_PLUGIN_Direct3D9 mD3D9Plugin = new Ogre::D3D9Plugin(); mRoot->installPlugin(mD3D9Plugin); #endif diff --git a/components/ogreinit/ogreinit.hpp b/components/ogreinit/ogreinit.hpp index b6fe4631a..9e6ad2058 100644 --- a/components/ogreinit/ogreinit.hpp +++ b/components/ogreinit/ogreinit.hpp @@ -17,6 +17,11 @@ #ifdef ENABLE_PLUGIN_GL # include "OgreGLPlugin.h" #endif + +#ifdef ENABLE_PLUGIN_GLES2 +# include "OgreGLES2Plugin.h" +#endif + #ifdef ENABLE_PLUGIN_Direct3D9 # include "OgreD3D9Plugin.h" #endif @@ -51,6 +56,8 @@ namespace OgreInit void loadStaticPlugins(); void loadPlugins(); void loadParticleFactories(); +//bool flag1=false; + #ifdef ENABLE_PLUGIN_CgProgramManager @@ -65,7 +72,11 @@ namespace OgreInit #ifdef ENABLE_PLUGIN_GL Ogre::GLPlugin* mGLPlugin; #endif - #ifdef ENABLE_PLUGIN_Direct3D9 + #ifdef ENABLE_PLUGIN_GLES2 + Ogre::GLES2Plugin* mGLES2Plugin; + #endif + + #ifdef ENABLE_PLUGIN_Direct3D9 Ogre::D3D9Plugin* mD3D9Plugin; #endif diff --git a/extern/sdl4ogre/sdlwindowhelper.cpp b/extern/sdl4ogre/sdlwindowhelper.cpp index 3ea39cff7..eaf6e8d22 100644 --- a/extern/sdl4ogre/sdlwindowhelper.cpp +++ b/extern/sdl4ogre/sdlwindowhelper.cpp @@ -10,6 +10,7 @@ #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE #include "osx_utils.h" #endif +bool flag1=false; namespace SFO { @@ -26,6 +27,7 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, throw std::runtime_error("Couldn't get WM Info!"); Ogre::String winHandle; + Ogre::String winHandleSurface; switch (wmInfo.subsystem) { @@ -43,10 +45,21 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, winHandle = Ogre::StringConverter::toString(WindowContentViewHandle(wmInfo)); break; #else - case SDL_SYSWM_X11: - winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.x11.window); + case SDL_SYSWM_ANDROID: + winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.android.window); + winHandleSurface = Ogre::StringConverter::toString((unsigned long)wmInfo.info.android.surface); + flag1=true; break; + if (flag1==false) +{ + //case SDL_SYSWM_X11: + // winHandle = Ogre::StringConverter::toString((unsigned long)wmInfo.info.x11.window); + // break; +} #endif + + + default: throw std::runtime_error("Unexpected WM!"); break; @@ -54,8 +67,14 @@ SDLWindowHelper::SDLWindowHelper (SDL_Window* window, int w, int h, /// \todo externalWindowHandle is deprecated according to the source code. Figure out a way to get parentWindowHandle /// to work properly. On Linux/X11 it causes an occasional GLXBadDrawable error. - params.insert(std::make_pair("externalWindowHandle", winHandle)); +if (flag1==false) +params.insert(std::make_pair("externalWindowHandle", winHandle)); +else +{ +params.insert(std::make_pair("externalWindowHandle", winHandle)); +params.insert(std::make_pair("externalSurface", winHandleSurface)); +} mWindow = Ogre::Root::getSingleton().createRenderWindow(title, w, h, fullscreen, ¶ms); } diff --git a/libs/openengine/gui/manager.cpp b/libs/openengine/gui/manager.cpp index 028192e9f..4c48ffbc7 100644 --- a/libs/openengine/gui/manager.cpp +++ b/libs/openengine/gui/manager.cpp @@ -653,7 +653,7 @@ void MyGUIManager::updateWindow (Ogre::RenderWindow *wnd) void MyGUIManager::windowResized() { - mRenderManager->setActiveViewport(0); + // mRenderManager->setActiveViewport(0); } void MyGUIManager::shutdown() diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 8fcf615ba..ca30096e7 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -138,7 +138,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings& settings.window_x, // width, in pixels settings.window_y, // height, in pixels SDL_WINDOW_SHOWN - | (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0) | SDL_WINDOW_RESIZABLE + | (settings.fullscreen ? SDL_WINDOW_FULLSCREEN : 0) | SDL_WINDOW_RESIZABLE ); SFO::SDLWindowHelper helper(mSDLWindow, settings.window_x, settings.window_y, title, settings.fullscreen, params);