Update Ghoul repository to have the factory return unique_ptrs

Adjust accordingly
This commit is contained in:
Alexander Bock
2017-03-01 22:03:48 -05:00
parent 2b07cf8c05
commit 2f2fa3b031
26 changed files with 69 additions and 52 deletions
+4 -2
View File
@@ -68,7 +68,9 @@ documentation:: Documentation ModelGeometry::Documentation() {
}
ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dictionary) {
std::unique_ptr<ModelGeometry> ModelGeometry::createFromDictionary(
const ghoul::Dictionary& dictionary)
{
if (!dictionary.hasKeyAndValue<std::string>(keyType)) {
throw ghoul::RuntimeError("Dictionary did not contain a key 'Type'");
}
@@ -76,7 +78,7 @@ ModelGeometry* ModelGeometry::createFromDictionary(const ghoul::Dictionary& dict
std::string geometryType = dictionary.value<std::string>(keyType);
auto factory = FactoryManager::ref().factory<ModelGeometry>();
ModelGeometry* result = factory->create(geometryType, dictionary);
std::unique_ptr<ModelGeometry> result = factory->create(geometryType, dictionary);
if (result == nullptr) {
throw ghoul::RuntimeError(
"Failed to create a ModelGeometry object of type '" + geometryType + "'"
+3 -1
View File
@@ -38,7 +38,9 @@ namespace modelgeometry {
class ModelGeometry : public properties::PropertyOwner {
public:
static ModelGeometry* createFromDictionary(const ghoul::Dictionary& dictionary);
static std::unique_ptr<ModelGeometry> createFromDictionary(
const ghoul::Dictionary& dictionary
);
struct Vertex {
GLfloat location[4];
+1 -2
View File
@@ -85,7 +85,7 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary)
if (success)
_colorTexturePath = absPath(texturePath);
addPropertySubOwner(_geometry);
addPropertySubOwner(_geometry.get());
addProperty(_colorTexturePath);
_colorTexturePath.onChange(std::bind(&RenderableModel::loadTexture, this));
@@ -153,7 +153,6 @@ bool RenderableModel::initialize() {
bool RenderableModel::deinitialize() {
if (_geometry) {
_geometry->deinitialize();
delete _geometry;
_geometry = nullptr;
}
_texture = nullptr;
+3 -1
View File
@@ -36,6 +36,8 @@
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
#include <memory>
namespace openspace {
namespace modelgeometry {
@@ -65,7 +67,7 @@ private:
std::unique_ptr<ghoul::opengl::ProgramObject> _programObject;
std::unique_ptr<ghoul::opengl::Texture> _texture;
modelgeometry::ModelGeometry* _geometry;
std::unique_ptr<modelgeometry::ModelGeometry> _geometry;
glm::dmat3 _modelTransform;