Commit b233e450 authored by Janis Born's avatar Janis Born

add load / save functions for the ACGL binary VAO format

(http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/Vao_File_Format)
parent 8ec2e204
......@@ -14,8 +14,32 @@
namespace ACGL{
namespace OpenGL{
//! loads geometry data from a file and attaches the loaded array buffer data to a VertexArrayObject
///////////////////////////////////////////////////////////////////////////////////////////////////
// generic load/save
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Loads geometry data from a file and attaches the loaded array buffer data to a VertexArrayObject
//! Tries to guess the file format from the file extension
SharedVertexArrayObject loadVertexArrayObject(const std::string& _filename);
///////////////////////////////////////////////////////////////////////////////////////////////////
// library specific load
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Loads a VertexArrayObject from the ACGL binary VAO format, as specified here:
//! http://www.graphics.rwth-aachen.de/redmine/projects/acgl/wiki/Vao_File_Format
//! A VAO file can contain several named EABs. Only the EAB whose name matches _eabName will be loaded
//! and attached to the VAO. If _eabName is left blank, the first defined EAB will be used.
SharedVertexArrayObject loadVertexArrayObjectVAO(const std::string& _filename, const std::string& _eabName = "");
///////////////////////////////////////////////////////////////////////////////////////////////////
// library specific save
///////////////////////////////////////////////////////////////////////////////////////////////////
//! Stores a VertexArrayObject in a file using the ACGL binary VAO format
//! Each attached ArrayBuffer will be stored entirely in the VAO file but only those attributes which
//! are used by _vao will be defined.
bool saveVertexArrayObjectToVAO(ConstSharedVertexArrayObject _vao, const std::string& _filename);
}
}
......@@ -5,9 +5,7 @@
**********************************************************************/
#include <ACGL/OpenGL/Data/GeometryDataLoadStore.hh>
//#include <ACGL/OpenGL/Tools.hh>
#include <ACGL/Base/FileHelpers.hh>
//#include <ACGL/Utils/Memory.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
......
......@@ -6,6 +6,7 @@
#include <ACGL/OpenGL/Data/VertexArrayObjectLoadStore.hh>
#include <ACGL/OpenGL/Data/ArrayBufferLoadStore.hh>
#include <ACGL/Base/FileHelpers.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
......@@ -16,16 +17,27 @@ namespace OpenGL{
SharedVertexArrayObject loadVertexArrayObject(const std::string& _filename)
{
SharedArrayBuffer ab = loadArrayBuffer(_filename);
if(ab)
// lower case file ending:
std::string fileEnding = Base::FileHelpers::getFileEnding(_filename);
if(fileEnding == "vao")
{
SharedVertexArrayObject vao(new VertexArrayObject);
vao->attachAllAttributes(ab);
return vao;
return loadVertexArrayObjectVAO(_filename);
}
else
{
return SharedVertexArrayObject();
// Generic load: Try to load the file as an ArrayBuffer and attach it to a VAO
SharedArrayBuffer ab = loadArrayBuffer(_filename);
if(ab)
{
SharedVertexArrayObject vao(new VertexArrayObject);
vao->attachAllAttributes(ab);
return vao;
}
else
{
return SharedVertexArrayObject();
}
}
}
......
This diff is collapsed.
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