Moved buffers to Utility
Fixed NzVector4::operator/ Replaced enumName_Count by enumName_Max Renamed (Index/Vertex)Buffer::GetBufferPtr by GetPointer
This commit is contained in:
@@ -17,7 +17,7 @@ template<typename T> class NzVector3
|
||||
NzVector3(T X, T Y, T Z);
|
||||
explicit NzVector3(T scale);
|
||||
NzVector3(T vec[3]);
|
||||
NzVector3(const NzVector2<T>& vec);
|
||||
NzVector3(const NzVector2<T>& vec, T Z = 0.0);
|
||||
template<typename U> explicit NzVector3(const NzVector3<U>& vec);
|
||||
NzVector3(const NzVector3& vec) = default;
|
||||
~NzVector3() = default;
|
||||
|
||||
@@ -39,10 +39,10 @@ z(vec[2])
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
NzVector3<T>::NzVector3(const NzVector2<T>& vec) :
|
||||
NzVector3<T>::NzVector3(const NzVector2<T>& vec, T Z) :
|
||||
x(vec.x),
|
||||
y(vec.y),
|
||||
z(0)
|
||||
z(Z)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ NzVector4<T> operator/(T scale, const NzVector4<T>& vec)
|
||||
throw std::domain_error(ss.ToString());
|
||||
}
|
||||
|
||||
return NzVector3<T>(scale / vec.x, scale / vec.y, scale / vec.z, scale / vec.w);
|
||||
return NzVector4<T>(scale / vec.x, scale / vec.y, scale / vec.z, scale / vec.w);
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
@@ -37,6 +37,7 @@ class NAZARA_API NzOpenGL
|
||||
DebugOutput,
|
||||
FP64,
|
||||
FrameBufferObject,
|
||||
PixelBufferObject,
|
||||
SeparateShaderObjects,
|
||||
Texture3D,
|
||||
TextureCompression_s3tc,
|
||||
|
||||
@@ -59,13 +59,13 @@ enum nzRendererCap
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_OcclusionQuery,
|
||||
nzRendererCap_SoftwareBuffer,
|
||||
nzRendererCap_PixelBufferObject,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Count
|
||||
nzRendererCap_Max = nzRendererCap_TextureNPOT
|
||||
};
|
||||
|
||||
enum nzRendererClear
|
||||
@@ -183,7 +183,7 @@ class NAZARA_API NzRenderer
|
||||
const NzVertexBuffer* m_vertexBuffer;
|
||||
const NzVertexDeclaration* m_vertexDeclaration;
|
||||
bool m_vaoUpdated;
|
||||
bool m_capabilities[nzRendererCap_Count];
|
||||
bool m_capabilities[nzRendererCap_Max+1];
|
||||
bool m_stencilFuncUpdated;
|
||||
bool m_stencilOpUpdated;
|
||||
unsigned int m_maxAnisotropyLevel;
|
||||
|
||||
@@ -30,7 +30,7 @@ enum nzShaderType
|
||||
nzShaderType_Geometry,
|
||||
nzShaderType_Vertex,
|
||||
|
||||
nzShaderType_Count
|
||||
nzShaderType_Max = nzShaderType_Vertex
|
||||
};
|
||||
|
||||
class NzRenderer;
|
||||
|
||||
@@ -22,7 +22,9 @@ enum nzBufferAccess
|
||||
enum nzBufferStorage
|
||||
{
|
||||
nzBufferStorage_Hardware,
|
||||
nzBufferStorage_Software
|
||||
nzBufferStorage_Software,
|
||||
|
||||
nzBufferStorage_Max = nzBufferStorage_Software
|
||||
};
|
||||
|
||||
enum nzBufferType
|
||||
@@ -39,27 +41,31 @@ enum nzBufferUsage
|
||||
|
||||
class NzBufferImpl;
|
||||
class NzRenderer;
|
||||
class NzUtility;
|
||||
|
||||
class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||
{
|
||||
friend class NzRenderer;
|
||||
friend class NzUtility;
|
||||
|
||||
public:
|
||||
typedef NzBufferImpl* (*BufferFunction)(NzBuffer* parent, nzBufferType type);
|
||||
|
||||
NzBuffer(nzBufferType type);
|
||||
NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
~NzBuffer();
|
||||
|
||||
bool CopyContent(NzBuffer& buffer);
|
||||
|
||||
bool Create(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
bool Create(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
void Destroy();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
void* GetBufferPtr();
|
||||
const void* GetBufferPtr() const;
|
||||
NzBufferImpl* GetImpl() const;
|
||||
unsigned int GetLength() const;
|
||||
void* GetPointer();
|
||||
const void* GetPointer() const;
|
||||
unsigned int GetSize() const;
|
||||
nzBufferStorage GetStorage() const;
|
||||
nzBufferType GetType() const;
|
||||
@@ -67,13 +73,18 @@ class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||
nzBufferUsage GetUsage() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||
bool Unmap();
|
||||
|
||||
static bool IsSupported(nzBufferStorage storage);
|
||||
static void SetBufferFunction(nzBufferStorage storage, BufferFunction func);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
nzBufferStorage m_storage;
|
||||
nzBufferType m_type;
|
||||
nzBufferUsage m_usage;
|
||||
@@ -81,6 +92,7 @@ class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||
NzBufferImpl* m_impl;
|
||||
unsigned int m_length;
|
||||
|
||||
static BufferFunction s_bufferFunctions[nzBufferStorage_Max+1];
|
||||
};
|
||||
|
||||
#endif // NAZARA_BUFFER_HPP
|
||||
31
include/Nazara/Utility/BufferImpl.hpp
Normal file
31
include/Nazara/Utility/BufferImpl.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine".
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_BUFFERIMPL_HPP
|
||||
#define NAZARA_BUFFERIMPL_HPP
|
||||
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzBufferImpl
|
||||
{
|
||||
public:
|
||||
NzBufferImpl() = default;
|
||||
virtual ~NzBufferImpl();
|
||||
|
||||
virtual bool Create(unsigned int size, nzBufferUsage usage = nzBufferUsage_Static) = 0;
|
||||
virtual void Destroy() = 0;
|
||||
|
||||
virtual bool Fill(const void* data, unsigned int offset, unsigned int size) = 0;
|
||||
|
||||
virtual void* GetPointer() = 0;
|
||||
|
||||
virtual bool IsHardware() const = 0;
|
||||
|
||||
virtual void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int size = 0) = 0;
|
||||
virtual bool Unmap() = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_BUFFERIMPL_INCLUDED
|
||||
@@ -35,7 +35,7 @@ enum nzImageType
|
||||
nzImageType_3D,
|
||||
nzImageType_Cubemap,
|
||||
|
||||
nzImageType_Count
|
||||
nzImageType_Max = nzImageType_Cubemap
|
||||
};
|
||||
|
||||
struct NzImageParams
|
||||
|
||||
@@ -8,23 +8,23 @@
|
||||
#define NAZARA_INDEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzIndexBuffer
|
||||
{
|
||||
public:
|
||||
NzIndexBuffer(NzBuffer* buffer, unsigned int startIndex, unsigned int indexCount);
|
||||
NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzIndexBuffer(const NzIndexBuffer& indexBuffer);
|
||||
~NzIndexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
void* GetBufferPtr();
|
||||
const void* GetBufferPtr() const;
|
||||
nzUInt8 GetIndexSize() const;
|
||||
unsigned int GetIndexCount() const;
|
||||
void* GetPointer();
|
||||
const void* GetPointer() const;
|
||||
unsigned int GetStartIndex() const;
|
||||
|
||||
bool IsHardware() const;
|
||||
@@ -46,7 +46,7 @@ enum nzPixelFormat
|
||||
nzPixelFormat_Stencil16,
|
||||
*/
|
||||
|
||||
nzPixelFormat_Count
|
||||
nzPixelFormat_Max = nzPixelFormat_RGBA8
|
||||
};
|
||||
|
||||
class NzUtility;
|
||||
@@ -69,7 +69,7 @@ class NzPixelFormat
|
||||
static bool IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat);
|
||||
static bool IsValid(nzPixelFormat format);
|
||||
|
||||
static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction);
|
||||
static void SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func);
|
||||
|
||||
static NzString ToString(nzPixelFormat format);
|
||||
|
||||
@@ -77,7 +77,7 @@ class NzPixelFormat
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
static NAZARA_API ConvertFunction s_convertFunctions[nzPixelFormat_Count][nzPixelFormat_Count];
|
||||
static NAZARA_API ConvertFunction s_convertFunctions[nzPixelFormat_Max+1][nzPixelFormat_Max+1];
|
||||
};
|
||||
|
||||
#include <Nazara/Utility/PixelFormat.inl>
|
||||
|
||||
@@ -129,7 +129,6 @@ inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format)
|
||||
case nzPixelFormat_RGBA8:
|
||||
return 4;
|
||||
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
NazaraError("Invalid pixel format");
|
||||
return 0;
|
||||
@@ -159,7 +158,6 @@ inline bool NzPixelFormat::HasAlpha(nzPixelFormat format)
|
||||
case nzPixelFormat_RGB8:
|
||||
return false;
|
||||
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
@@ -192,15 +190,7 @@ inline bool NzPixelFormat::IsConversionSupported(nzPixelFormat srcFormat, nzPixe
|
||||
|
||||
inline bool NzPixelFormat::IsValid(nzPixelFormat format)
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return format != nzPixelFormat_Undefined;
|
||||
}
|
||||
|
||||
inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func)
|
||||
@@ -269,7 +259,6 @@ inline NzString NzPixelFormat::ToString(nzPixelFormat format)
|
||||
case nzPixelFormat_RGBA8:
|
||||
return "RGBA8";
|
||||
|
||||
case nzPixelFormat_Count:
|
||||
case nzPixelFormat_Undefined:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -8,21 +8,21 @@
|
||||
#define NAZARA_VERTEXBUFFER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Buffer.hpp>
|
||||
#include <Nazara/Utility/Buffer.hpp>
|
||||
|
||||
class NAZARA_API NzVertexBuffer
|
||||
{
|
||||
public:
|
||||
NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
|
||||
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage = nzBufferStorage_Software, nzBufferUsage usage = nzBufferUsage_Static);
|
||||
NzVertexBuffer(const NzVertexBuffer& vertexBuffer);
|
||||
~NzVertexBuffer();
|
||||
|
||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||
|
||||
NzBuffer* GetBuffer() const;
|
||||
void* GetBufferPtr();
|
||||
const void* GetBufferPtr() const;
|
||||
void* GetPointer();
|
||||
const void* GetPointer() const;
|
||||
unsigned int GetStartVertex() const;
|
||||
nzUInt8 GetTypeSize() const;
|
||||
unsigned int GetVertexCount() const;
|
||||
Reference in New Issue
Block a user