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 Identity();
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& target, const NzVector3<T>& up = NzVector3<T>::Up()); 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 Perspective(T angle, T ratio, T zNear, T zFar);
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation); static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
static NzMatrix4 Scale(const NzVector3<T>& scale); 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(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
~NzBuffer(); ~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); bool Create(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
void Destroy(); void Destroy();

View File

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