[Orxonox-commit 3269] r7960 - in code/branches/kicklib: cmake/tools src src/external src/libraries/core src/libraries/util
rgrieder at orxonox.net
rgrieder at orxonox.net
Fri Feb 25 03:07:17 CET 2011
Author: rgrieder
Date: 2011-02-25 03:07:17 +0100 (Fri, 25 Feb 2011)
New Revision: 7960
Modified:
code/branches/kicklib/cmake/tools/FindCEGUI.cmake
code/branches/kicklib/src/CMakeLists.txt
code/branches/kicklib/src/external/CMakeLists.txt
code/branches/kicklib/src/libraries/core/CMakeLists.txt
code/branches/kicklib/src/libraries/core/CorePrereqs.h
code/branches/kicklib/src/libraries/core/GUIManager.cc
code/branches/kicklib/src/libraries/core/GUIManager.h
code/branches/kicklib/src/libraries/util/Exception.cc
Log:
Applied C++ code changes to compile Orxonox with CEGUI 0.7 (does not run yet).
Modified: code/branches/kicklib/cmake/tools/FindCEGUI.cmake
===================================================================
--- code/branches/kicklib/cmake/tools/FindCEGUI.cmake 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/cmake/tools/FindCEGUI.cmake 2011-02-25 02:07:17 UTC (rev 7960)
@@ -25,15 +25,21 @@
# Version checking and CEGUILua finding by Reto Grieder
# > www.orxonox.net <
+INCLUDE(CompareVersionStrings)
INCLUDE(DetermineVersion)
INCLUDE(FindPackageHandleAdvancedArgs)
INCLUDE(HandleLibraryTypes)
-# Find CEGUI library
+# Find headers
FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h
PATHS $ENV{CEGUIDIR}
PATH_SUFFIXES include include/CEGUI CEGUI.framework/Headers
)
+
+# Inspect CEGUIVersion.h for the version number
+DETERMINE_VERSION(CEGUI ${CEGUI_INCLUDE_DIR}/CEGUIVersion.h)
+
+# Find CEGUI library
FIND_LIBRARY(CEGUI_LIBRARY_OPTIMIZED
NAMES CEGUIBase CEGUI
PATHS $ENV{CEGUIDIR}
@@ -71,8 +77,24 @@
PATH_SUFFIXES lib bin
)
-# Inspect CEGUIVersion.h for the version number
-DETERMINE_VERSION(CEGUI ${CEGUI_INCLUDE_DIR}/CEGUIVersion.h)
+# Newer versions of CEGUI have the renderer for OGRE shipped with them
+COMPARE_VERSION_STRINGS("${CEGUI_VERSION}" "0.7" _version_compare TRUE)
+IF(_version_compare GREATER -1)
+ # Find CEGUI OGRE Renderer libraries
+ FIND_LIBRARY(CEGUI_OGRE_RENDERER_LIBRARY_OPTIMIZED
+ NAMES CEGUIOgreRenderer
+ PATHS $ENV{CEGUIDIR}
+ PATH_SUFFIXES lib bin
+ )
+ FIND_LIBRARY(CEGUI_OGRE_RENDERER_LIBRARY_DEBUG
+ NAMES CEGUIOgreRendererd CEGUIOgreRenderer_d
+ PATHS $ENV{CEGUIDIR}
+ PATH_SUFFIXES lib bin
+ )
+ SET(CEGUI_OGRE_RENDERER_LIBRARY_NAME CEGUI_OGRE_RENDERER_LIBRARY_OPTIMIZED)
+ELSE()
+ SET(CEGUI_OGRE_RENDERER_BUILD_REQUIRED TRUE)
+ENDIF()
# Handle the REQUIRED argument and set CEGUI_FOUND
# Also checks the version requirements if given
@@ -81,12 +103,16 @@
CEGUI_LIBRARY_OPTIMIZED
CEGUILUA_LIBRARY_OPTIMIZED
CEGUI_TOLUA_LIBRARY_OPTIMIZED
+ ${CEGUI_OGRE_RENDERER_LIBRARY_NAME}
)
# Collect optimized and debug libraries
HANDLE_LIBRARY_TYPES(CEGUI)
HANDLE_LIBRARY_TYPES(CEGUILUA)
HANDLE_LIBRARY_TYPES(CEGUI_TOLUA)
+IF(NOT CEGUI_OGRE_RENDERER_BUILD_REQUIRED)
+ HANDLE_LIBRARY_TYPES(CEGUI_OGRE_RENDERER)
+ENDIF()
MARK_AS_ADVANCED(
CEGUI_INCLUDE_DIR
@@ -96,4 +122,6 @@
CEGUILUA_LIBRARY_DEBUG
CEGUI_TOLUA_LIBRARY_OPTIMIZED
CEGUI_TOLUA_LIBRARY_DEBUG
+ CEGUI_OGRE_RENDERER_LIBRARY_OPTIMIZED
+ CEGUI_OGRE_RENDERER_LIBRARY_DEBUG
)
Modified: code/branches/kicklib/src/CMakeLists.txt
===================================================================
--- code/branches/kicklib/src/CMakeLists.txt 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/src/CMakeLists.txt 2011-02-25 02:07:17 UTC (rev 7960)
@@ -98,6 +98,12 @@
INCLUDE_DIRECTORIES(${DBGHELP_INCLUDE_DIR})
ENDIF()
+############## CEGUI OGRE Renderer ##############
+
+IF(CEGUI_OGRE_RENDERER_BUILD_REQUIRED)
+ SET(CEGUI_OGRE_RENDERER_LIBRARY ogreceguirenderer_orxonox)
+ENDIF()
+
################### Tolua Bind ##################
# Create directory because the tolua application doesn't work otherwise
Modified: code/branches/kicklib/src/external/CMakeLists.txt
===================================================================
--- code/branches/kicklib/src/external/CMakeLists.txt 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/src/external/CMakeLists.txt 2011-02-25 02:07:17 UTC (rev 7960)
@@ -24,6 +24,8 @@
ADD_SUBDIRECTORY(cpptcl)
ADD_SUBDIRECTORY(enet)
ADD_SUBDIRECTORY(loki)
-ADD_SUBDIRECTORY(ogreceguirenderer)
+IF(CEGUI_OGRE_RENDERER_BUILD_REQUIRED)
+ ADD_SUBDIRECTORY(ogreceguirenderer)
+ENDIF()
ADD_SUBDIRECTORY(ois)
ADD_SUBDIRECTORY(tinyxml)
Modified: code/branches/kicklib/src/libraries/core/CMakeLists.txt
===================================================================
--- code/branches/kicklib/src/libraries/core/CMakeLists.txt 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/src/libraries/core/CMakeLists.txt 2011-02-25 02:07:17 UTC (rev 7960)
@@ -92,9 +92,9 @@
${CEGUI_LIBRARY}
${CEGUILUA_LIBRARY}
${CEGUI_TOLUA_LIBRARY}
+ ${CEGUI_OGRE_RENDERER_LIBRARY}
${LUA5.1_LIBRARY}
cpptcl_orxonox
- ogreceguirenderer_orxonox
ois_orxonox
tinyxml_orxonox
util
Modified: code/branches/kicklib/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/kicklib/src/libraries/core/CorePrereqs.h 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/src/libraries/core/CorePrereqs.h 2011-02-25 02:07:17 UTC (rev 7960)
@@ -37,6 +37,7 @@
#include "OrxonoxConfig.h"
#include <boost/version.hpp>
+#include <CEGUIVersion.h>
//-----------------------------------------------------------------------
// Shared library settings
@@ -304,9 +305,15 @@
class Logger;
class LuaScriptModule;
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
class OgreCEGUIRenderer;
class OgreCEGUIResourceProvider;
class OgreCEGUITexture;
+#else
+ class OgreRenderer;
+ class OgreResourceProvider;
+ class OgreImageCodec;
+#endif
}
// Lua
Modified: code/branches/kicklib/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/kicklib/src/libraries/core/GUIManager.cc 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/src/libraries/core/GUIManager.cc 2011-02-25 02:07:17 UTC (rev 7960)
@@ -31,6 +31,8 @@
#include <memory>
#include <boost/bind.hpp>
+#include <OgreRenderQueue.h>
+#include <OgreRenderWindow.h>
#include <CEGUIDefaultLogger.h>
#include <CEGUIExceptions.h>
@@ -43,8 +45,15 @@
#include <elements/CEGUIListbox.h>
#include <elements/CEGUIListboxItem.h>
-#include <CEGUILua.h>
-#include <ogreceguirenderer/OgreCEGUIRenderer.h>
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
+# include <CEGUILua.h>
+# include <ogreceguirenderer/OgreCEGUIRenderer.h>
+#else
+# include <ScriptingModules/LuaScriptModule/CEGUILua.h>
+# include <RendererModules/Ogre/CEGUIOgreImageCodec.h>
+# include <RendererModules/Ogre/CEGUIOgreRenderer.h>
+# include <RendererModules/Ogre/CEGUIOgreResourceProvider.h>
+#endif
#include "util/Clock.h"
#include "util/Convert.h"
@@ -117,6 +126,9 @@
, scriptModule_(NULL)
, guiSystem_(NULL)
, resourceProvider_(NULL)
+#if CEGUI_VERSION_MAJOR >= 1 || CEGUI_VERSION_MINOR >= 7
+ , imageCodec_(NULL)
+#endif
, camera_(NULL)
{
RegisterRootObject(GUIManager);
@@ -127,8 +139,14 @@
COUT(3) << "Initialising CEGUI." << std::endl;
// Note: No SceneManager specified yet
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
guiRenderer_ = new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000);
resourceProvider_ = guiRenderer_->createResourceProvider();
+#else
+ guiRenderer_ = &OgreRenderer::create(*GraphicsManager::getInstance().getRenderWindow());
+ resourceProvider_ = &OgreRenderer::createOgreResourceProvider();
+ imageCodec_ = &OgreRenderer::createOgreImageCodec();
+#endif
resourceProvider_->setDefaultResourceGroup("General");
// Setup scripting
@@ -136,7 +154,11 @@
rootFileInfo_ = Resource::getInfo("InitialiseGUI.lua");
// This is necessary to ensure that input events also use the right resource info when triggering lua functions
luaState_->setDefaultResourceInfo(this->rootFileInfo_);
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
scriptModule_ = new LuaScriptModule(luaState_->getInternalLuaState());
+#else
+ scriptModule_ = &LuaScriptModule::create(luaState_->getInternalLuaState());
+#endif
scriptModule_->setDefaultPCallErrorHandler(LuaState::ERROR_HANDLER_NAME);
// Create our own logger to specify the filepath
@@ -148,7 +170,11 @@
this->ceguiLogger_ = ceguiLogger.release();
// Create the CEGUI system singleton
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
guiSystem_ = new System(guiRenderer_, resourceProvider_, 0, scriptModule_);
+#else
+ guiSystem_ = &System::create(*guiRenderer_, resourceProvider_, 0, imageCodec_, scriptModule_);
+#endif
// Align CEGUI mouse with OIS mouse
guiSystem_->injectMousePosition((float)mousePosition.first, (float)mousePosition.second);
@@ -177,9 +203,17 @@
{
using namespace CEGUI;
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
delete guiSystem_;
delete guiRenderer_;
delete scriptModule_;
+#else
+ System::destroy();
+ OgreRenderer::destroyOgreResourceProvider(*resourceProvider_);
+ OgreRenderer::destroyOgreImageCodec(*imageCodec_);
+ OgreRenderer::destroy(*guiRenderer_);
+ LuaScriptModule::destroy(*scriptModule_);
+#endif
delete luaState_;
}
@@ -222,10 +256,12 @@
void GUIManager::setCamera(Ogre::Camera* camera)
{
this->camera_ = camera;
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
if (camera == NULL)
this->guiRenderer_->setTargetSceneManager(0);
else
this->guiRenderer_->setTargetSceneManager(camera->getSceneManager());
+#endif
}
/**
@@ -511,7 +547,11 @@
*/
void GUIManager::windowResized(unsigned int newWidth, unsigned int newHeight)
{
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
this->guiRenderer_->setDisplaySize(CEGUI::Size(newWidth, newHeight));
+#else
+ this->guiRenderer_->setDisplaySize(CEGUI::Size((float)newWidth, (float)newHeight));
+#endif
}
/**
Modified: code/branches/kicklib/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/kicklib/src/libraries/core/GUIManager.h 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/src/libraries/core/GUIManager.h 2011-02-25 02:07:17 UTC (rev 7960)
@@ -41,7 +41,7 @@
#include <set>
#include <string>
#include <CEGUIForwardRefs.h>
-#include <boost/scoped_ptr.hpp>
+#include <CEGUIVersion.h>
#include <boost/shared_ptr.hpp>
#include <loki/ScopeGuard.h>
@@ -146,8 +146,14 @@
/// Surrogate for the destructor
Loki::ObjScopeGuardImpl0<GUIManager, void (GUIManager::*)()> destroyer_;
+#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine
CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
+#else
+ CEGUI::OgreRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine
+ CEGUI::OgreResourceProvider* resourceProvider_; //!< CEGUI's resource provider
+ CEGUI::OgreImageCodec* imageCodec_;
+#endif
LuaState* luaState_; //!< LuaState, access point to the Lua engine
CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua
CEGUI::System* guiSystem_; //!< CEGUI's main system
Modified: code/branches/kicklib/src/libraries/util/Exception.cc
===================================================================
--- code/branches/kicklib/src/libraries/util/Exception.cc 2011-02-25 02:06:23 UTC (rev 7959)
+++ code/branches/kicklib/src/libraries/util/Exception.cc 2011-02-25 02:07:17 UTC (rev 7960)
@@ -94,15 +94,15 @@
// rethrow
throw;
}
- catch (const std::exception& ex)
- {
- return ex.what();
- }
catch (const CEGUI::Exception& ex)
{
return GeneralException(ex.getMessage().c_str(), ex.getLine(),
ex.getFileName().c_str(), ex.getName().c_str()).getDescription();
}
+ catch (const std::exception& ex)
+ {
+ return ex.what();
+ }
catch (...)
{
COUT(0) << "BIG WARNING: Unknown exception type encountered."
More information about the Orxonox-commit
mailing list