Buffer::CopyContent takes now an const buffer

Former-commit-id: c7a44c3198a24a60a26ab3cc04f75f4cea159979
This commit is contained in:
Lynix 2013-03-01 16:11:39 +01:00
parent 3b0751fb88
commit bb4c747e0b
3 changed files with 6 additions and 14 deletions

View File

@ -106,7 +106,7 @@ class NzMatrix4
static NzMatrix4 Identity();
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up());
static NzMatrix4 Ortho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
static NzMatrix4 Ortho(T left, T right, T top, T bottom, T zNear = -1.0, T zFar = 1.0);
static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar);
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
static NzMatrix4 Scale(const NzVector3<T>& scale);

View File

@ -25,7 +25,7 @@ class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
~NzBuffer();
bool CopyContent(NzBuffer& buffer);
bool CopyContent(const NzBuffer& buffer);
bool Create(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
void Destroy();

View File

@ -5,6 +5,7 @@
#include <Nazara/Utility/Buffer.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Utility/BufferImpl.hpp>
#include <Nazara/Utility/BufferMapper.hpp>
#include <Nazara/Utility/Config.hpp>
#include <Nazara/Utility/SoftwareBuffer.hpp>
#include <cstring>
@ -47,7 +48,7 @@ NzBuffer::~NzBuffer()
Destroy();
}
bool NzBuffer::CopyContent(NzBuffer& buffer)
bool NzBuffer::CopyContent(const NzBuffer& buffer)
{
#if NAZARA_UTILITY_SAFE
if (!m_impl)
@ -69,18 +70,9 @@ bool NzBuffer::CopyContent(NzBuffer& buffer)
}
#endif
void* ptr = buffer.Map(nzBufferAccess_ReadOnly);
if (!ptr)
{
NazaraError("Failed to map source buffer");
return false;
}
NzBufferMapper<NzBuffer> mapper(buffer, nzBufferAccess_ReadOnly);
bool r = Fill(ptr, 0, buffer.GetLength());
buffer.Unmap();
return r;
return Fill(mapper.GetPointer(), 0, buffer.GetLength());
}
bool NzBuffer::Create(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage, nzBufferUsage usage)