Commit 1c7dd000 authored by Janis Born's avatar Janis Born

add loader functions to directly create ArrayBuffers / VAOs from files

parent 07464e40
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/Objects/ArrayBuffer.hh>
#include <string>
namespace ACGL{
namespace OpenGL{
//! loads an array buffer from the given file
SharedArrayBuffer loadArrayBuffer(const std::string& _filename);
}
}
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#pragma once
#include <ACGL/ACGL.hh>
#include <ACGL/OpenGL/Objects/VertexArrayObject.hh>
#include <string>
namespace ACGL{
namespace OpenGL{
//! loads geometry data from a file and attaches the loaded array buffer data to a VertexArrayObject
SharedVertexArrayObject loadVertexArrayObject(const std::string& _filename);
}
}
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#include <ACGL/OpenGL/Data/ArrayBufferLoadStore.hh>
#include <ACGL/OpenGL/Data/GeometryDataLoadStore.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
using namespace ACGL::Utils;
namespace ACGL{
namespace OpenGL{
SharedArrayBuffer loadArrayBuffer(const std::string &_filename)
{
SharedArrayBuffer ab(new ArrayBuffer);
SharedGeometryData data = loadGeometryData(_filename);
if(data)
{
for(ArrayBuffer::AttributeVec::const_iterator it = data->mAttributes.begin();
it != data->mAttributes.end();
++it)
{
ab->defineAttribute(*it);
}
ab->setStride(data->getStrideSize());
ab->setData(data->getSize(), data->getData());
return ab;
}
else
{
return ab;
}
}
}
}
......@@ -8,10 +8,6 @@
#include <ACGL/Math/Math.hh>
#include <ACGL/Base/StringOperations.hh>
//#include <ACGL/OpenGL/Tools.hh>
//#include <ACGL/Base/FileHelpers.hh>
//#include <ACGL/Utils/Memory.hh>
#include <fstream>
#include <string>
......
/***********************************************************************
* Copyright 2011-2012 Computer Graphics Group RWTH Aachen University. *
* All rights reserved. *
* Distributed under the terms of the MIT License (see LICENSE.TXT). *
**********************************************************************/
#include <ACGL/OpenGL/Data/VertexArrayObjectLoadStore.hh>
#include <ACGL/OpenGL/Data/ArrayBufferLoadStore.hh>
using namespace ACGL;
using namespace ACGL::OpenGL;
using namespace ACGL::Utils;
namespace ACGL{
namespace OpenGL{
SharedVertexArrayObject loadVertexArrayObject(const std::string& _filename)
{
SharedVertexArrayObject vao(new VertexArrayObject);
SharedArrayBuffer ab = loadArrayBuffer(_filename);
vao->attachAllAttributes(ab);
return vao;
}
}
}
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