Commit 60510b1d authored by Robert Menzel's avatar Robert Menzel

simplified VertexArrayObjectControlFile and renamed it to VertexArrayObjectCreator

parent ca449c1b
......@@ -6,7 +6,7 @@
#ifndef ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILE_HH
#define ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILE_HH
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
/**
* Basetemplate for file loading.
*
......@@ -95,5 +95,5 @@ ACGL_SMARTPOINTER_TYPEDEFS( GeometryDataControlFile )
} // OpenGL
} // ACGL
#endif
#endif // ACGL_OPENGL_CONTROLLER_TEXTUREDATACONTROLFILE_HH
......@@ -6,7 +6,7 @@
#ifndef ACGL_OPENGL_CONTROLLER_DATACONTROLFILEFACTORY_HH
#define ACGL_OPENGL_CONTROLLER_DATACONTROLFILEFACTORY_HH
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
/**
* Image loaders can register the supported types at TextureDataControlFileFactory so a call like
* ... = TextureControlFile("bunny.ppm").create();
......@@ -93,5 +93,5 @@ typedef DataControlFileFactory< SharedGeometryDataControlFile > GeometryDataCont
} // OpenGL
} // ACGL
#endif
#endif // ACGL_OPENGL_CONTROLLER_DATACONTROLFILEFACTORY_HH
......@@ -6,7 +6,7 @@
#ifndef ACGL_OPENGL_CONTROLLER_ELEMENTARRAYBUFFERCONTROL_HH
#define ACGL_OPENGL_CONTROLLER_ELEMENTARRAYBUFFERCONTROL_HH
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
#include <ACGL/ACGL.hh>
#include <ACGL/Resource/BasicCreateInterface.hh>
......@@ -74,4 +74,5 @@ protected:
} // OpenGL
} // ACGL
#endif
#endif
#endif // ACGL_OPENGL_CONTROLLER_ELEMENTARRAYBUFFERCONTROL_HH
......@@ -6,7 +6,7 @@
#ifndef ACGL_OPENGL_CONTROLLER_GEOMETRYDATACONTROLFILEOBJ_HH
#define ACGL_OPENGL_CONTROLLER_GEOMETRYDATACONTROLFILEOBJ_HH
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
/**
* A minimal obj loader.
*/
......@@ -50,5 +50,5 @@ ACGL_SMARTPOINTER_TYPEDEFS(GeometryDataControlFileMesh)
} // OpenGL
} // ACGL
#endif
#endif // ACGL_OPENGL_CONTROLLER_GEOMETRYDATACONTROLFILEOBJ_HH
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#ifndef ACGL_OPENGL_CONTROLLER_VERTEXARRAYOBJECTCONTROLFILE_HH
#define ACGL_OPENGL_CONTROLLER_VERTEXARRAYOBJECTCONTROLFILE_HH
#pragma once
#include <ACGL/ACGL.hh>
#include <ACGL/Resource/SingleFileBasedCreator.hh>
#include <ACGL/OpenGL/Controller/DataControlFile.hh>
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
#include <ACGL/OpenGL/Data/LocationMappings.hh>
#ifdef ACGL_SUPPORT_VAO
#include <ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh>
namespace ACGL{
namespace OpenGL{
class VertexArrayObjectControlFile : public Resource::SingleFileBasedCreator<VertexArrayObject>
{
// ========================================================================================================= \/
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
VertexArrayObjectControlFile(const std::string& _filename);
VertexArrayObjectControlFile(const char* _filename);
template<typename CONTROLLER>
VertexArrayObjectControlFile(const CONTROLLER& _fileController)
: Resource::SingleFileBasedCreator<VertexArrayObject>(_fileController.getFilename(), Base::Settings::the()->getFullGeometryPath()),
mDataController(new CONTROLLER(_fileController)),
mAttributeLocations()
{}
virtual ~VertexArrayObjectControlFile(void) {}
// ==================================================================================================== \/
// ============================================================================================ METHODS \/
// ==================================================================================================== \/
public:
//! links to an external LocationMappings object
inline VertexArrayObjectControlFile& externAttributeLocations(const SharedLocationMappings& _attributeLocations) { mAttributeLocations = _attributeLocations; return *this; }
private:
bool load(SharedVertexArrayObject& vao);
// ===================================================================================================== \/
// ============================================================================================ OVERRIDE \/
// ===================================================================================================== \/
public:
virtual SharedVertexArrayObject create(void);
virtual bool update(SharedVertexArrayObject& _vao);
// =================================================================================================== \/
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
SharedGeometryDataControlFile mDataController;
SharedLocationMappings mAttributeLocations;
};
} // OpenGL
} // ACGL
#endif // #ifdef ACGL_SUPPORT_VAO
typedef ACGL::OpenGL::VertexArrayObjectCreator VertexArrayObjectControlFile;
#endif // ACGL_OPENGL_CONTROLLER_VERTEXARRAYOBJECTCONTROLFILE_HH
}
}
/***********************************************************************
* Copyright 2011-2013 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
/**
* Creates a VAO from a file which contains a mesh, e.g. an *.obj file.
*
* SharedVertexArrayObject vaoBunny = VertexArrayObjectCreator("Bunny.obj").create();
*
*/
#include <ACGL/ACGL.hh>
#include <ACGL/Resource/SingleFileBasedCreator.hh>
//#include <ACGL/OpenGL/Controller/DataControlFile.hh>
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
#include <ACGL/OpenGL/Data/LocationMappings.hh>
#include <ACGL/Base/Settings.hh>
#ifdef ACGL_SUPPORT_VAO
namespace ACGL{
namespace OpenGL{
class VertexArrayObjectCreator : public Resource::SingleFileBasedCreator<VertexArrayObject>
{
// ========================================================================================================= \/
// ============================================================================================ CONSTRUCTORS \/
// ========================================================================================================= \/
public:
VertexArrayObjectCreator(const std::string& _filename);
VertexArrayObjectCreator(const char* _filename);
template<typename CONTROLLER>
VertexArrayObjectCreator(const CONTROLLER& _fileController)
: Resource::SingleFileBasedCreator<VertexArrayObject>(_fileController.getFilename(), Base::Settings::the()->getFullGeometryPath()),
mAttributeLocations()
{}
virtual ~VertexArrayObjectCreator() {}
// ==================================================================================================== \/
// ============================================================================================ METHODS \/
// ==================================================================================================== \/
public:
//! links to an external LocationMappings object
inline VertexArrayObjectCreator& externAttributeLocations(const SharedLocationMappings& _attributeLocations) { mAttributeLocations = _attributeLocations; return *this; }
private:
bool load(SharedVertexArrayObject& vao);
// ===================================================================================================== \/
// ============================================================================================ OVERRIDE \/
// ===================================================================================================== \/
public:
virtual SharedVertexArrayObject create();
virtual bool update(SharedVertexArrayObject& _vao);
// =================================================================================================== \/
// ============================================================================================ FIELDS \/
// =================================================================================================== \/
protected:
//SharedGeometryDataControlFile mDataController;
SharedLocationMappings mAttributeLocations;
};
} // OpenGL
} // ACGL
#endif // #ifdef ACGL_SUPPORT_VAO
......@@ -3,13 +3,12 @@
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
#include <ACGL/OpenGL/Controller/ArrayBufferControlFile.hh>
#include <ACGL/OpenGL/Controller/DataControlFileFactory.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
ArrayBufferControlFile::ArrayBufferControlFile(const std::string& _filename)
: Resource::SingleFileBasedCreator<ArrayBuffer>(_filename, Base::Settings::the()->getFullGeometryPath()),
mDataController(GeometryDataControlFileFactory::the()->create(_filename))
......
......@@ -5,11 +5,11 @@
**********************************************************************/
#include <ACGL/OpenGL/Controller/DataControlFile.hh>
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
using namespace ACGL;
using namespace ACGL::OpenGL;
using namespace ACGL::Utils;
template<> int_t TextureDataControlFile::sTypeID = -1;
template<> int_t GeometryDataControlFile::sTypeID = -1;
#endif
......@@ -3,7 +3,7 @@
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#ifdef ACGL_INCLUDE_DEPRECATED_FUNCTIONALITY
#include <ACGL/OpenGL/Controller/GeometryDataControlFileOBJ.hh>
#include <ACGL/OpenGL/Controller/DataControlFileFactory.hh>
......@@ -30,3 +30,4 @@ bool GeometryDataControlFileMesh::load(SharedGeometryData& geometry) const
return false;
}
#endif
......@@ -4,36 +4,28 @@
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#include <ACGL/OpenGL/Controller/VertexArrayObjectControlFile.hh>
#include <ACGL/OpenGL/Creator/VertexArrayObjectCreator.hh>
#include <ACGL/OpenGL/Controller/DataControlFileFactory.hh>
#include <ACGL/OpenGL/Data/GeometryDataLoadStore.hh>
#ifdef ACGL_SUPPORT_VAO
using namespace ACGL;
using namespace ACGL::OpenGL;
VertexArrayObjectControlFile::VertexArrayObjectControlFile(const std::string& _filename)
: Resource::SingleFileBasedCreator<VertexArrayObject>(_filename, Base::Settings::the()->getFullGeometryPath()),
mDataController(GeometryDataControlFileFactory::the()->create(_filename))
VertexArrayObjectCreator::VertexArrayObjectCreator(const std::string &_filename)
: Resource::SingleFileBasedCreator<VertexArrayObject>(_filename, Base::Settings::the()->getFullGeometryPath())
{
if(!mDataController)
ACGL::Utils::error() << "No valid VAO controller to load the geometry. Perhaps there is no loader for that file extension: " << _filename << std::endl;
}
VertexArrayObjectControlFile::VertexArrayObjectControlFile(const char* _filename)
: Resource::SingleFileBasedCreator<VertexArrayObject>(std::string(_filename), Base::Settings::the()->getFullGeometryPath()),
mDataController(GeometryDataControlFileFactory::the()->create(std::string(_filename)))
VertexArrayObjectCreator::VertexArrayObjectCreator(const char *_filename)
: Resource::SingleFileBasedCreator<VertexArrayObject>(std::string(_filename), Base::Settings::the()->getFullGeometryPath())
{
if(!mDataController)
ACGL::Utils::error() << "No valid VAO controller to load the geometry. Perhaps there is no loader for that file extension: " << _filename << std::endl;
}
bool VertexArrayObjectControlFile::load(SharedVertexArrayObject& _vao)
bool VertexArrayObjectCreator::load(SharedVertexArrayObject &_vao)
{
if(!mDataController)
return false;
SharedGeometryData tempData = mDataController->create();
SharedGeometryData tempData = loadGeometryData( getFullFilePath() );
if(!tempData)
return false;
......@@ -59,7 +51,7 @@ bool VertexArrayObjectControlFile::load(SharedVertexArrayObject& _vao)
return true;
}
SharedVertexArrayObject VertexArrayObjectControlFile::create(void)
SharedVertexArrayObject VertexArrayObjectCreator::create()
{
updateFileModificationTime();
......@@ -71,7 +63,7 @@ SharedVertexArrayObject VertexArrayObjectControlFile::create(void)
return vao;
}
bool VertexArrayObjectControlFile::update(SharedVertexArrayObject& vao)
bool VertexArrayObjectCreator::update(SharedVertexArrayObject &vao)
{
if(fileIsUpToDate())
return false;
......
......@@ -31,6 +31,6 @@ void ACGL::OpenGL::initStaticFileTypes(void)
// Geometry, Meshes, Vertex data
//
GeometryDataControlFileATB::registerType();
#endif
GeometryDataControlFileMesh::registerType();
#endif
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment