Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 21, 2011, 6:16:24 AM (13 years ago)
Author:
rgrieder
Message:

Dropped support for OGRE v1.4 and removed the remaining workarounds.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/kicklib/src/libraries/core/GraphicsManager.cc

    r7874 r7948  
    3535#include <boost/shared_array.hpp>
    3636
    37 #include <OgreArchiveFactory.h>
    38 #include <OgreArchiveManager.h>
    3937#include <OgreFrameListener.h>
    4038#include <OgreRoot.h>
     
    5856#include "GameMode.h"
    5957#include "Loader.h"
    60 #include "MemoryArchive.h"
    6158#include "PathConfig.h"
    6259#include "WindowEventListener.h"
     
    9087    GraphicsManager::GraphicsManager(bool bLoadRenderer)
    9188        : ogreWindowEventListener_(new OgreWindowEventListener())
    92 #if OGRE_VERSION < 0x010600
    93         , memoryArchiveFactory_(new MemoryArchiveFactory())
    94 #endif
    9589        , renderWindow_(0)
    9690        , viewport_(0)
     
    178172
    179173        this->loadRenderer();
    180 
    181 #if OGRE_VERSION < 0x010600
    182         // WORKAROUND: There is an incompatibility for particle scripts when trying
    183         // to support both Ogre 1.4 and 1.6. The hacky solution is to create
    184         // scripts for the 1.6 version and then remove the inserted "particle_system"
    185         // keyword. But we need to supply these new scripts as well, which is why
    186         // there is an extra Ogre::Archive dealing with it in the memory.
    187         using namespace Ogre;
    188         ArchiveManager::getSingleton().addArchiveFactory(memoryArchiveFactory_.get());
    189         const StringVector& groups = ResourceGroupManager::getSingleton().getResourceGroups();
    190         // Travers all groups
    191         for (StringVector::const_iterator itGroup = groups.begin(); itGroup != groups.end(); ++itGroup)
    192         {
    193             FileInfoListPtr files = ResourceGroupManager::getSingleton().findResourceFileInfo(*itGroup, "*.particle");
    194             for (FileInfoList::const_iterator itFile = files->begin(); itFile != files->end(); ++itFile)
    195             {
    196                 // open file
    197                 Ogre::DataStreamPtr input = ResourceGroupManager::getSingleton().openResource(itFile->filename, *itGroup, false);
    198                 std::stringstream output;
    199                 // Parse file and replace "particle_system" with nothing
    200                 while (!input->eof())
    201                 {
    202                     std::string line = input->getLine();
    203                     size_t pos = line.find("particle_system");
    204                     if (pos != std::string::npos)
    205                     {
    206                         // 15 is the length of "particle_system"
    207                         line.replace(pos, 15, "");
    208                     }
    209                     output << line << std::endl;
    210                 }
    211                 // Add file to the memory archive
    212                 shared_array<char> data(new char[output.str().size()]);
    213                 // Debug optimisations
    214                 const std::string& outputStr = output.str();
    215                 char* rawData = data.get();
    216                 for (unsigned i = 0; i < outputStr.size(); ++i)
    217                     rawData[i] = outputStr[i];
    218                 MemoryArchive::addFile("particle_scripts_ogre_1.4_" + *itGroup, itFile->filename, data, output.str().size());
    219             }
    220             if (!files->empty())
    221             {
    222                 // Declare the files, but using a new group
    223                 ResourceGroupManager::getSingleton().addResourceLocation("particle_scripts_ogre_1.4_" + *itGroup,
    224                     "Memory", "particle_scripts_ogre_1.4_" + *itGroup);
    225             }
    226         }
    227 #endif
    228174
    229175        // Initialise all resources (do this AFTER the renderer has been loaded!)
Note: See TracChangeset for help on using the changeset viewer.