Skip to content

Commit

Permalink
Merge pull request OGRECave#284 from paroj/samples
Browse files Browse the repository at this point in the history
Samples
  • Loading branch information
paroj committed Dec 30, 2016
2 parents 5f17d12 + 7caa681 commit 7d5279b
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 35 deletions.
2 changes: 1 addition & 1 deletion OgreMain/include/OgreResourceGroupManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ namespace Ogre {
/** Internal method called by ResourceManager when a resource is removed.
@param res Weak reference to resource
*/
void _notifyResourceRemoved(ResourcePtr& res);
void _notifyResourceRemoved(const ResourcePtr& res);

/** Internal method to notify the group manager that a resource has
changed group (only applicable for autodetect group) */
Expand Down
4 changes: 2 additions & 2 deletions OgreMain/include/OgreResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ namespace Ogre {
destruction of resources, try making sure you release all your
shared pointers before you shutdown OGRE.
*/
virtual void remove(ResourcePtr& r);
virtual void remove(const ResourcePtr& r);

/** Remove a single resource by name.
@remarks
Expand Down Expand Up @@ -555,7 +555,7 @@ namespace Ogre {
/** Add a newly created resource to the manager (note weak reference) */
virtual void addImpl( ResourcePtr& res );
/** Remove a resource from this manager; remove it from the lists. */
virtual void removeImpl( ResourcePtr& res );
virtual void removeImpl(const ResourcePtr& res );
/** Checks memory usage and pages out if required. This is automatically done after a new resource is loaded.
*/
virtual void checkUsage(void);
Expand Down
2 changes: 1 addition & 1 deletion OgreMain/src/OgreResourceGroupManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ namespace Ogre {
fireResourceCreated(res);
}
//-----------------------------------------------------------------------
void ResourceGroupManager::_notifyResourceRemoved(ResourcePtr& res)
void ResourceGroupManager::_notifyResourceRemoved(const ResourcePtr& res)
{
fireResourceRemove(res);

Expand Down
4 changes: 2 additions & 2 deletions OgreMain/src/OgreResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ namespace Ogre {
}
}
//-----------------------------------------------------------------------
void ResourceManager::removeImpl( ResourcePtr& res )
void ResourceManager::removeImpl(const ResourcePtr& res )
{
OGRE_LOCK_AUTO_MUTEX;

Expand Down Expand Up @@ -305,7 +305,7 @@ namespace Ogre {
}
}
//-----------------------------------------------------------------------
void ResourceManager::remove(ResourcePtr& res)
void ResourceManager::remove(const ResourcePtr& res)
{
removeImpl(res);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ListenerFactoryLogic : public Ogre::CompositorLogic
/** @copydoc CompositorLogic::compositorInstanceDestroyed */
virtual void compositorInstanceDestroyed(Ogre::CompositorInstance* destroyedInstance)
{
destroyedInstance->removeListener(mListeners[destroyedInstance]);
delete mListeners[destroyedInstance];
mListeners.erase(destroyedInstance);
}
Expand Down
28 changes: 1 addition & 27 deletions Samples/Compositor/include/HelperLogics.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,33 +31,7 @@ Also see acknowledgements in Readme.html
not exported to a plugin for simplification of the SDK package.
@see CompositorDemo::loadResources
*/
class ListenerFactoryLogic : public Ogre::CompositorLogic
{
public:
/** @copydoc CompositorLogic::compositorInstanceCreated */
virtual void compositorInstanceCreated(Ogre::CompositorInstance* newInstance)
{
Ogre::CompositorInstance::Listener* listener = createListener(newInstance);
newInstance->addListener(listener);
mListeners[newInstance] = listener;
}

/** @copydoc CompositorLogic::compositorInstanceDestroyed */
virtual void compositorInstanceDestroyed(Ogre::CompositorInstance* destroyedInstance)
{
destroyedInstance->removeListener(mListeners[destroyedInstance]);
delete mListeners[destroyedInstance];
mListeners.erase(destroyedInstance);
}

protected:
/// This is the method that implementations will need to override.
virtual Ogre::CompositorInstance::Listener* createListener(Ogre::CompositorInstance* instance) = 0;
private:
typedef std::map<Ogre::CompositorInstance*, Ogre::CompositorInstance::Listener*> ListenerMap;
ListenerMap mListeners;

};
#include "ListenerFactoryLogic.h"

/// The compositor logic for the heat vision compositor.
class HeatVisionLogic : public ListenerFactoryLogic
Expand Down
2 changes: 0 additions & 2 deletions Samples/DeferredShading/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ set(HEADER_FILES
include/GBufferSchemeHandler.h
include/GeomUtils.h
include/LightMaterialGenerator.h
include/ListenerFactoryLogic.h
include/MaterialGenerator.h
include/NullSchemeHandler.h
include/SharedData.h
Expand Down Expand Up @@ -53,4 +52,3 @@ if (APPLE AND NOT APPLE_IOS)
INSTALL_NAME_DIR "@executable_path/../Plugins"
)
endif()

10 changes: 10 additions & 0 deletions Samples/DeferredShading/src/MaterialGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ same license as the rest of the engine.

#include "OgreHighLevelGpuProgram.h"
#include "OgreHighLevelGpuProgramManager.h"
#include "OgreMaterialManager.h"

#include <iostream>

Expand All @@ -33,6 +34,15 @@ MaterialGenerator::MaterialGenerator():
}
MaterialGenerator::~MaterialGenerator()
{
// we have generated fragment shaders and materials
// so delete them
for(ProgramMap::iterator it = mFs.begin(); it != mFs.end(); ++it) {
HighLevelGpuProgramManager::getSingleton().remove(it->second);
}
for(MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it) {
MaterialManager::getSingleton().remove(it->second);
}

delete mImpl;
}

Expand Down

0 comments on commit 7d5279b

Please sign in to comment.