mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-04-24 04:58:59 -05:00
Using new ghoul ProgramObject functionality
- Fixed risk of memory leak in SceneGraph (deleting shaders)
This commit is contained in:
@@ -45,7 +45,6 @@
|
||||
// #define FLARE_ONLY
|
||||
|
||||
#include <openspace/flare/flare.h>
|
||||
#include <openspace/util/shadercreator.h>
|
||||
|
||||
#define ABUFFER_SINGLE_LINKED 1
|
||||
#define ABUFFER_FIXED 2
|
||||
@@ -76,7 +75,6 @@ public:
|
||||
InteractionHandler& interactionHandler();
|
||||
RenderEngine& renderEngine();
|
||||
scripting::ScriptEngine& scriptEngine();
|
||||
ShaderCreator& shaderBuilder();
|
||||
|
||||
// SGCT callbacks
|
||||
bool initializeGL();
|
||||
@@ -116,7 +114,6 @@ private:
|
||||
ghoul::opencl::CLContext _context;
|
||||
|
||||
sgct::SharedVector<char> _synchronizationBuffer;
|
||||
ShaderCreator _shaderBuilder;
|
||||
};
|
||||
|
||||
#define OsEng (openspace::OpenSpaceEngine::ref())
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
// std includes
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <mutex>
|
||||
|
||||
#include <openspace/util/camera.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
@@ -118,6 +120,10 @@ private:
|
||||
std::map<std::string, SceneGraphNode*> _allNodes;
|
||||
|
||||
std::string _sceneGraphToLoad;
|
||||
|
||||
std::mutex _programUpdateLock;
|
||||
std::set<ghoul::opengl::ProgramObject*> _programsToUpdate;
|
||||
std::vector<ghoul::opengl::ProgramObject*> _programs;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __SHADERCREATOR_H__
|
||||
#define __SHADERCREATOR_H__
|
||||
|
||||
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace openspace {
|
||||
class ShaderCreator {
|
||||
|
||||
public:
|
||||
ShaderCreator();
|
||||
~ShaderCreator();
|
||||
|
||||
void createSourceFile(bool b);
|
||||
void sourceFileExtension(const std::string& extension);
|
||||
void sourceFileHeader(const std::string& header);
|
||||
|
||||
ghoul::opengl::ProgramObject* buildShader(const std::string& name, const std::string& vpath, const std::string& fpath, const std::string& gpath = "");
|
||||
|
||||
private:
|
||||
|
||||
void _generateSource(const std::string& filename);
|
||||
std::string _loadSource(const std::string& filename, unsigned int depth = 0);
|
||||
std::string _generateFilename(const std::string& filename);
|
||||
|
||||
bool _createSourceFile;
|
||||
std::string _sourceFileExtension;
|
||||
std::string _sourceFileHeader;
|
||||
unsigned int _maxDepth;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user