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:
parent
be0a5d2819
commit
ec9470ceb6
|
|
@ -54,9 +54,6 @@ $RECYCLE.BIN/
|
||||||
[Dd]ebug*/
|
[Dd]ebug*/
|
||||||
[Rr]elease/
|
[Rr]elease/
|
||||||
|
|
||||||
build/
|
|
||||||
|
|
||||||
|
|
||||||
[Tt]est[Rr]esult
|
[Tt]est[Rr]esult
|
||||||
[Bb]uild[Ll]og.*
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ template<typename T> class NzVector3
|
||||||
NzVector3(T X, T Y, T Z);
|
NzVector3(T X, T Y, T Z);
|
||||||
explicit NzVector3(T scale);
|
explicit NzVector3(T scale);
|
||||||
NzVector3(T vec[3]);
|
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);
|
template<typename U> explicit NzVector3(const NzVector3<U>& vec);
|
||||||
NzVector3(const NzVector3& vec) = default;
|
NzVector3(const NzVector3& vec) = default;
|
||||||
~NzVector3() = default;
|
~NzVector3() = default;
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,10 @@ z(vec[2])
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
NzVector3<T>::NzVector3(const NzVector2<T>& vec) :
|
NzVector3<T>::NzVector3(const NzVector2<T>& vec, T Z) :
|
||||||
x(vec.x),
|
x(vec.x),
|
||||||
y(vec.y),
|
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());
|
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>
|
#include <Nazara/Core/DebugOff.hpp>
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ class NAZARA_API NzOpenGL
|
||||||
DebugOutput,
|
DebugOutput,
|
||||||
FP64,
|
FP64,
|
||||||
FrameBufferObject,
|
FrameBufferObject,
|
||||||
|
PixelBufferObject,
|
||||||
SeparateShaderObjects,
|
SeparateShaderObjects,
|
||||||
Texture3D,
|
Texture3D,
|
||||||
TextureCompression_s3tc,
|
TextureCompression_s3tc,
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,13 @@ enum nzRendererCap
|
||||||
nzRendererCap_HardwareBuffer,
|
nzRendererCap_HardwareBuffer,
|
||||||
nzRendererCap_MultipleRenderTargets,
|
nzRendererCap_MultipleRenderTargets,
|
||||||
nzRendererCap_OcclusionQuery,
|
nzRendererCap_OcclusionQuery,
|
||||||
nzRendererCap_SoftwareBuffer,
|
nzRendererCap_PixelBufferObject,
|
||||||
nzRendererCap_Texture3D,
|
nzRendererCap_Texture3D,
|
||||||
nzRendererCap_TextureCubemap,
|
nzRendererCap_TextureCubemap,
|
||||||
nzRendererCap_TextureMulti,
|
nzRendererCap_TextureMulti,
|
||||||
nzRendererCap_TextureNPOT,
|
nzRendererCap_TextureNPOT,
|
||||||
|
|
||||||
nzRendererCap_Count
|
nzRendererCap_Max = nzRendererCap_TextureNPOT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum nzRendererClear
|
enum nzRendererClear
|
||||||
|
|
@ -183,7 +183,7 @@ class NAZARA_API NzRenderer
|
||||||
const NzVertexBuffer* m_vertexBuffer;
|
const NzVertexBuffer* m_vertexBuffer;
|
||||||
const NzVertexDeclaration* m_vertexDeclaration;
|
const NzVertexDeclaration* m_vertexDeclaration;
|
||||||
bool m_vaoUpdated;
|
bool m_vaoUpdated;
|
||||||
bool m_capabilities[nzRendererCap_Count];
|
bool m_capabilities[nzRendererCap_Max+1];
|
||||||
bool m_stencilFuncUpdated;
|
bool m_stencilFuncUpdated;
|
||||||
bool m_stencilOpUpdated;
|
bool m_stencilOpUpdated;
|
||||||
unsigned int m_maxAnisotropyLevel;
|
unsigned int m_maxAnisotropyLevel;
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ enum nzShaderType
|
||||||
nzShaderType_Geometry,
|
nzShaderType_Geometry,
|
||||||
nzShaderType_Vertex,
|
nzShaderType_Vertex,
|
||||||
|
|
||||||
nzShaderType_Count
|
nzShaderType_Max = nzShaderType_Vertex
|
||||||
};
|
};
|
||||||
|
|
||||||
class NzRenderer;
|
class NzRenderer;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ enum nzBufferAccess
|
||||||
enum nzBufferStorage
|
enum nzBufferStorage
|
||||||
{
|
{
|
||||||
nzBufferStorage_Hardware,
|
nzBufferStorage_Hardware,
|
||||||
nzBufferStorage_Software
|
nzBufferStorage_Software,
|
||||||
|
|
||||||
|
nzBufferStorage_Max = nzBufferStorage_Software
|
||||||
};
|
};
|
||||||
|
|
||||||
enum nzBufferType
|
enum nzBufferType
|
||||||
|
|
@ -39,27 +41,31 @@ enum nzBufferUsage
|
||||||
|
|
||||||
class NzBufferImpl;
|
class NzBufferImpl;
|
||||||
class NzRenderer;
|
class NzRenderer;
|
||||||
|
class NzUtility;
|
||||||
|
|
||||||
class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||||
{
|
{
|
||||||
friend class NzRenderer;
|
friend class NzRenderer;
|
||||||
|
friend class NzUtility;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
typedef NzBufferImpl* (*BufferFunction)(NzBuffer* parent, nzBufferType type);
|
||||||
|
|
||||||
NzBuffer(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();
|
~NzBuffer();
|
||||||
|
|
||||||
bool CopyContent(NzBuffer& buffer);
|
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();
|
void Destroy();
|
||||||
|
|
||||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||||
|
|
||||||
void* GetBufferPtr();
|
|
||||||
const void* GetBufferPtr() const;
|
|
||||||
NzBufferImpl* GetImpl() const;
|
NzBufferImpl* GetImpl() const;
|
||||||
unsigned int GetLength() const;
|
unsigned int GetLength() const;
|
||||||
|
void* GetPointer();
|
||||||
|
const void* GetPointer() const;
|
||||||
unsigned int GetSize() const;
|
unsigned int GetSize() const;
|
||||||
nzBufferStorage GetStorage() const;
|
nzBufferStorage GetStorage() const;
|
||||||
nzBufferType GetType() const;
|
nzBufferType GetType() const;
|
||||||
|
|
@ -67,13 +73,18 @@ class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||||
nzBufferUsage GetUsage() const;
|
nzBufferUsage GetUsage() const;
|
||||||
|
|
||||||
bool IsHardware() const;
|
bool IsHardware() const;
|
||||||
|
bool IsValid() const;
|
||||||
|
|
||||||
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
void* Map(nzBufferAccess access, unsigned int offset = 0, unsigned int length = 0);
|
||||||
bool Unmap();
|
bool Unmap();
|
||||||
|
|
||||||
static bool IsSupported(nzBufferStorage storage);
|
static bool IsSupported(nzBufferStorage storage);
|
||||||
|
static void SetBufferFunction(nzBufferStorage storage, BufferFunction func);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static bool Initialize();
|
||||||
|
static void Uninitialize();
|
||||||
|
|
||||||
nzBufferStorage m_storage;
|
nzBufferStorage m_storage;
|
||||||
nzBufferType m_type;
|
nzBufferType m_type;
|
||||||
nzBufferUsage m_usage;
|
nzBufferUsage m_usage;
|
||||||
|
|
@ -81,6 +92,7 @@ class NAZARA_API NzBuffer : public NzResource, NzNonCopyable
|
||||||
NzBufferImpl* m_impl;
|
NzBufferImpl* m_impl;
|
||||||
unsigned int m_length;
|
unsigned int m_length;
|
||||||
|
|
||||||
|
static BufferFunction s_bufferFunctions[nzBufferStorage_Max+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NAZARA_BUFFER_HPP
|
#endif // NAZARA_BUFFER_HPP
|
||||||
|
|
@ -7,22 +7,20 @@
|
||||||
#ifndef NAZARA_BUFFERIMPL_HPP
|
#ifndef NAZARA_BUFFERIMPL_HPP
|
||||||
#define NAZARA_BUFFERIMPL_HPP
|
#define NAZARA_BUFFERIMPL_HPP
|
||||||
|
|
||||||
#include <Nazara/Renderer/Buffer.hpp>
|
#include <Nazara/Utility/Buffer.hpp>
|
||||||
|
|
||||||
class NzBufferImpl
|
class NAZARA_API NzBufferImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzBufferImpl() = default;
|
NzBufferImpl() = default;
|
||||||
virtual ~NzBufferImpl();
|
virtual ~NzBufferImpl();
|
||||||
|
|
||||||
virtual void Bind() = 0;
|
|
||||||
|
|
||||||
virtual bool Create(unsigned int size, nzBufferUsage usage = nzBufferUsage_Static) = 0;
|
virtual bool Create(unsigned int size, nzBufferUsage usage = nzBufferUsage_Static) = 0;
|
||||||
virtual void Destroy() = 0;
|
virtual void Destroy() = 0;
|
||||||
|
|
||||||
virtual bool Fill(const void* data, unsigned int offset, unsigned int size) = 0;
|
virtual bool Fill(const void* data, unsigned int offset, unsigned int size) = 0;
|
||||||
|
|
||||||
virtual void* GetBufferPtr() = 0;
|
virtual void* GetPointer() = 0;
|
||||||
|
|
||||||
virtual bool IsHardware() const = 0;
|
virtual bool IsHardware() const = 0;
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ enum nzImageType
|
||||||
nzImageType_3D,
|
nzImageType_3D,
|
||||||
nzImageType_Cubemap,
|
nzImageType_Cubemap,
|
||||||
|
|
||||||
nzImageType_Count
|
nzImageType_Max = nzImageType_Cubemap
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NzImageParams
|
struct NzImageParams
|
||||||
|
|
|
||||||
|
|
@ -8,23 +8,23 @@
|
||||||
#define NAZARA_INDEXBUFFER_HPP
|
#define NAZARA_INDEXBUFFER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Renderer/Buffer.hpp>
|
#include <Nazara/Utility/Buffer.hpp>
|
||||||
|
|
||||||
class NAZARA_API NzIndexBuffer
|
class NAZARA_API NzIndexBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzIndexBuffer(NzBuffer* buffer, unsigned int startIndex, unsigned int indexCount);
|
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(const NzIndexBuffer& indexBuffer);
|
||||||
~NzIndexBuffer();
|
~NzIndexBuffer();
|
||||||
|
|
||||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||||
|
|
||||||
NzBuffer* GetBuffer() const;
|
NzBuffer* GetBuffer() const;
|
||||||
void* GetBufferPtr();
|
|
||||||
const void* GetBufferPtr() const;
|
|
||||||
nzUInt8 GetIndexSize() const;
|
nzUInt8 GetIndexSize() const;
|
||||||
unsigned int GetIndexCount() const;
|
unsigned int GetIndexCount() const;
|
||||||
|
void* GetPointer();
|
||||||
|
const void* GetPointer() const;
|
||||||
unsigned int GetStartIndex() const;
|
unsigned int GetStartIndex() const;
|
||||||
|
|
||||||
bool IsHardware() const;
|
bool IsHardware() const;
|
||||||
|
|
@ -46,7 +46,7 @@ enum nzPixelFormat
|
||||||
nzPixelFormat_Stencil16,
|
nzPixelFormat_Stencil16,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nzPixelFormat_Count
|
nzPixelFormat_Max = nzPixelFormat_RGBA8
|
||||||
};
|
};
|
||||||
|
|
||||||
class NzUtility;
|
class NzUtility;
|
||||||
|
|
@ -69,7 +69,7 @@ class NzPixelFormat
|
||||||
static bool IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat);
|
static bool IsConversionSupported(nzPixelFormat srcFormat, nzPixelFormat dstFormat);
|
||||||
static bool IsValid(nzPixelFormat format);
|
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);
|
static NzString ToString(nzPixelFormat format);
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ class NzPixelFormat
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
static void Uninitialize();
|
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>
|
#include <Nazara/Utility/PixelFormat.inl>
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,6 @@ inline nzUInt8 NzPixelFormat::GetBPP(nzPixelFormat format)
|
||||||
case nzPixelFormat_RGBA8:
|
case nzPixelFormat_RGBA8:
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
case nzPixelFormat_Count:
|
|
||||||
case nzPixelFormat_Undefined:
|
case nzPixelFormat_Undefined:
|
||||||
NazaraError("Invalid pixel format");
|
NazaraError("Invalid pixel format");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -159,7 +158,6 @@ inline bool NzPixelFormat::HasAlpha(nzPixelFormat format)
|
||||||
case nzPixelFormat_RGB8:
|
case nzPixelFormat_RGB8:
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case nzPixelFormat_Count:
|
|
||||||
case nzPixelFormat_Undefined:
|
case nzPixelFormat_Undefined:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -192,15 +190,7 @@ inline bool NzPixelFormat::IsConversionSupported(nzPixelFormat srcFormat, nzPixe
|
||||||
|
|
||||||
inline bool NzPixelFormat::IsValid(nzPixelFormat format)
|
inline bool NzPixelFormat::IsValid(nzPixelFormat format)
|
||||||
{
|
{
|
||||||
switch (format)
|
return format != nzPixelFormat_Undefined;
|
||||||
{
|
|
||||||
case nzPixelFormat_Count:
|
|
||||||
case nzPixelFormat_Undefined:
|
|
||||||
return false;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func)
|
inline void NzPixelFormat::SetConvertFunction(nzPixelFormat srcFormat, nzPixelFormat dstFormat, ConvertFunction func)
|
||||||
|
|
@ -269,7 +259,6 @@ inline NzString NzPixelFormat::ToString(nzPixelFormat format)
|
||||||
case nzPixelFormat_RGBA8:
|
case nzPixelFormat_RGBA8:
|
||||||
return "RGBA8";
|
return "RGBA8";
|
||||||
|
|
||||||
case nzPixelFormat_Count:
|
|
||||||
case nzPixelFormat_Undefined:
|
case nzPixelFormat_Undefined:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,21 +8,21 @@
|
||||||
#define NAZARA_VERTEXBUFFER_HPP
|
#define NAZARA_VERTEXBUFFER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Renderer/Buffer.hpp>
|
#include <Nazara/Utility/Buffer.hpp>
|
||||||
|
|
||||||
class NAZARA_API NzVertexBuffer
|
class NAZARA_API NzVertexBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount);
|
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(const NzVertexBuffer& vertexBuffer);
|
||||||
~NzVertexBuffer();
|
~NzVertexBuffer();
|
||||||
|
|
||||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||||
|
|
||||||
NzBuffer* GetBuffer() const;
|
NzBuffer* GetBuffer() const;
|
||||||
void* GetBufferPtr();
|
void* GetPointer();
|
||||||
const void* GetBufferPtr() const;
|
const void* GetPointer() const;
|
||||||
unsigned int GetStartVertex() const;
|
unsigned int GetStartVertex() const;
|
||||||
nzUInt8 GetTypeSize() const;
|
nzUInt8 GetTypeSize() const;
|
||||||
unsigned int GetVertexCount() const;
|
unsigned int GetVertexCount() const;
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
#include <Nazara/Renderer/Context.hpp>
|
#include <Nazara/Renderer/Context.hpp>
|
||||||
#include <Nazara/Renderer/Renderer.hpp>
|
#include <Nazara/Renderer/Renderer.hpp>
|
||||||
#include <Nazara/Renderer/Texture.hpp>
|
#include <Nazara/Renderer/Texture.hpp>
|
||||||
#include <Nazara/Renderer/VertexDeclaration.hpp>
|
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Renderer/Debug.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
@ -24,7 +24,7 @@ namespace
|
||||||
4 // nzElementUsage_TexCoord
|
4 // nzElementUsage_TexCoord
|
||||||
};
|
};
|
||||||
|
|
||||||
const GLenum shaderType[nzShaderType_Count] = {
|
const GLenum shaderType[nzShaderType_Max+1] = {
|
||||||
GL_FRAGMENT_SHADER, // nzShaderType_Fragment
|
GL_FRAGMENT_SHADER, // nzShaderType_Fragment
|
||||||
GL_GEOMETRY_SHADER, // nzShaderType_Geometry
|
GL_GEOMETRY_SHADER, // nzShaderType_Geometry
|
||||||
GL_VERTEX_SHADER // nzShaderType_Vertex
|
GL_VERTEX_SHADER // nzShaderType_Vertex
|
||||||
|
|
@ -136,7 +136,7 @@ bool NzGLSLShader::Create()
|
||||||
glBindAttribLocation(m_program, attribIndex[nzElementUsage_TexCoord]+i, uniformName.GetConstBuffer());
|
glBindAttribLocation(m_program, attribIndex[nzElementUsage_TexCoord]+i, uniformName.GetConstBuffer());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < nzShaderType_Count; ++i)
|
for (int i = 0; i <= nzShaderType_Max; ++i)
|
||||||
m_shaders[i] = 0;
|
m_shaders[i] = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ class NzGLSLShader : public NzShaderImpl
|
||||||
mutable std::map<NzString, GLint> m_idCache;
|
mutable std::map<NzString, GLint> m_idCache;
|
||||||
std::map<GLint, TextureSlot> m_textures;
|
std::map<GLint, TextureSlot> m_textures;
|
||||||
GLuint m_program;
|
GLuint m_program;
|
||||||
GLuint m_shaders[nzShaderType_Count];
|
GLuint m_shaders[nzShaderType_Max+1];
|
||||||
NzShader* m_parent;
|
NzShader* m_parent;
|
||||||
NzString m_log;
|
NzString m_log;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ bool NzHardwareBuffer::Fill(const void* data, unsigned int offset, unsigned int
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* NzHardwareBuffer::GetBufferPtr()
|
void* NzHardwareBuffer::GetPointer()
|
||||||
{
|
{
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@
|
||||||
#define NAZARA_HARDWAREBUFFER_HPP
|
#define NAZARA_HARDWAREBUFFER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Renderer/BufferImpl.hpp>
|
|
||||||
#include <Nazara/Renderer/OpenGL.hpp>
|
#include <Nazara/Renderer/OpenGL.hpp>
|
||||||
|
#include <Nazara/Utility/BufferImpl.hpp>
|
||||||
|
|
||||||
class NzHardwareBuffer : public NzBufferImpl
|
class NzHardwareBuffer : public NzBufferImpl
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +24,7 @@ class NzHardwareBuffer : public NzBufferImpl
|
||||||
|
|
||||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||||
|
|
||||||
void* GetBufferPtr();
|
void* GetPointer();
|
||||||
|
|
||||||
bool IsHardware() const;
|
bool IsHardware() const;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -400,6 +400,9 @@ bool NzOpenGL::Initialize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PixelBufferObject
|
||||||
|
openGLextensions[NzOpenGL::PixelBufferObject] = (openGLversion >= 210 || IsSupported("GL_ARB_pixel_buffer_object"));
|
||||||
|
|
||||||
// SeparateShaderObjects
|
// SeparateShaderObjects
|
||||||
if (openGLversion >= 400 || IsSupported("GL_ARB_gpu_shader_fp64"))
|
if (openGLversion >= 400 || IsSupported("GL_ARB_gpu_shader_fp64"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,16 +6,17 @@
|
||||||
#include <Nazara/Renderer/Renderer.hpp>
|
#include <Nazara/Renderer/Renderer.hpp>
|
||||||
#include <Nazara/Core/Color.hpp>
|
#include <Nazara/Core/Color.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Renderer/BufferImpl.hpp>
|
|
||||||
#include <Nazara/Renderer/Config.hpp>
|
#include <Nazara/Renderer/Config.hpp>
|
||||||
#include <Nazara/Renderer/Context.hpp>
|
#include <Nazara/Renderer/Context.hpp>
|
||||||
#include <Nazara/Renderer/IndexBuffer.hpp>
|
#include <Nazara/Renderer/HardwareBuffer.hpp>
|
||||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||||
#include <Nazara/Renderer/Shader.hpp>
|
#include <Nazara/Renderer/Shader.hpp>
|
||||||
#include <Nazara/Renderer/ShaderImpl.hpp>
|
#include <Nazara/Renderer/ShaderImpl.hpp>
|
||||||
#include <Nazara/Renderer/VertexBuffer.hpp>
|
#include <Nazara/Utility/BufferImpl.hpp>
|
||||||
#include <Nazara/Renderer/VertexDeclaration.hpp>
|
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||||
#include <Nazara/Utility/Utility.hpp>
|
#include <Nazara/Utility/Utility.hpp>
|
||||||
|
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||||
|
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Renderer/Debug.hpp>
|
||||||
|
|
||||||
|
|
@ -128,6 +129,11 @@ namespace
|
||||||
GL_REPLACE, // nzStencilOperation_Replace
|
GL_REPLACE, // nzStencilOperation_Replace
|
||||||
GL_ZERO // nzStencilOperation_Zero
|
GL_ZERO // nzStencilOperation_Zero
|
||||||
};
|
};
|
||||||
|
|
||||||
|
NzBufferImpl* HardwareBufferFunction(NzBuffer* parent, nzBufferType type)
|
||||||
|
{
|
||||||
|
return new NzHardwareBuffer(parent, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NzRenderer::NzRenderer()
|
NzRenderer::NzRenderer()
|
||||||
|
|
@ -219,7 +225,7 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glDrawElements(openglPrimitive[primitive], indexCount, type, reinterpret_cast<const nzUInt8*>(m_indexBuffer->GetBufferPtr()) + firstIndex*indexSize);
|
glDrawElements(openglPrimitive[primitive], indexCount, type, reinterpret_cast<const nzUInt8*>(m_indexBuffer->GetPointer()) + firstIndex*indexSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount)
|
void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount)
|
||||||
|
|
@ -333,15 +339,13 @@ bool NzRenderer::Initialize()
|
||||||
m_utilityModule = new NzUtility;
|
m_utilityModule = new NzUtility;
|
||||||
m_utilityModule->Initialize();
|
m_utilityModule->Initialize();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
m_utilityModule = nullptr;
|
||||||
|
|
||||||
if (NzOpenGL::Initialize())
|
if (NzOpenGL::Initialize())
|
||||||
{
|
{
|
||||||
NzContext::EnsureContext();
|
NzContext::EnsureContext();
|
||||||
|
|
||||||
const NzContext* context = NzContext::GetReference();
|
|
||||||
bool compatibility = context->GetParameters().compatibilityProfile;
|
|
||||||
|
|
||||||
m_vaoUpdated = false;
|
|
||||||
m_indexBuffer = nullptr;
|
m_indexBuffer = nullptr;
|
||||||
m_shader = nullptr;
|
m_shader = nullptr;
|
||||||
m_stencilCompare = nzRendererComparison_Always;
|
m_stencilCompare = nzRendererComparison_Always;
|
||||||
|
|
@ -353,6 +357,7 @@ bool NzRenderer::Initialize()
|
||||||
m_stencilReference = 0;
|
m_stencilReference = 0;
|
||||||
m_stencilZFail = nzStencilOperation_Keep;
|
m_stencilZFail = nzStencilOperation_Keep;
|
||||||
m_target = nullptr;
|
m_target = nullptr;
|
||||||
|
m_vaoUpdated = false;
|
||||||
m_vertexBuffer = nullptr;
|
m_vertexBuffer = nullptr;
|
||||||
m_vertexDeclaration = nullptr;
|
m_vertexDeclaration = nullptr;
|
||||||
|
|
||||||
|
|
@ -362,7 +367,7 @@ bool NzRenderer::Initialize()
|
||||||
m_capabilities[nzRendererCap_HardwareBuffer] = true; // Natif depuis OpenGL 1.5
|
m_capabilities[nzRendererCap_HardwareBuffer] = true; // Natif depuis OpenGL 1.5
|
||||||
m_capabilities[nzRendererCap_MultipleRenderTargets] = true; // Natif depuis OpenGL 2.0
|
m_capabilities[nzRendererCap_MultipleRenderTargets] = true; // Natif depuis OpenGL 2.0
|
||||||
m_capabilities[nzRendererCap_OcclusionQuery] = true; // Natif depuis OpenGL 1.5
|
m_capabilities[nzRendererCap_OcclusionQuery] = true; // Natif depuis OpenGL 1.5
|
||||||
m_capabilities[nzRendererCap_SoftwareBuffer] = compatibility || NzOpenGL::GetVersion() <= 300; // Déprécié en OpenGL 3
|
m_capabilities[nzRendererCap_PixelBufferObject] = NzOpenGL::IsSupported(NzOpenGL::PixelBufferObject);
|
||||||
m_capabilities[nzRendererCap_Texture3D] = NzOpenGL::IsSupported(NzOpenGL::Texture3D);
|
m_capabilities[nzRendererCap_Texture3D] = NzOpenGL::IsSupported(NzOpenGL::Texture3D);
|
||||||
m_capabilities[nzRendererCap_TextureCubemap] = true; // Natif depuis OpenGL 1.3
|
m_capabilities[nzRendererCap_TextureCubemap] = true; // Natif depuis OpenGL 1.3
|
||||||
m_capabilities[nzRendererCap_TextureMulti] = true; // Natif depuis OpenGL 1.3
|
m_capabilities[nzRendererCap_TextureMulti] = true; // Natif depuis OpenGL 1.3
|
||||||
|
|
@ -398,6 +403,8 @@ bool NzRenderer::Initialize()
|
||||||
else
|
else
|
||||||
m_maxTextureUnit = 1;
|
m_maxTextureUnit = 1;
|
||||||
|
|
||||||
|
NzBuffer::SetBufferFunction(nzBufferStorage_Hardware, HardwareBufferFunction);
|
||||||
|
|
||||||
s_initialized = true;
|
s_initialized = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -497,9 +504,16 @@ void NzRenderer::SetFaceFilling(nzFaceFilling fillingMode)
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, faceFillingMode[fillingMode]);
|
glPolygonMode(GL_FRONT_AND_BACK, faceFillingMode[fillingMode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NzRenderer::SetIndexBuffer(const NzIndexBuffer* indexBuffer)
|
bool NzRenderer::SetIndexBuffer(const NzIndexBuffer* indexBuffer)
|
||||||
{
|
{
|
||||||
|
#if NAZARA_RENDERER_SAFE
|
||||||
|
if (indexBuffer && !indexBuffer->IsHardware())
|
||||||
|
{
|
||||||
|
NazaraError("Buffer must be hardware");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (indexBuffer != m_indexBuffer)
|
if (indexBuffer != m_indexBuffer)
|
||||||
{
|
{
|
||||||
m_indexBuffer = indexBuffer;
|
m_indexBuffer = indexBuffer;
|
||||||
|
|
@ -635,6 +649,14 @@ bool NzRenderer::SetTarget(NzRenderTarget* target)
|
||||||
|
|
||||||
bool NzRenderer::SetVertexBuffer(const NzVertexBuffer* vertexBuffer)
|
bool NzRenderer::SetVertexBuffer(const NzVertexBuffer* vertexBuffer)
|
||||||
{
|
{
|
||||||
|
#if NAZARA_RENDERER_SAFE
|
||||||
|
if (vertexBuffer && !vertexBuffer->IsHardware())
|
||||||
|
{
|
||||||
|
NazaraError("Buffer must be hardware");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_vertexBuffer != vertexBuffer)
|
if (m_vertexBuffer != vertexBuffer)
|
||||||
{
|
{
|
||||||
m_vertexBuffer = vertexBuffer;
|
m_vertexBuffer = vertexBuffer;
|
||||||
|
|
@ -675,13 +697,7 @@ void NzRenderer::SetViewport(const NzRectui& viewport)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int width = m_target->GetWidth();
|
unsigned int width = m_target->GetWidth();
|
||||||
if (viewport.x+viewport.width >= width)
|
if (viewport.x+viewport.width > width || viewport.y+viewport.height > height)
|
||||||
{
|
|
||||||
NazaraError("Rectangle dimensions are out of bounds");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (viewport.y+viewport.height >= height)
|
|
||||||
{
|
{
|
||||||
NazaraError("Rectangle dimensions are out of bounds");
|
NazaraError("Rectangle dimensions are out of bounds");
|
||||||
return;
|
return;
|
||||||
|
|
@ -812,9 +828,10 @@ bool NzRenderer::EnsureStateUpdate()
|
||||||
|
|
||||||
if (update)
|
if (update)
|
||||||
{
|
{
|
||||||
m_vertexBuffer->GetBuffer()->GetImpl()->Bind();
|
NzHardwareBuffer* vertexBuffer = static_cast<NzHardwareBuffer*>(m_vertexBuffer->GetBuffer()->GetImpl());
|
||||||
|
vertexBuffer->Bind();
|
||||||
|
|
||||||
const nzUInt8* buffer = reinterpret_cast<const nzUInt8*>(m_vertexBuffer->GetBufferPtr());
|
const nzUInt8* buffer = reinterpret_cast<const nzUInt8*>(m_vertexBuffer->GetPointer());
|
||||||
|
|
||||||
///FIXME: Améliorer les déclarations pour permettre de faire ça plus simplement
|
///FIXME: Améliorer les déclarations pour permettre de faire ça plus simplement
|
||||||
for (int i = 0; i < 12; ++i) // Solution temporaire, à virer
|
for (int i = 0; i < 12; ++i) // Solution temporaire, à virer
|
||||||
|
|
@ -836,7 +853,10 @@ bool NzRenderer::EnsureStateUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_indexBuffer)
|
if (m_indexBuffer)
|
||||||
m_indexBuffer->GetBuffer()->GetImpl()->Bind();
|
{
|
||||||
|
NzHardwareBuffer* indexBuffer = static_cast<NzHardwareBuffer*>(m_indexBuffer->GetBuffer()->GetImpl());
|
||||||
|
indexBuffer->Bind();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vaoSupported)
|
if (vaoSupported)
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,6 @@ namespace
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case nzPixelFormat_Undefined:
|
case nzPixelFormat_Undefined:
|
||||||
case nzPixelFormat_Count:
|
|
||||||
NazaraInternalError("Invalid pixel format");
|
NazaraInternalError("Invalid pixel format");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -252,8 +251,8 @@ namespace
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned short lockedLevel[nzImageType_Count] = {0};
|
static unsigned short lockedLevel[nzImageType_Max+1] = {0};
|
||||||
static GLuint lockedPrevious[nzImageType_Count] = {0};
|
static GLuint lockedPrevious[nzImageType_Max+1] = {0};
|
||||||
|
|
||||||
void LockTexture(NzTextureImpl* impl)
|
void LockTexture(NzTextureImpl* impl)
|
||||||
{
|
{
|
||||||
|
|
@ -1576,7 +1575,6 @@ bool NzTexture::IsFormatSupported(nzPixelFormat format)
|
||||||
}
|
}
|
||||||
|
|
||||||
case nzPixelFormat_Undefined:
|
case nzPixelFormat_Undefined:
|
||||||
case nzPixelFormat_Count:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,21 @@
|
||||||
// This file is part of the "Nazara Engine".
|
// This file is part of the "Nazara Engine".
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Renderer/OpenGL.hpp>
|
#include <Nazara/Utility/Buffer.hpp>
|
||||||
#include <Nazara/Renderer/Buffer.hpp>
|
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Renderer/Config.hpp>
|
#include <Nazara/Utility/BufferImpl.hpp>
|
||||||
#include <Nazara/Renderer/HardwareBuffer.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <Nazara/Renderer/Renderer.hpp>
|
#include <Nazara/Utility/SoftwareBuffer.hpp>
|
||||||
#include <Nazara/Renderer/SoftwareBuffer.hpp>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
nzRendererCap storageToCapability[] = {
|
NzBufferImpl* SoftwareBufferFunction(NzBuffer* parent, nzBufferType type)
|
||||||
nzRendererCap_HardwareBuffer, // nzBufferStorage_Hardware
|
{
|
||||||
nzRendererCap_SoftwareBuffer, // nzBufferStorage_Software
|
return new NzSoftwareBuffer(parent, type);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NzBuffer::NzBuffer(nzBufferType type) :
|
NzBuffer::NzBuffer(nzBufferType type) :
|
||||||
|
|
@ -28,11 +27,11 @@ m_length(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
NzBuffer::NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferUsage usage) :
|
NzBuffer::NzBuffer(nzBufferType type, unsigned int length, nzUInt8 typeSize, nzBufferStorage storage, nzBufferUsage usage) :
|
||||||
m_type(type),
|
m_type(type),
|
||||||
m_impl(nullptr)
|
m_impl(nullptr)
|
||||||
{
|
{
|
||||||
Create(length, typeSize, usage);
|
Create(length, typeSize, storage, usage);
|
||||||
|
|
||||||
#ifdef NAZARA_DEBUG
|
#ifdef NAZARA_DEBUG
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
|
|
@ -50,6 +49,26 @@ NzBuffer::~NzBuffer()
|
||||||
|
|
||||||
bool NzBuffer::CopyContent(NzBuffer& buffer)
|
bool NzBuffer::CopyContent(NzBuffer& buffer)
|
||||||
{
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!m_impl)
|
||||||
|
{
|
||||||
|
NazaraError("Buffer must be valid");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buffer.IsValid())
|
||||||
|
{
|
||||||
|
NazaraError("Source buffer must be valid");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buffer.GetTypeSize() != m_typeSize)
|
||||||
|
{
|
||||||
|
NazaraError("Source buffer type size does not match buffer type size");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void* ptr = buffer.Map(nzBufferAccess_ReadOnly);
|
void* ptr = buffer.Map(nzBufferAccess_ReadOnly);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
|
|
@ -57,7 +76,7 @@ bool NzBuffer::CopyContent(NzBuffer& buffer)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool r = Fill(ptr, 0, m_length);
|
bool r = Fill(ptr, 0, buffer.GetLength());
|
||||||
|
|
||||||
if (!buffer.Unmap())
|
if (!buffer.Unmap())
|
||||||
NazaraWarning("Failed to unmap source buffer");
|
NazaraWarning("Failed to unmap source buffer");
|
||||||
|
|
@ -65,41 +84,28 @@ bool NzBuffer::CopyContent(NzBuffer& buffer)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NzBuffer::Create(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage)
|
bool NzBuffer::Create(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage, nzBufferUsage usage)
|
||||||
{
|
{
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
// On tente d'abord de faire un buffer hardware, si supporté
|
// On tente d'abord de faire un buffer hardware, si supporté
|
||||||
if (NazaraRenderer->HasCapability(nzRendererCap_HardwareBuffer))
|
if (s_bufferFunctions[storage])
|
||||||
{
|
{
|
||||||
m_impl = new NzHardwareBuffer(this, m_type);
|
NzBufferImpl* impl = s_bufferFunctions[storage](this, m_type);
|
||||||
if (!m_impl->Create(length*typeSize, usage))
|
if (!impl->Create(length*typeSize, usage))
|
||||||
{
|
{
|
||||||
NazaraWarning("Failed to create hardware buffer, trying to create software buffer...");
|
NazaraError("Failed to create buffer");
|
||||||
|
delete impl;
|
||||||
|
|
||||||
delete m_impl;
|
return false;
|
||||||
m_impl = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_impl = impl;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (!m_impl)
|
|
||||||
{
|
{
|
||||||
if (!NazaraRenderer->HasCapability(nzRendererCap_SoftwareBuffer))
|
NazaraError("Buffer storage not supported");
|
||||||
{
|
return false;
|
||||||
// Ne devrait jamais arriver
|
|
||||||
NazaraError("Software buffer not supported");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_impl = new NzSoftwareBuffer(this, m_type);
|
|
||||||
if (!m_impl->Create(length*typeSize, usage))
|
|
||||||
{
|
|
||||||
NazaraError("Failed to create software buffer");
|
|
||||||
delete m_impl;
|
|
||||||
m_impl = nullptr;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_length = length;
|
m_length = length;
|
||||||
|
|
@ -122,10 +128,10 @@ void NzBuffer::Destroy()
|
||||||
|
|
||||||
bool NzBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
bool NzBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
{
|
{
|
||||||
NazaraError("Buffer not created");
|
NazaraError("Buffer not valid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,32 +145,6 @@ bool NzBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
||||||
return m_impl->Fill(data, offset*m_typeSize, length*m_typeSize);
|
return m_impl->Fill(data, offset*m_typeSize, length*m_typeSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* NzBuffer::GetBufferPtr()
|
|
||||||
{
|
|
||||||
#if NAZARA_RENDERER_SAFE
|
|
||||||
if (!m_impl)
|
|
||||||
{
|
|
||||||
NazaraError("Buffer not created");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return m_impl->GetBufferPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
const void* NzBuffer::GetBufferPtr() const
|
|
||||||
{
|
|
||||||
#if NAZARA_RENDERER_SAFE
|
|
||||||
if (!m_impl)
|
|
||||||
{
|
|
||||||
NazaraError("Buffer not created");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return m_impl->GetBufferPtr();
|
|
||||||
}
|
|
||||||
|
|
||||||
NzBufferImpl* NzBuffer::GetImpl() const
|
NzBufferImpl* NzBuffer::GetImpl() const
|
||||||
{
|
{
|
||||||
return m_impl;
|
return m_impl;
|
||||||
|
|
@ -175,6 +155,32 @@ unsigned int NzBuffer::GetLength() const
|
||||||
return m_length;
|
return m_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* NzBuffer::GetPointer()
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!m_impl)
|
||||||
|
{
|
||||||
|
NazaraError("Buffer not valid");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_impl->GetPointer();
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* NzBuffer::GetPointer() const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!m_impl)
|
||||||
|
{
|
||||||
|
NazaraError("Buffer not valid");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return m_impl->GetPointer();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int NzBuffer::GetSize() const
|
unsigned int NzBuffer::GetSize() const
|
||||||
{
|
{
|
||||||
return m_length*m_typeSize;
|
return m_length*m_typeSize;
|
||||||
|
|
@ -205,12 +211,17 @@ bool NzBuffer::IsHardware() const
|
||||||
return m_storage == nzBufferStorage_Hardware;
|
return m_storage == nzBufferStorage_Hardware;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NzBuffer::IsValid() const
|
||||||
|
{
|
||||||
|
return m_impl != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void* NzBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int length)
|
void* NzBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
{
|
{
|
||||||
NazaraError("Buffer not created");
|
NazaraError("Buffer not valid");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,10 +237,10 @@ void* NzBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int len
|
||||||
|
|
||||||
bool NzBuffer::Unmap()
|
bool NzBuffer::Unmap()
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_impl)
|
if (!m_impl)
|
||||||
{
|
{
|
||||||
NazaraError("Buffer not created");
|
NazaraError("Buffer not valid");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -239,5 +250,24 @@ bool NzBuffer::Unmap()
|
||||||
|
|
||||||
bool NzBuffer::IsSupported(nzBufferStorage storage)
|
bool NzBuffer::IsSupported(nzBufferStorage storage)
|
||||||
{
|
{
|
||||||
return NazaraRenderer->HasCapability(storageToCapability[storage]);
|
return s_bufferFunctions[storage] != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NzBuffer::SetBufferFunction(nzBufferStorage storage, BufferFunction func)
|
||||||
|
{
|
||||||
|
s_bufferFunctions[storage] = func;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NzBuffer::Initialize()
|
||||||
|
{
|
||||||
|
s_bufferFunctions[nzBufferStorage_Software] = SoftwareBufferFunction;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NzBuffer::Uninitialize()
|
||||||
|
{
|
||||||
|
std::memset(s_bufferFunctions, 0, (nzBufferStorage_Max+1)*sizeof(NzBuffer::BufferFunction));
|
||||||
|
}
|
||||||
|
|
||||||
|
NzBuffer::BufferFunction NzBuffer::s_bufferFunctions[nzBufferStorage_Max+1] = {0};
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// This file is part of the "Nazara Engine".
|
// This file is part of the "Nazara Engine".
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Renderer/BufferImpl.hpp>
|
#include <Nazara/Utility/BufferImpl.hpp>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
NzBufferImpl::~NzBufferImpl() = default;
|
NzBufferImpl::~NzBufferImpl() = default;
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
// This file is part of the "Nazara Engine".
|
// This file is part of the "Nazara Engine".
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Renderer/IndexBuffer.hpp>
|
#include <Nazara/Utility/IndexBuffer.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Renderer/Config.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
NzIndexBuffer::NzIndexBuffer(NzBuffer* buffer, unsigned int startIndex, unsigned int indexCount) :
|
NzIndexBuffer::NzIndexBuffer(NzBuffer* buffer, unsigned int startIndex, unsigned int indexCount) :
|
||||||
m_buffer(buffer),
|
m_buffer(buffer),
|
||||||
|
|
@ -31,7 +31,7 @@ m_startIndex(startIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NzIndexBuffer::NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferUsage usage) :
|
NzIndexBuffer::NzIndexBuffer(unsigned int length, nzUInt8 indexSize, nzBufferStorage storage, nzBufferUsage usage) :
|
||||||
m_ownsBuffer(true),
|
m_ownsBuffer(true),
|
||||||
m_indexCount(length),
|
m_indexCount(length),
|
||||||
m_startIndex(0)
|
m_startIndex(0)
|
||||||
|
|
@ -46,13 +46,14 @@ m_startIndex(0)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_buffer = new NzBuffer(nzBufferType_Index, length, indexSize, usage);
|
m_buffer = new NzBuffer(nzBufferType_Index, length, indexSize, storage, usage);
|
||||||
m_buffer->AddResourceReference();
|
m_buffer->AddResourceReference();
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
NzIndexBuffer::NzIndexBuffer(const NzIndexBuffer& indexBuffer) :
|
NzIndexBuffer::NzIndexBuffer(const NzIndexBuffer& indexBuffer) :
|
||||||
m_buffer(indexBuffer.m_buffer),
|
m_buffer(indexBuffer.m_buffer),
|
||||||
|
m_ownsBuffer(indexBuffer.m_ownsBuffer),
|
||||||
m_indexCount(indexBuffer.m_indexCount),
|
m_indexCount(indexBuffer.m_indexCount),
|
||||||
m_startIndex(indexBuffer.m_startIndex)
|
m_startIndex(indexBuffer.m_startIndex)
|
||||||
{
|
{
|
||||||
|
|
@ -60,7 +61,9 @@ m_startIndex(indexBuffer.m_startIndex)
|
||||||
{
|
{
|
||||||
if (m_ownsBuffer)
|
if (m_ownsBuffer)
|
||||||
{
|
{
|
||||||
m_buffer = new NzBuffer(nzBufferType_Index, indexBuffer.m_buffer->GetLength(), indexBuffer.m_buffer->GetSize(), indexBuffer.m_buffer->GetUsage());
|
NzBuffer* buffer = indexBuffer.m_buffer;
|
||||||
|
|
||||||
|
m_buffer = new NzBuffer(nzBufferType_Index, buffer->GetLength(), buffer->GetSize(), buffer->GetStorage(), buffer->GetUsage());
|
||||||
m_buffer->AddResourceReference();
|
m_buffer->AddResourceReference();
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
m_buffer->CopyContent(*indexBuffer.m_buffer);
|
m_buffer->CopyContent(*indexBuffer.m_buffer);
|
||||||
|
|
@ -71,8 +74,6 @@ m_startIndex(indexBuffer.m_startIndex)
|
||||||
m_buffer->AddResourceReference();
|
m_buffer->AddResourceReference();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
m_buffer = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NzIndexBuffer::~NzIndexBuffer()
|
NzIndexBuffer::~NzIndexBuffer()
|
||||||
|
|
@ -83,7 +84,7 @@ NzIndexBuffer::~NzIndexBuffer()
|
||||||
|
|
||||||
bool NzIndexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
bool NzIndexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_buffer)
|
if (!m_buffer)
|
||||||
{
|
{
|
||||||
NazaraError("Impossible to fill sequential buffer");
|
NazaraError("Impossible to fill sequential buffer");
|
||||||
|
|
@ -105,38 +106,12 @@ NzBuffer* NzIndexBuffer::GetBuffer() const
|
||||||
return m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* NzIndexBuffer::GetBufferPtr()
|
|
||||||
{
|
|
||||||
#if NAZARA_RENDERER_SAFE
|
|
||||||
if (!m_buffer)
|
|
||||||
{
|
|
||||||
NazaraError("Sequential index buffer: Buffer has no pointer");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return reinterpret_cast<nzUInt8*>(m_buffer->GetBufferPtr()) + m_startIndex*m_buffer->GetTypeSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
const void* NzIndexBuffer::GetBufferPtr() const
|
|
||||||
{
|
|
||||||
#if NAZARA_RENDERER_SAFE
|
|
||||||
if (!m_buffer)
|
|
||||||
{
|
|
||||||
NazaraError("Sequential index buffer: Buffer has no pointer");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return reinterpret_cast<const nzUInt8*>(m_buffer->GetBufferPtr()) + m_startIndex*m_buffer->GetTypeSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
nzUInt8 NzIndexBuffer::GetIndexSize() const
|
nzUInt8 NzIndexBuffer::GetIndexSize() const
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_buffer)
|
if (!m_buffer)
|
||||||
{
|
{
|
||||||
NazaraError("Sequential index buffer: Buffer has no index size");
|
NazaraError("Sequential index buffer has no index size");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -144,6 +119,32 @@ nzUInt8 NzIndexBuffer::GetIndexSize() const
|
||||||
return m_buffer->GetTypeSize();
|
return m_buffer->GetTypeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void* NzIndexBuffer::GetPointer()
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!m_buffer)
|
||||||
|
{
|
||||||
|
NazaraError("Sequential index buffer: Buffer has no pointer");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return reinterpret_cast<nzUInt8*>(m_buffer->GetPointer()) + m_startIndex*m_buffer->GetTypeSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
const void* NzIndexBuffer::GetPointer() const
|
||||||
|
{
|
||||||
|
#if NAZARA_UTILITY_SAFE
|
||||||
|
if (!m_buffer)
|
||||||
|
{
|
||||||
|
NazaraError("Sequential index buffer has no pointer");
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return reinterpret_cast<const nzUInt8*>(m_buffer->GetPointer()) + m_startIndex*m_buffer->GetTypeSize();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int NzIndexBuffer::GetIndexCount() const
|
unsigned int NzIndexBuffer::GetIndexCount() const
|
||||||
{
|
{
|
||||||
return m_indexCount;
|
return m_indexCount;
|
||||||
|
|
@ -156,10 +157,10 @@ unsigned int NzIndexBuffer::GetStartIndex() const
|
||||||
|
|
||||||
bool NzIndexBuffer::IsHardware() const
|
bool NzIndexBuffer::IsHardware() const
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_buffer)
|
if (!m_buffer)
|
||||||
{
|
{
|
||||||
NazaraError("Sequential index buffer is neither hardware or software");
|
NazaraWarning("Sequential index buffers are neither hardware or software");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -174,7 +175,7 @@ bool NzIndexBuffer::IsSequential() const
|
||||||
|
|
||||||
void* NzIndexBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int length)
|
void* NzIndexBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_buffer)
|
if (!m_buffer)
|
||||||
{
|
{
|
||||||
NazaraError("Impossible to map sequential index buffer");
|
NazaraError("Impossible to map sequential index buffer");
|
||||||
|
|
@ -193,7 +194,7 @@ void* NzIndexBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned in
|
||||||
|
|
||||||
bool NzIndexBuffer::Unmap()
|
bool NzIndexBuffer::Unmap()
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_buffer)
|
if (!m_buffer)
|
||||||
{
|
{
|
||||||
NazaraError("Impossible to unlock sequential index buffer");
|
NazaraError("Impossible to unlock sequential index buffer");
|
||||||
|
|
@ -1314,7 +1314,7 @@ bool NzPixelFormat::Initialize()
|
||||||
|
|
||||||
void NzPixelFormat::Uninitialize()
|
void NzPixelFormat::Uninitialize()
|
||||||
{
|
{
|
||||||
std::memset(s_convertFunctions, 0, nzPixelFormat_Count*nzPixelFormat_Count*sizeof(NzPixelFormat::ConvertFunction));
|
std::memset(s_convertFunctions, 0, (nzPixelFormat_Max+1)*(nzPixelFormat_Max+1)*sizeof(NzPixelFormat::ConvertFunction));
|
||||||
}
|
}
|
||||||
|
|
||||||
NzPixelFormat::ConvertFunction NzPixelFormat::s_convertFunctions[nzPixelFormat_Count][nzPixelFormat_Count] = {{0}}; ///FIXME: Fonctionne correctement ?
|
NzPixelFormat::ConvertFunction NzPixelFormat::s_convertFunctions[nzPixelFormat_Max+1][nzPixelFormat_Max+1] = {{0}}; ///FIXME: Fonctionne correctement ?
|
||||||
|
|
|
||||||
|
|
@ -2,22 +2,12 @@
|
||||||
// This file is part of the "Nazara Engine".
|
// This file is part of the "Nazara Engine".
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Renderer/OpenGL.hpp>
|
#include <Nazara/Utility/SoftwareBuffer.hpp>
|
||||||
#include <Nazara/Renderer/SoftwareBuffer.hpp>
|
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Renderer/Config.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <Nazara/Renderer/Context.hpp>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
GLenum bufferTarget[] = {
|
|
||||||
GL_ELEMENT_ARRAY_BUFFER, // nzBufferType_Index,
|
|
||||||
GL_ARRAY_BUFFER, // nzBufferType_Vertex
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
NzSoftwareBuffer::NzSoftwareBuffer(NzBuffer* parent, nzBufferType type) :
|
NzSoftwareBuffer::NzSoftwareBuffer(NzBuffer* parent, nzBufferType type) :
|
||||||
m_type(type)
|
m_type(type)
|
||||||
|
|
@ -29,19 +19,6 @@ NzSoftwareBuffer::~NzSoftwareBuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void NzSoftwareBuffer::Bind()
|
|
||||||
{
|
|
||||||
#ifdef NAZARA_DEBUG
|
|
||||||
if (NzContext::GetCurrent() == nullptr)
|
|
||||||
{
|
|
||||||
NazaraError("No active context");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glBindBuffer(bufferTarget[m_type], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool NzSoftwareBuffer::Create(unsigned int size, nzBufferUsage usage)
|
bool NzSoftwareBuffer::Create(unsigned int size, nzBufferUsage usage)
|
||||||
{
|
{
|
||||||
NazaraUnused(usage);
|
NazaraUnused(usage);
|
||||||
|
|
@ -69,7 +46,7 @@ void NzSoftwareBuffer::Destroy()
|
||||||
|
|
||||||
bool NzSoftwareBuffer::Fill(const void* data, unsigned int offset, unsigned int size)
|
bool NzSoftwareBuffer::Fill(const void* data, unsigned int offset, unsigned int size)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (m_mapped)
|
if (m_mapped)
|
||||||
{
|
{
|
||||||
NazaraError("Buffer already mapped");
|
NazaraError("Buffer already mapped");
|
||||||
|
|
@ -82,7 +59,7 @@ bool NzSoftwareBuffer::Fill(const void* data, unsigned int offset, unsigned int
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* NzSoftwareBuffer::GetBufferPtr()
|
void* NzSoftwareBuffer::GetPointer()
|
||||||
{
|
{
|
||||||
return m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
@ -97,7 +74,7 @@ void* NzSoftwareBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned
|
||||||
NazaraUnused(access);
|
NazaraUnused(access);
|
||||||
NazaraUnused(size);
|
NazaraUnused(size);
|
||||||
|
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (m_mapped)
|
if (m_mapped)
|
||||||
{
|
{
|
||||||
NazaraError("Buffer already mapped");
|
NazaraError("Buffer already mapped");
|
||||||
|
|
@ -112,7 +89,7 @@ void* NzSoftwareBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned
|
||||||
|
|
||||||
bool NzSoftwareBuffer::Unmap()
|
bool NzSoftwareBuffer::Unmap()
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (!m_mapped)
|
if (!m_mapped)
|
||||||
{
|
{
|
||||||
NazaraError("Buffer not mapped");
|
NazaraError("Buffer not mapped");
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
#define NAZARA_SOFTWAREBUFFER_HPP
|
#define NAZARA_SOFTWAREBUFFER_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Renderer/BufferImpl.hpp>
|
#include <Nazara/Utility/BufferImpl.hpp>
|
||||||
|
|
||||||
class NzSoftwareBuffer : public NzBufferImpl
|
class NzSoftwareBuffer : public NzBufferImpl
|
||||||
{
|
{
|
||||||
|
|
@ -16,14 +16,12 @@ class NzSoftwareBuffer : public NzBufferImpl
|
||||||
NzSoftwareBuffer(NzBuffer* parent, nzBufferType type);
|
NzSoftwareBuffer(NzBuffer* parent, nzBufferType type);
|
||||||
~NzSoftwareBuffer();
|
~NzSoftwareBuffer();
|
||||||
|
|
||||||
void Bind();
|
|
||||||
|
|
||||||
bool Create(unsigned int size, nzBufferUsage usage = nzBufferUsage_Static);
|
bool Create(unsigned int size, nzBufferUsage usage = nzBufferUsage_Static);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
bool Fill(const void* data, unsigned int offset, unsigned int length);
|
||||||
|
|
||||||
void* GetBufferPtr();
|
void* GetPointer();
|
||||||
|
|
||||||
bool IsHardware() const;
|
bool IsHardware() const;
|
||||||
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <Nazara/Utility/Utility.hpp>
|
#include <Nazara/Utility/Utility.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
#include <Nazara/Utility/Buffer.hpp>
|
||||||
#include <Nazara/Utility/Config.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <Nazara/Utility/Loaders/PCX.hpp>
|
#include <Nazara/Utility/Loaders/PCX.hpp>
|
||||||
#include <Nazara/Utility/Loaders/STB.hpp>
|
#include <Nazara/Utility/Loaders/STB.hpp>
|
||||||
|
|
@ -31,9 +32,15 @@ bool NzUtility::Initialize()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (!NzBuffer::Initialize())
|
||||||
|
{
|
||||||
|
NazaraError("Failed to initialize buffers");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!NzPixelFormat::Initialize())
|
if (!NzPixelFormat::Initialize())
|
||||||
{
|
{
|
||||||
NazaraError("Failed to initialize pixel format");
|
NazaraError("Failed to initialize pixel formats");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -45,10 +52,10 @@ bool NzUtility::Initialize()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loaders spécialisés
|
/// Loaders spécialisés
|
||||||
NzLoaders_PCX_Register(); // Loader de fichiers .PCX (1, 4, 8, 24)
|
NzLoaders_PCX_Register(); // Loader de fichiers .PCX (1, 4, 8, 24)
|
||||||
|
|
||||||
// Loaders génériques (En dernier pour donner la priorité aux loaders spécialisés)
|
/// Loaders génériques (En dernier pour donner la priorité aux loaders spécialisés)
|
||||||
NzLoaders_STB_Register(); // Loader générique (STB)
|
NzLoaders_STB_Register(); // Loader générique (STB)
|
||||||
|
|
||||||
s_initialized = true;
|
s_initialized = true;
|
||||||
|
|
@ -70,8 +77,8 @@ void NzUtility::Uninitialize()
|
||||||
NzLoaders_PCX_Unregister();
|
NzLoaders_PCX_Unregister();
|
||||||
|
|
||||||
NzWindow::Uninitialize();
|
NzWindow::Uninitialize();
|
||||||
|
|
||||||
NzPixelFormat::Uninitialize();
|
NzPixelFormat::Uninitialize();
|
||||||
|
NzBuffer::Uninitialize();
|
||||||
|
|
||||||
s_initialized = false;
|
s_initialized = false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
// This file is part of the "Nazara Engine".
|
// This file is part of the "Nazara Engine".
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Renderer/VertexBuffer.hpp>
|
#include <Nazara/Utility/VertexBuffer.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
|
|
||||||
NzVertexBuffer::NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount) :
|
NzVertexBuffer::NzVertexBuffer(NzBuffer* buffer, unsigned int startVertex, unsigned int vertexCount) :
|
||||||
m_buffer(buffer),
|
m_buffer(buffer),
|
||||||
|
|
@ -12,15 +12,23 @@ m_ownsBuffer(false),
|
||||||
m_startVertex(startVertex),
|
m_startVertex(startVertex),
|
||||||
m_vertexCount(vertexCount)
|
m_vertexCount(vertexCount)
|
||||||
{
|
{
|
||||||
|
#ifdef NAZARA_DEBUG
|
||||||
|
if (!m_buffer)
|
||||||
|
{
|
||||||
|
NazaraError("Passed buffer is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
m_buffer->AddResourceReference();
|
m_buffer->AddResourceReference();
|
||||||
}
|
}
|
||||||
|
|
||||||
NzVertexBuffer::NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferUsage usage) :
|
NzVertexBuffer::NzVertexBuffer(unsigned int length, nzUInt8 typeSize, nzBufferStorage storage, nzBufferUsage usage) :
|
||||||
m_ownsBuffer(true),
|
m_ownsBuffer(true),
|
||||||
m_startVertex(0),
|
m_startVertex(0),
|
||||||
m_vertexCount(length)
|
m_vertexCount(length)
|
||||||
{
|
{
|
||||||
m_buffer = new NzBuffer(nzBufferType_Vertex, length, typeSize, usage);
|
m_buffer = new NzBuffer(nzBufferType_Vertex, length, typeSize, storage, usage);
|
||||||
m_buffer->AddResourceReference();
|
m_buffer->AddResourceReference();
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
}
|
}
|
||||||
|
|
@ -32,7 +40,9 @@ m_vertexCount(vertexBuffer.m_vertexCount)
|
||||||
{
|
{
|
||||||
if (m_ownsBuffer)
|
if (m_ownsBuffer)
|
||||||
{
|
{
|
||||||
m_buffer = new NzBuffer(nzBufferType_Vertex, vertexBuffer.m_buffer->GetLength(), vertexBuffer.m_buffer->GetSize(), vertexBuffer.m_buffer->GetUsage());
|
NzBuffer* buffer = vertexBuffer.m_buffer;
|
||||||
|
|
||||||
|
m_buffer = new NzBuffer(nzBufferType_Vertex, buffer->GetLength(), buffer->GetSize(), buffer->GetStorage(), buffer->GetUsage());
|
||||||
m_buffer->AddResourceReference();
|
m_buffer->AddResourceReference();
|
||||||
m_buffer->SetPersistent(false);
|
m_buffer->SetPersistent(false);
|
||||||
m_buffer->CopyContent(*vertexBuffer.m_buffer);
|
m_buffer->CopyContent(*vertexBuffer.m_buffer);
|
||||||
|
|
@ -51,7 +61,7 @@ NzVertexBuffer::~NzVertexBuffer()
|
||||||
|
|
||||||
bool NzVertexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
bool NzVertexBuffer::Fill(const void* data, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (offset+length > m_vertexCount)
|
if (offset+length > m_vertexCount)
|
||||||
{
|
{
|
||||||
NazaraError("Exceeding virtual buffer size");
|
NazaraError("Exceeding virtual buffer size");
|
||||||
|
|
@ -67,14 +77,14 @@ NzBuffer* NzVertexBuffer::GetBuffer() const
|
||||||
return m_buffer;
|
return m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* NzVertexBuffer::GetBufferPtr()
|
void* NzVertexBuffer::GetPointer()
|
||||||
{
|
{
|
||||||
return reinterpret_cast<nzUInt8*>(m_buffer->GetBufferPtr()) + m_startVertex*m_buffer->GetTypeSize();
|
return reinterpret_cast<nzUInt8*>(m_buffer->GetPointer()) + m_startVertex*m_buffer->GetTypeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
const void* NzVertexBuffer::GetBufferPtr() const
|
const void* NzVertexBuffer::GetPointer() const
|
||||||
{
|
{
|
||||||
return reinterpret_cast<const nzUInt8*>(m_buffer->GetBufferPtr()) + m_startVertex*m_buffer->GetTypeSize();
|
return reinterpret_cast<const nzUInt8*>(m_buffer->GetPointer()) + m_startVertex*m_buffer->GetTypeSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int NzVertexBuffer::GetStartVertex() const
|
unsigned int NzVertexBuffer::GetStartVertex() const
|
||||||
|
|
@ -99,7 +109,7 @@ bool NzVertexBuffer::IsHardware() const
|
||||||
|
|
||||||
void* NzVertexBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int length)
|
void* NzVertexBuffer::Map(nzBufferAccess access, unsigned int offset, unsigned int length)
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (offset+length > m_vertexCount)
|
if (offset+length > m_vertexCount)
|
||||||
{
|
{
|
||||||
NazaraError("Exceeding virtual buffer size");
|
NazaraError("Exceeding virtual buffer size");
|
||||||
|
|
@ -2,11 +2,10 @@
|
||||||
// This file is part of the "Nazara Engine".
|
// This file is part of the "Nazara Engine".
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Renderer/VertexDeclaration.hpp>
|
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||||
#include <Nazara/Core/Error.hpp>
|
#include <Nazara/Core/Error.hpp>
|
||||||
#include <Nazara/Renderer/Config.hpp>
|
#include <Nazara/Utility/Config.hpp>
|
||||||
#include <Nazara/Renderer/Renderer.hpp>
|
#include <Nazara/Utility/Debug.hpp>
|
||||||
#include <Nazara/Renderer/Debug.hpp>
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
@ -32,11 +31,9 @@ bool NzVertexDeclaration::Create(const NzVertexElement* elements, unsigned int e
|
||||||
|
|
||||||
if (stream >= m_streams.size())
|
if (stream >= m_streams.size())
|
||||||
m_streams.resize(stream+1);
|
m_streams.resize(stream+1);
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
else // Seulement si le stream ne vient pas d'être créé (Autrement c'est inutile)
|
else // Seulement si le stream ne vient pas d'être créé (Autrement c'est inutile)
|
||||||
{
|
{
|
||||||
bool fp64 = NazaraRenderer->HasCapability(nzRendererCap_FP64);
|
|
||||||
|
|
||||||
for (unsigned int j = 0; j < i; ++j)
|
for (unsigned int j = 0; j < i; ++j)
|
||||||
{
|
{
|
||||||
if (elements[j].stream == stream && elements[j].usage == elements[i].usage && elements[j].usageIndex == elements[i].usageIndex)
|
if (elements[j].stream == stream && elements[j].usage == elements[i].usage && elements[j].usageIndex == elements[i].usageIndex)
|
||||||
|
|
@ -44,11 +41,6 @@ bool NzVertexDeclaration::Create(const NzVertexElement* elements, unsigned int e
|
||||||
NazaraError("Element usage (" + NzString::Number(elements[j].usage, 16) + ") collision on stream " + NzString::Number(stream) + " with usage index " + NzString::Number(elements[j].usageIndex));
|
NazaraError("Element usage (" + NzString::Number(elements[j].usage, 16) + ") collision on stream " + NzString::Number(stream) + " with usage index " + NzString::Number(elements[j].usageIndex));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (!fp64 && elements[j].type >= nzElementType_Double1 && elements[j].type <= nzElementType_Double4)
|
|
||||||
{
|
|
||||||
NazaraError("FP64 not supported");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -78,7 +70,7 @@ bool NzVertexDeclaration::Create(const NzVertexElement* elements, unsigned int e
|
||||||
|
|
||||||
const NzVertexDeclaration::Element* NzVertexDeclaration::GetElement(unsigned int i, unsigned int stream) const
|
const NzVertexDeclaration::Element* NzVertexDeclaration::GetElement(unsigned int i, unsigned int stream) const
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (stream >= m_streams.size())
|
if (stream >= m_streams.size())
|
||||||
{
|
{
|
||||||
NazaraError("Stream out of range");
|
NazaraError("Stream out of range");
|
||||||
|
|
@ -97,7 +89,7 @@ const NzVertexDeclaration::Element* NzVertexDeclaration::GetElement(unsigned int
|
||||||
|
|
||||||
unsigned int NzVertexDeclaration::GetElementCount(unsigned int stream) const
|
unsigned int NzVertexDeclaration::GetElementCount(unsigned int stream) const
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (stream >= m_streams.size())
|
if (stream >= m_streams.size())
|
||||||
{
|
{
|
||||||
NazaraError("Stream out of range");
|
NazaraError("Stream out of range");
|
||||||
|
|
@ -115,7 +107,7 @@ unsigned int NzVertexDeclaration::GetStreamCount() const
|
||||||
|
|
||||||
unsigned int NzVertexDeclaration::GetStride(unsigned int stream) const
|
unsigned int NzVertexDeclaration::GetStride(unsigned int stream) const
|
||||||
{
|
{
|
||||||
#if NAZARA_RENDERER_SAFE
|
#if NAZARA_UTILITY_SAFE
|
||||||
if (stream >= m_streams.size())
|
if (stream >= m_streams.size())
|
||||||
{
|
{
|
||||||
NazaraError("Stream out of range");
|
NazaraError("Stream out of range");
|
||||||
Loading…
Reference in New Issue