Update ghoul reference

- Added destructor to OpenSpaceEngine to deallocate SyncBuffer
- Changed texture reading to avoid memory leak
This commit is contained in:
jonasstrandstedt
2014-12-10 20:57:41 +01:00
parent 81caf96d72
commit 01361307f6
13 changed files with 22 additions and 15 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ public:
private:
OpenSpaceEngine(std::string programName);
~OpenSpaceEngine() = default;
~OpenSpaceEngine();
void clearAllWindows();
bool gatherCommandlineArguments();
+7
View File
@@ -90,6 +90,12 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName)
ghoul::systemcapabilities::SystemCapabilities::initialize();
}
OpenSpaceEngine::~OpenSpaceEngine() {
if(_syncBuffer)
delete _syncBuffer;
_syncBuffer = nullptr;
}
OpenSpaceEngine& OpenSpaceEngine::ref() {
assert(_engine);
return *_engine;
@@ -201,6 +207,7 @@ bool OpenSpaceEngine::create(int argc, char** argv,
}
void OpenSpaceEngine::destroy() {
delete _engine;
ghoul::systemcapabilities::SystemCapabilities::deinitialize();
FactoryManager::deinitialize();
+1 -1
View File
@@ -173,7 +173,7 @@ void RenderableModel::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
+1 -1
View File
@@ -170,7 +170,7 @@ void RenderablePlanet::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
+1 -1
View File
@@ -308,7 +308,7 @@ void RenderableEphemeris::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
+1 -1
View File
@@ -238,7 +238,7 @@ void RenderableFov::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
+1 -1
View File
@@ -233,7 +233,7 @@ void RenderablePath::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
+1 -1
View File
@@ -184,7 +184,7 @@ void RenderablePlane::loadTexture()
LDEBUG("loadTexture");
if (_texturePath.value() != "") {
LDEBUG("loadTexture2");
ghoul::opengl::Texture* texture = ghoul::io::TextureReader::loadTexture(absPath(_texturePath));
ghoul::opengl::Texture* texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_texturePath));
if (texture) {
LDEBUG("Loaded texture from '" << absPath(_texturePath) << "'");
texture->uploadTexture();
+1 -1
View File
@@ -310,7 +310,7 @@ void RenderableTrail::loadTexture()
delete _texture;
_texture = nullptr;
if (_colorTexturePath.value() != "") {
_texture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
_texture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_texture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_texture->uploadTexture();
+1 -1
View File
@@ -294,7 +294,7 @@ ghoul::opengl::Texture* RenderableVolume::loadTransferFunction(const std::string
// check if not a txt based texture
if ( ! hasExtension(filepath, "txt")) {
ghoul::opengl::Texture* t = ghoul::io::TextureReader::loadTexture(f);
ghoul::opengl::Texture* t = ghoul::io::TextureReader::ref().loadTexture(f);
t->setWrapping(wrappingmode);
return t;
}
+3 -3
View File
@@ -162,13 +162,13 @@ bool RenderEngine::initialize()
OsEng.interactionHandler().setCamera(_mainCamera);
#ifdef GHOUL_USE_DEVIL
ghoul::io::TextureReader::addReader(new ghoul::io::impl::TextureReaderDevIL);
ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderDevIL);
#endif // GHOUL_USE_DEVIL
#ifdef GHOUL_USE_FREEIMAGE
ghoul::io::TextureReader::addReader(new ghoul::io::impl::TextureReaderFreeImage);
ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderFreeImage);
#endif // GHOUL_USE_FREEIMAGE
ghoul::io::TextureReader::addReader(new ghoul::io::impl::TextureReaderCMAP);
ghoul::io::TextureReader::ref().addReader(new ghoul::io::impl::TextureReaderCMAP);
#if ABUFFER_IMPLEMENTATION == ABUFFER_FRAMEBUFFER
_abuffer = new ABufferFramebuffer();
+2 -2
View File
@@ -292,7 +292,7 @@ void RenderableStars::update(const UpdateData& data) {
delete _pointSpreadFunctionTexture;
_pointSpreadFunctionTexture = nullptr;
if (_pointSpreadFunctionTexturePath.value() != "") {
_pointSpreadFunctionTexture = ghoul::io::TextureReader::loadTexture(absPath(_pointSpreadFunctionTexturePath));
_pointSpreadFunctionTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_pointSpreadFunctionTexturePath));
if (_pointSpreadFunctionTexture) {
LDEBUG("Loaded texture from '" << absPath(_pointSpreadFunctionTexturePath) << "'");
_pointSpreadFunctionTexture->uploadTexture();
@@ -306,7 +306,7 @@ void RenderableStars::update(const UpdateData& data) {
delete _colorTexture;
_colorTexture = nullptr;
if (_colorTexturePath.value() != "") {
_colorTexture = ghoul::io::TextureReader::loadTexture(absPath(_colorTexturePath));
_colorTexture = ghoul::io::TextureReader::ref().loadTexture(absPath(_colorTexturePath));
if (_colorTexture) {
LDEBUG("Loaded texture from '" << absPath(_colorTexturePath) << "'");
_colorTexture->uploadTexture();