From 320fb3f8b82cfcb1723a71898c60bb4ba2dc627d Mon Sep 17 00:00:00 2001 From: Nicolay Korslund Date: Sun, 28 Feb 2010 14:51:17 +0100 Subject: [PATCH] Added very early CMakeLists.txt, builds main executable from game/main.cpp --- .gitignore | 6 ++++- CMakeLists.txt | 17 +++++++++++++ game/main.cpp | 53 +++++++++++++++++++++++++++++++++++++++ nifogre/ogre_nif_loader.h | 3 ++- 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 game/main.cpp diff --git a/.gitignore b/.gitignore index 8f6290d2c..ec1bceda4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ *.o *~ data -mw-scripts +CMakeFiles +CMakeCache.txt +Makefile +cmake*.cmake +openmw diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..a6fc1e4fd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,17 @@ +# We probably support older versions than this. +cmake_minimum_required(VERSION 2.6) + +# Local files +set(BSA bsa/bsa_archive.cpp bsa/bsa_file.cpp) +set(NIF nif/nif_file.cpp nifogre/ogre_nif_loader.cpp) +set(TOOLS tools/stringops.cpp) +set(MANGLE_VFS mangle/vfs/servers/ogre_vfs.cpp) +set(GAME game/main.cpp) + +# Dependencies +# Not exactly platform independent, FIXME! +add_definitions(-I/usr/local/include/OGRE) + +# Main executable +add_executable(openmw ${BSA} ${TOOLS} ${GAME}) +target_link_libraries(openmw OgreMain) diff --git a/game/main.cpp b/game/main.cpp new file mode 100644 index 000000000..60755ea87 --- /dev/null +++ b/game/main.cpp @@ -0,0 +1,53 @@ +#include + +#include "../bsa/bsa_archive.h" +#include "../esm/records.hpp" + +#include "Ogre.h" + +using namespace std; + +// Absolute minimal OGRE setup +void ogre_setup() +{ + using namespace Ogre; + + // Disable Ogre logging + new LogManager; + Log *log = LogManager::getSingleton().createLog(""); + log->setDebugOutputEnabled(false); + + // Set up Root. + new Root(); +} + +void maintest() +{ + const char* bsaFile = "data/Morrowind.bsa"; + const char* esmFile = "data/Morrowind.esm"; + + cout << "Hello, fellow traveler!\n"; + + cout << "Initializing OGRE\n"; + ogre_setup(); + + cout << "Adding " << bsaFile << endl; + addBSA(bsaFile); + + cout << "Loading ESM " << esmFile << " (header only)\n"; + ESM::ESMReader esm; + esm.open(esmFile); + + cout << "\nThat's all for now!\n"; +} + +int main(/*int argc, char**argv*/) +{ + try { maintest(); } + catch(exception &e) + { + cout << "\nERROR: " << e.what() << endl; + return 1; + } + return 0; +} diff --git a/nifogre/ogre_nif_loader.h b/nifogre/ogre_nif_loader.h index 846457c92..8d03118e7 100644 --- a/nifogre/ogre_nif_loader.h +++ b/nifogre/ogre_nif_loader.h @@ -40,7 +40,8 @@ Afterwards, you can use the mesh name "somemesh.nif" normally to create entities and so on. The mesh isn't loaded from disk until OGRE needs it for rendering. Thus the above load() command is not - very resource intensive. + very resource intensive, and can safely be done for a large number + of meshes at load time. */ struct NIFLoader : Ogre::ManualResourceLoader {