Switch from Nz prefix to namespace Nz
What a huge commit Former-commit-id: 38ac5eebf70adc1180f571f6006192d28fb99897
This commit is contained in:
@@ -16,62 +16,65 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class NzContext;
|
||||
|
||||
using NzContextConstRef = NzObjectRef<const NzContext>;
|
||||
using NzContextLibrary = NzObjectLibrary<NzContext>;
|
||||
using NzContextRef = NzObjectRef<NzContext>;
|
||||
|
||||
class NzContextImpl;
|
||||
|
||||
class NAZARA_RENDERER_API NzContext : public NzRefCounted
|
||||
namespace Nz
|
||||
{
|
||||
friend NzContextImpl;
|
||||
friend NzContextLibrary;
|
||||
friend class NzOpenGL;
|
||||
class Context;
|
||||
|
||||
public:
|
||||
NzContext() = default;
|
||||
NzContext(const NzContext&) = delete;
|
||||
NzContext(NzContext&&) = delete;
|
||||
~NzContext();
|
||||
using ContextConstRef = ObjectRef<const Context>;
|
||||
using ContextLibrary = ObjectLibrary<Context>;
|
||||
using ContextRef = ObjectRef<Context>;
|
||||
|
||||
bool Create(const NzContextParameters& parameters = NzContextParameters());
|
||||
class ContextImpl;
|
||||
|
||||
void Destroy();
|
||||
class NAZARA_RENDERER_API Context : public RefCounted
|
||||
{
|
||||
friend ContextImpl;
|
||||
friend ContextLibrary;
|
||||
friend class OpenGL;
|
||||
|
||||
void EnableVerticalSync(bool enabled);
|
||||
public:
|
||||
Context() = default;
|
||||
Context(const Context&) = delete;
|
||||
Context(Context&&) = delete;
|
||||
~Context();
|
||||
|
||||
const NzContextParameters& GetParameters() const;
|
||||
bool Create(const ContextParameters& parameters = ContextParameters());
|
||||
|
||||
bool IsActive() const;
|
||||
void Destroy();
|
||||
|
||||
bool SetActive(bool active) const;
|
||||
void SwapBuffers();
|
||||
void EnableVerticalSync(bool enabled);
|
||||
|
||||
NzContext& operator=(const NzContext&) = delete;
|
||||
NzContext& operator=(NzContext&&) = delete;
|
||||
const ContextParameters& GetParameters() const;
|
||||
|
||||
static bool EnsureContext();
|
||||
bool IsActive() const;
|
||||
|
||||
static const NzContext* GetCurrent();
|
||||
static const NzContext* GetReference();
|
||||
static const NzContext* GetThreadContext();
|
||||
bool SetActive(bool active) const;
|
||||
void SwapBuffers();
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnContextDestroy, const NzContext* /*context*/);
|
||||
NazaraSignal(OnContextRelease, const NzContext* /*context*/);
|
||||
Context& operator=(const Context&) = delete;
|
||||
Context& operator=(Context&&) = delete;
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
static bool EnsureContext();
|
||||
|
||||
NzContextParameters m_parameters;
|
||||
NzContextImpl* m_impl = nullptr;
|
||||
static const Context* GetCurrent();
|
||||
static const Context* GetReference();
|
||||
static const Context* GetThreadContext();
|
||||
|
||||
static std::unique_ptr<NzContext> s_reference;
|
||||
static std::vector<std::unique_ptr<NzContext>> s_contexts;
|
||||
static NzContextLibrary::LibraryMap s_library;
|
||||
};
|
||||
// Signals:
|
||||
NazaraSignal(OnContextDestroy, const Context* /*context*/);
|
||||
NazaraSignal(OnContextRelease, const Context* /*context*/);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
ContextParameters m_parameters;
|
||||
ContextImpl* m_impl = nullptr;
|
||||
|
||||
static std::unique_ptr<Context> s_reference;
|
||||
static std::vector<std::unique_ptr<Context>> s_contexts;
|
||||
static ContextLibrary::LibraryMap s_library;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_CONTEXT_HPP
|
||||
|
||||
@@ -12,46 +12,49 @@
|
||||
#include <Nazara/Utility/VideoMode.hpp>
|
||||
#include <Nazara/Utility/WindowHandle.hpp>
|
||||
|
||||
class NzContext;
|
||||
|
||||
struct NAZARA_RENDERER_API NzContextParameters
|
||||
namespace Nz
|
||||
{
|
||||
NzContextParameters(const NzRenderTargetParameters& parameters = NzRenderTargetParameters()) :
|
||||
antialiasingLevel(parameters.antialiasingLevel),
|
||||
bitsPerPixel(NzVideoMode::GetDesktopMode().bitsPerPixel),
|
||||
depthBits(parameters.depthBits),
|
||||
majorVersion(defaultMajorVersion),
|
||||
minorVersion(defaultMinorVersion),
|
||||
stencilBits(parameters.stencilBits),
|
||||
shareContext(defaultShareContext),
|
||||
window(0),
|
||||
compatibilityProfile(defaultCompatibilityProfile),
|
||||
debugMode(defaultDebugMode),
|
||||
doubleBuffered(defaultDoubleBuffered),
|
||||
shared(defaultShared)
|
||||
class Context;
|
||||
|
||||
struct NAZARA_RENDERER_API ContextParameters
|
||||
{
|
||||
}
|
||||
ContextParameters(const RenderTargetParameters& parameters = RenderTargetParameters()) :
|
||||
antialiasingLevel(parameters.antialiasingLevel),
|
||||
bitsPerPixel(VideoMode::GetDesktopMode().bitsPerPixel),
|
||||
depthBits(parameters.depthBits),
|
||||
majorVersion(defaultMajorVersion),
|
||||
minorVersion(defaultMinorVersion),
|
||||
stencilBits(parameters.stencilBits),
|
||||
shareContext(defaultShareContext),
|
||||
window(0),
|
||||
compatibilityProfile(defaultCompatibilityProfile),
|
||||
debugMode(defaultDebugMode),
|
||||
doubleBuffered(defaultDoubleBuffered),
|
||||
shared(defaultShared)
|
||||
{
|
||||
}
|
||||
|
||||
nzUInt8 antialiasingLevel;
|
||||
nzUInt8 bitsPerPixel;
|
||||
nzUInt8 depthBits;
|
||||
nzUInt8 majorVersion;
|
||||
nzUInt8 minorVersion;
|
||||
nzUInt8 stencilBits;
|
||||
const NzContext* shareContext;
|
||||
NzWindowHandle window;
|
||||
bool compatibilityProfile;
|
||||
bool debugMode;
|
||||
bool doubleBuffered;
|
||||
bool shared;
|
||||
UInt8 antialiasingLevel;
|
||||
UInt8 bitsPerPixel;
|
||||
UInt8 depthBits;
|
||||
UInt8 majorVersion;
|
||||
UInt8 minorVersion;
|
||||
UInt8 stencilBits;
|
||||
const Context* shareContext;
|
||||
WindowHandle window;
|
||||
bool compatibilityProfile;
|
||||
bool debugMode;
|
||||
bool doubleBuffered;
|
||||
bool shared;
|
||||
|
||||
static nzUInt8 defaultMajorVersion;
|
||||
static nzUInt8 defaultMinorVersion;
|
||||
static const NzContext* defaultShareContext;
|
||||
static bool defaultCompatibilityProfile;
|
||||
static bool defaultDebugMode;
|
||||
static bool defaultDoubleBuffered;
|
||||
static bool defaultShared;
|
||||
};
|
||||
static UInt8 defaultMajorVersion;
|
||||
static UInt8 defaultMinorVersion;
|
||||
static const Context* defaultShareContext;
|
||||
static bool defaultCompatibilityProfile;
|
||||
static bool defaultDebugMode;
|
||||
static bool defaultDoubleBuffered;
|
||||
static bool defaultShared;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_CONTEXTPARAMETERS_HPP
|
||||
|
||||
@@ -16,43 +16,46 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Utility/StaticMesh.hpp>
|
||||
|
||||
class NzSkeleton;
|
||||
|
||||
class NAZARA_RENDERER_API NzDebugDrawer
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
static void Draw(const NzBoundingVolumef& volume);
|
||||
static void Draw(const NzBoxf& box);
|
||||
static void Draw(const NzBoxi& box);
|
||||
static void Draw(const NzBoxui& box);
|
||||
static void Draw(const NzFrustumf& frustum);
|
||||
static void Draw(const NzOrientedBoxf& orientedBox);
|
||||
static void Draw(const NzSkeleton* skeleton);
|
||||
static void Draw(const NzVector3f& position, float size = 0.1f);
|
||||
static void DrawAxes(const NzVector3f& position = NzVector3f::Zero(), float size = 1.f);
|
||||
static void DrawBinormals(const NzStaticMesh* subMesh);
|
||||
static void DrawCone(const NzVector3f& origin, const NzQuaternionf& rotation, float angle, float length);
|
||||
static void DrawLine(const NzVector3f& p1, const NzVector3f& p2);
|
||||
static void DrawPoints(const NzVector3f* ptr, unsigned int pointCount);
|
||||
static void DrawNormals(const NzStaticMesh* subMesh);
|
||||
static void DrawTangents(const NzStaticMesh* subMesh);
|
||||
class Skeleton;
|
||||
|
||||
static void EnableDepthBuffer(bool depthBuffer);
|
||||
class NAZARA_RENDERER_API DebugDrawer
|
||||
{
|
||||
public:
|
||||
static void Draw(const BoundingVolumef& volume);
|
||||
static void Draw(const Boxf& box);
|
||||
static void Draw(const Boxi& box);
|
||||
static void Draw(const Boxui& box);
|
||||
static void Draw(const Frustumf& frustum);
|
||||
static void Draw(const OrientedBoxf& orientedBox);
|
||||
static void Draw(const Skeleton* skeleton);
|
||||
static void Draw(const Vector3f& position, float size = 0.1f);
|
||||
static void DrawAxes(const Vector3f& position = Vector3f::Zero(), float size = 1.f);
|
||||
static void DrawBinormals(const StaticMesh* subMesh);
|
||||
static void DrawCone(const Vector3f& origin, const Quaternionf& rotation, float angle, float length);
|
||||
static void DrawLine(const Vector3f& p1, const Vector3f& p2);
|
||||
static void DrawPoints(const Vector3f* ptr, unsigned int pointCount);
|
||||
static void DrawNormals(const StaticMesh* subMesh);
|
||||
static void DrawTangents(const StaticMesh* subMesh);
|
||||
|
||||
static float GetLineWidth();
|
||||
static float GetPointSize();
|
||||
static NzColor GetPrimaryColor();
|
||||
static NzColor GetSecondaryColor();
|
||||
static void EnableDepthBuffer(bool depthBuffer);
|
||||
|
||||
static bool Initialize();
|
||||
static bool IsDepthBufferEnabled();
|
||||
static float GetLineWidth();
|
||||
static float GetPointSize();
|
||||
static Color GetPrimaryColor();
|
||||
static Color GetSecondaryColor();
|
||||
|
||||
static void SetLineWidth(float width);
|
||||
static void SetPointSize(float size);
|
||||
static void SetPrimaryColor(const NzColor& color);
|
||||
static void SetSecondaryColor(const NzColor& color);
|
||||
static bool Initialize();
|
||||
static bool IsDepthBufferEnabled();
|
||||
|
||||
static void Uninitialize();
|
||||
};
|
||||
static void SetLineWidth(float width);
|
||||
static void SetPointSize(float size);
|
||||
static void SetPrimaryColor(const Color& color);
|
||||
static void SetSecondaryColor(const Color& color);
|
||||
|
||||
static void Uninitialize();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_DEBUG_DRAWER_HPP
|
||||
|
||||
@@ -7,225 +7,228 @@
|
||||
#ifndef NAZARA_ENUMS_RENDERER_HPP
|
||||
#define NAZARA_ENUMS_RENDERER_HPP
|
||||
|
||||
enum nzAttachmentPoint
|
||||
namespace Nz
|
||||
{
|
||||
nzAttachmentPoint_Color,
|
||||
nzAttachmentPoint_Depth,
|
||||
nzAttachmentPoint_DepthStencil,
|
||||
nzAttachmentPoint_Stencil,
|
||||
enum AttachmentPoint
|
||||
{
|
||||
AttachmentPoint_Color,
|
||||
AttachmentPoint_Depth,
|
||||
AttachmentPoint_DepthStencil,
|
||||
AttachmentPoint_Stencil,
|
||||
|
||||
nzAttachmentPoint_Max = nzAttachmentPoint_Stencil
|
||||
};
|
||||
|
||||
enum nzBlendFunc
|
||||
{
|
||||
nzBlendFunc_DestAlpha,
|
||||
nzBlendFunc_DestColor,
|
||||
nzBlendFunc_SrcAlpha,
|
||||
nzBlendFunc_SrcColor,
|
||||
nzBlendFunc_InvDestAlpha,
|
||||
nzBlendFunc_InvDestColor,
|
||||
nzBlendFunc_InvSrcAlpha,
|
||||
nzBlendFunc_InvSrcColor,
|
||||
nzBlendFunc_One,
|
||||
nzBlendFunc_Zero,
|
||||
|
||||
nzBlendFunc_Max = nzBlendFunc_Zero
|
||||
};
|
||||
|
||||
enum nzFaceFilling
|
||||
{
|
||||
nzFaceFilling_Fill,
|
||||
nzFaceFilling_Line,
|
||||
nzFaceFilling_Point,
|
||||
|
||||
nzFaceFilling_Max = nzFaceFilling_Point
|
||||
};
|
||||
|
||||
enum nzFaceSide
|
||||
{
|
||||
nzFaceSide_Back,
|
||||
nzFaceSide_Front,
|
||||
nzFaceSide_FrontAndBack,
|
||||
|
||||
nzFaceSide_Max = nzFaceSide_FrontAndBack
|
||||
};
|
||||
|
||||
enum nzGpuQueryCondition
|
||||
{
|
||||
nzGpuQueryCondition_Region_NoWait,
|
||||
nzGpuQueryCondition_Region_Wait,
|
||||
nzGpuQueryCondition_NoWait,
|
||||
nzGpuQueryCondition_Wait,
|
||||
|
||||
nzGpuQueryCondition_Max = nzGpuQueryCondition_Wait
|
||||
};
|
||||
|
||||
enum nzGpuQueryMode
|
||||
{
|
||||
nzGpuQueryMode_AnySamplesPassed,
|
||||
nzGpuQueryMode_AnySamplesPassedConservative,
|
||||
nzGpuQueryMode_PrimitiveGenerated,
|
||||
nzGpuQueryMode_SamplesPassed,
|
||||
nzGpuQueryMode_TimeElapsed,
|
||||
nzGpuQueryMode_TransformFeedbackPrimitivesWritten,
|
||||
|
||||
nzGpuQueryMode_Max = nzGpuQueryMode_TransformFeedbackPrimitivesWritten
|
||||
};
|
||||
|
||||
enum nzMatrixType
|
||||
{
|
||||
// Matrices de base
|
||||
nzMatrixType_Projection,
|
||||
nzMatrixType_View,
|
||||
nzMatrixType_World,
|
||||
|
||||
// Matrices combinées
|
||||
nzMatrixType_ViewProj,
|
||||
nzMatrixType_WorldView,
|
||||
nzMatrixType_WorldViewProj,
|
||||
|
||||
// Matrice inversées
|
||||
nzMatrixType_InvProjection,
|
||||
nzMatrixType_InvView,
|
||||
nzMatrixType_InvViewProj,
|
||||
nzMatrixType_InvWorld,
|
||||
nzMatrixType_InvWorldView,
|
||||
nzMatrixType_InvWorldViewProj,
|
||||
|
||||
nzMatrixType_Max = nzMatrixType_InvWorldViewProj
|
||||
};
|
||||
|
||||
enum nzPixelBufferType
|
||||
{
|
||||
nzPixelBufferType_Pack,
|
||||
nzPixelBufferType_Unpack,
|
||||
|
||||
nzPixelBufferType_Max = nzPixelBufferType_Unpack
|
||||
};
|
||||
|
||||
enum nzRendererCap
|
||||
{
|
||||
nzRendererCap_AnisotropicFilter,
|
||||
nzRendererCap_ConditionalRendering,
|
||||
nzRendererCap_FP64,
|
||||
nzRendererCap_HardwareBuffer,
|
||||
nzRendererCap_Instancing,
|
||||
nzRendererCap_MultipleRenderTargets,
|
||||
nzRendererCap_OcclusionQuery,
|
||||
nzRendererCap_PixelBufferObject,
|
||||
nzRendererCap_RenderTexture,
|
||||
nzRendererCap_Texture3D,
|
||||
nzRendererCap_TextureCubemap,
|
||||
nzRendererCap_TextureMulti,
|
||||
nzRendererCap_TextureNPOT,
|
||||
|
||||
nzRendererCap_Max = nzRendererCap_TextureNPOT
|
||||
};
|
||||
|
||||
enum nzRendererBufferFlags
|
||||
{
|
||||
nzRendererBuffer_Color = 0x1,
|
||||
nzRendererBuffer_Depth = 0x2,
|
||||
nzRendererBuffer_Stencil = 0x4,
|
||||
|
||||
nzRendererBuffer_Max = nzRendererBuffer_Stencil*2-1
|
||||
};
|
||||
|
||||
enum nzRendererComparison
|
||||
{
|
||||
nzRendererComparison_Always,
|
||||
nzRendererComparison_Equal,
|
||||
nzRendererComparison_Greater,
|
||||
nzRendererComparison_GreaterOrEqual,
|
||||
nzRendererComparison_Less,
|
||||
nzRendererComparison_LessOrEqual,
|
||||
nzRendererComparison_Never,
|
||||
nzRendererComparison_NotEqual,
|
||||
|
||||
nzRendererComparison_Max = nzRendererComparison_NotEqual
|
||||
};
|
||||
|
||||
enum nzRendererParameter
|
||||
{
|
||||
nzRendererParameter_Blend,
|
||||
nzRendererParameter_ColorWrite,
|
||||
nzRendererParameter_DepthBuffer,
|
||||
nzRendererParameter_DepthWrite,
|
||||
nzRendererParameter_FaceCulling,
|
||||
nzRendererParameter_ScissorTest,
|
||||
nzRendererParameter_StencilTest,
|
||||
|
||||
nzRendererParameter_Max = nzRendererParameter_StencilTest
|
||||
};
|
||||
|
||||
enum nzSamplerFilter
|
||||
{
|
||||
nzSamplerFilter_Unknown = -1,
|
||||
|
||||
nzSamplerFilter_Bilinear,
|
||||
nzSamplerFilter_Nearest,
|
||||
nzSamplerFilter_Trilinear,
|
||||
|
||||
nzSamplerFilter_Default,
|
||||
|
||||
nzSamplerFilter_Max = nzSamplerFilter_Default
|
||||
};
|
||||
|
||||
enum nzSamplerWrap
|
||||
{
|
||||
nzSamplerWrap_Unknown = -1,
|
||||
|
||||
nzSamplerWrap_Clamp,
|
||||
nzSamplerWrap_MirroredRepeat,
|
||||
nzSamplerWrap_Repeat,
|
||||
|
||||
nzSamplerWrap_Default,
|
||||
|
||||
nzSamplerWrap_Max = nzSamplerWrap_Repeat
|
||||
};
|
||||
|
||||
enum nzShaderUniform
|
||||
{
|
||||
nzShaderUniform_InvProjMatrix,
|
||||
nzShaderUniform_InvTargetSize,
|
||||
nzShaderUniform_InvViewMatrix,
|
||||
nzShaderUniform_InvViewProjMatrix,
|
||||
nzShaderUniform_InvWorldMatrix,
|
||||
nzShaderUniform_InvWorldViewMatrix,
|
||||
nzShaderUniform_InvWorldViewProjMatrix,
|
||||
nzShaderUniform_ProjMatrix,
|
||||
nzShaderUniform_TargetSize,
|
||||
nzShaderUniform_ViewMatrix,
|
||||
nzShaderUniform_ViewProjMatrix,
|
||||
nzShaderUniform_WorldMatrix,
|
||||
nzShaderUniform_WorldViewMatrix,
|
||||
nzShaderUniform_WorldViewProjMatrix,
|
||||
|
||||
nzShaderUniform_Max = nzShaderUniform_WorldViewProjMatrix
|
||||
};
|
||||
|
||||
enum nzShaderStage
|
||||
{
|
||||
nzShaderStage_Fragment,
|
||||
nzShaderStage_Geometry,
|
||||
nzShaderStage_Vertex,
|
||||
|
||||
nzShaderStage_Max = nzShaderStage_Vertex
|
||||
};
|
||||
|
||||
enum nzStencilOperation
|
||||
{
|
||||
nzStencilOperation_Decrement,
|
||||
nzStencilOperation_DecrementNoClamp,
|
||||
nzStencilOperation_Increment,
|
||||
nzStencilOperation_IncrementNoClamp,
|
||||
nzStencilOperation_Invert,
|
||||
nzStencilOperation_Keep,
|
||||
nzStencilOperation_Replace,
|
||||
nzStencilOperation_Zero,
|
||||
|
||||
nzStencilOperation_Max = nzStencilOperation_Zero
|
||||
AttachmentPoint_Max = AttachmentPoint_Stencil
|
||||
};
|
||||
|
||||
enum BlendFunc
|
||||
{
|
||||
BlendFunc_DestAlpha,
|
||||
BlendFunc_DestColor,
|
||||
BlendFunc_SrcAlpha,
|
||||
BlendFunc_SrcColor,
|
||||
BlendFunc_InvDestAlpha,
|
||||
BlendFunc_InvDestColor,
|
||||
BlendFunc_InvSrcAlpha,
|
||||
BlendFunc_InvSrcColor,
|
||||
BlendFunc_One,
|
||||
BlendFunc_Zero,
|
||||
|
||||
BlendFunc_Max = BlendFunc_Zero
|
||||
};
|
||||
|
||||
enum FaceFilling
|
||||
{
|
||||
FaceFilling_Fill,
|
||||
FaceFilling_Line,
|
||||
FaceFilling_Point,
|
||||
|
||||
FaceFilling_Max = FaceFilling_Point
|
||||
};
|
||||
|
||||
enum FaceSide
|
||||
{
|
||||
FaceSide_Back,
|
||||
FaceSide_Front,
|
||||
FaceSide_FrontAndBack,
|
||||
|
||||
FaceSide_Max = FaceSide_FrontAndBack
|
||||
};
|
||||
|
||||
enum GpuQueryCondition
|
||||
{
|
||||
GpuQueryCondition_Region_NoWait,
|
||||
GpuQueryCondition_Region_Wait,
|
||||
GpuQueryCondition_NoWait,
|
||||
GpuQueryCondition_Wait,
|
||||
|
||||
GpuQueryCondition_Max = GpuQueryCondition_Wait
|
||||
};
|
||||
|
||||
enum GpuQueryMode
|
||||
{
|
||||
GpuQueryMode_AnySamplesPassed,
|
||||
GpuQueryMode_AnySamplesPassedConservative,
|
||||
GpuQueryMode_PrimitiveGenerated,
|
||||
GpuQueryMode_SamplesPassed,
|
||||
GpuQueryMode_TimeElapsed,
|
||||
GpuQueryMode_TransformFeedbackPrimitivesWritten,
|
||||
|
||||
GpuQueryMode_Max = GpuQueryMode_TransformFeedbackPrimitivesWritten
|
||||
};
|
||||
|
||||
enum MatrixType
|
||||
{
|
||||
// Matrices de base
|
||||
MatrixType_Projection,
|
||||
MatrixType_View,
|
||||
MatrixType_World,
|
||||
|
||||
// Matrices combinées
|
||||
MatrixType_ViewProj,
|
||||
MatrixType_WorldView,
|
||||
MatrixType_WorldViewProj,
|
||||
|
||||
// Matrice inversées
|
||||
MatrixType_InvProjection,
|
||||
MatrixType_InvView,
|
||||
MatrixType_InvViewProj,
|
||||
MatrixType_InvWorld,
|
||||
MatrixType_InvWorldView,
|
||||
MatrixType_InvWorldViewProj,
|
||||
|
||||
MatrixType_Max = MatrixType_InvWorldViewProj
|
||||
};
|
||||
|
||||
enum PixelBufferType
|
||||
{
|
||||
PixelBufferType_Pack,
|
||||
PixelBufferType_Unpack,
|
||||
|
||||
PixelBufferType_Max = PixelBufferType_Unpack
|
||||
};
|
||||
|
||||
enum RendererCap
|
||||
{
|
||||
RendererCap_AnisotropicFilter,
|
||||
RendererCap_ConditionalRendering,
|
||||
RendererCap_FP64,
|
||||
RendererCap_HardwareBuffer,
|
||||
RendererCap_Instancing,
|
||||
RendererCap_MultipleRenderTargets,
|
||||
RendererCap_OcclusionQuery,
|
||||
RendererCap_PixelBufferObject,
|
||||
RendererCap_RenderTexture,
|
||||
RendererCap_Texture3D,
|
||||
RendererCap_TextureCubemap,
|
||||
RendererCap_TextureMulti,
|
||||
RendererCap_TextureNPOT,
|
||||
|
||||
RendererCap_Max = RendererCap_TextureNPOT
|
||||
};
|
||||
|
||||
enum RendererBufferFlags
|
||||
{
|
||||
RendererBuffer_Color = 0x1,
|
||||
RendererBuffer_Depth = 0x2,
|
||||
RendererBuffer_Stencil = 0x4,
|
||||
|
||||
RendererBuffer_Max = RendererBuffer_Stencil*2-1
|
||||
};
|
||||
|
||||
enum RendererComparison
|
||||
{
|
||||
RendererComparison_Always,
|
||||
RendererComparison_Equal,
|
||||
RendererComparison_Greater,
|
||||
RendererComparison_GreaterOrEqual,
|
||||
RendererComparison_Less,
|
||||
RendererComparison_LessOrEqual,
|
||||
RendererComparison_Never,
|
||||
RendererComparison_NotEqual,
|
||||
|
||||
RendererComparison_Max = RendererComparison_NotEqual
|
||||
};
|
||||
|
||||
enum RendererParameter
|
||||
{
|
||||
RendererParameter_Blend,
|
||||
RendererParameter_ColorWrite,
|
||||
RendererParameter_DepthBuffer,
|
||||
RendererParameter_DepthWrite,
|
||||
RendererParameter_FaceCulling,
|
||||
RendererParameter_ScissorTest,
|
||||
RendererParameter_StencilTest,
|
||||
|
||||
RendererParameter_Max = RendererParameter_StencilTest
|
||||
};
|
||||
|
||||
enum SamplerFilter
|
||||
{
|
||||
SamplerFilter_Unknown = -1,
|
||||
|
||||
SamplerFilter_Bilinear,
|
||||
SamplerFilter_Nearest,
|
||||
SamplerFilter_Trilinear,
|
||||
|
||||
SamplerFilter_Default,
|
||||
|
||||
SamplerFilter_Max = SamplerFilter_Default
|
||||
};
|
||||
|
||||
enum SamplerWrap
|
||||
{
|
||||
SamplerWrap_Unknown = -1,
|
||||
|
||||
SamplerWrap_Clamp,
|
||||
SamplerWrap_MirroredRepeat,
|
||||
SamplerWrap_Repeat,
|
||||
|
||||
SamplerWrap_Default,
|
||||
|
||||
SamplerWrap_Max = SamplerWrap_Repeat
|
||||
};
|
||||
|
||||
enum ShaderUniform
|
||||
{
|
||||
ShaderUniform_InvProjMatrix,
|
||||
ShaderUniform_InvTargetSize,
|
||||
ShaderUniform_InvViewMatrix,
|
||||
ShaderUniform_InvViewProjMatrix,
|
||||
ShaderUniform_InvWorldMatrix,
|
||||
ShaderUniform_InvWorldViewMatrix,
|
||||
ShaderUniform_InvWorldViewProjMatrix,
|
||||
ShaderUniform_ProjMatrix,
|
||||
ShaderUniform_TargetSize,
|
||||
ShaderUniform_ViewMatrix,
|
||||
ShaderUniform_ViewProjMatrix,
|
||||
ShaderUniform_WorldMatrix,
|
||||
ShaderUniform_WorldViewMatrix,
|
||||
ShaderUniform_WorldViewProjMatrix,
|
||||
|
||||
ShaderUniform_Max = ShaderUniform_WorldViewProjMatrix
|
||||
};
|
||||
|
||||
enum ShaderStageType
|
||||
{
|
||||
ShaderStageType_Fragment,
|
||||
ShaderStageType_Geometry,
|
||||
ShaderStageType_Vertex,
|
||||
|
||||
ShaderStageType_Max = ShaderStageType_Vertex
|
||||
};
|
||||
|
||||
enum nzStencilOperation
|
||||
{
|
||||
nzStencilOperation_Decrement,
|
||||
nzStencilOperation_DecrementNoClamp,
|
||||
nzStencilOperation_Increment,
|
||||
nzStencilOperation_IncrementNoClamp,
|
||||
nzStencilOperation_Invert,
|
||||
nzStencilOperation_Keep,
|
||||
nzStencilOperation_Replace,
|
||||
nzStencilOperation_Zero,
|
||||
|
||||
nzStencilOperation_Max = nzStencilOperation_Zero
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_ENUMS_RENDERER_HPP
|
||||
|
||||
@@ -11,33 +11,36 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
class NAZARA_RENDERER_API NzGpuQuery
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzGpuQuery();
|
||||
NzGpuQuery(const NzGpuQuery&) = delete;
|
||||
NzGpuQuery(NzGpuQuery&&) = delete; ///TODO
|
||||
~NzGpuQuery();
|
||||
class NAZARA_RENDERER_API GpuQuery
|
||||
{
|
||||
public:
|
||||
GpuQuery();
|
||||
GpuQuery(const GpuQuery&) = delete;
|
||||
GpuQuery(GpuQuery&&) = delete; ///TODO
|
||||
~GpuQuery();
|
||||
|
||||
void Begin(nzGpuQueryMode mode);
|
||||
void End();
|
||||
void Begin(GpuQueryMode mode);
|
||||
void End();
|
||||
|
||||
unsigned int GetResult() const;
|
||||
unsigned int GetResult() const;
|
||||
|
||||
bool IsResultAvailable() const;
|
||||
bool IsResultAvailable() const;
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
NzGpuQuery& operator=(const NzGpuQuery&) = delete;
|
||||
NzGpuQuery& operator=(NzGpuQuery&&) = delete; ///TODO
|
||||
GpuQuery& operator=(const GpuQuery&) = delete;
|
||||
GpuQuery& operator=(GpuQuery&&) = delete; ///TODO
|
||||
|
||||
static bool IsModeSupported(nzGpuQueryMode mode);
|
||||
static bool IsSupported();
|
||||
static bool IsModeSupported(GpuQueryMode mode);
|
||||
static bool IsSupported();
|
||||
|
||||
private:
|
||||
nzGpuQueryMode m_mode;
|
||||
unsigned int m_id;
|
||||
};
|
||||
private:
|
||||
GpuQueryMode m_mode;
|
||||
unsigned int m_id;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_GPUQUERY_HPP
|
||||
|
||||
@@ -29,136 +29,139 @@ namespace GLX
|
||||
#include <GL3/glxext.h>
|
||||
#endif
|
||||
|
||||
enum nzOpenGLExtension
|
||||
namespace Nz
|
||||
{
|
||||
nzOpenGLExtension_AnisotropicFilter,
|
||||
nzOpenGLExtension_ConditionalRender,
|
||||
nzOpenGLExtension_DebugOutput,
|
||||
nzOpenGLExtension_DrawInstanced,
|
||||
nzOpenGLExtension_FP64,
|
||||
nzOpenGLExtension_FrameBufferObject,
|
||||
nzOpenGLExtension_GetProgramBinary,
|
||||
nzOpenGLExtension_InstancedArray,
|
||||
nzOpenGLExtension_PixelBufferObject,
|
||||
nzOpenGLExtension_SamplerObjects,
|
||||
nzOpenGLExtension_SeparateShaderObjects,
|
||||
nzOpenGLExtension_Shader_ImageLoadStore,
|
||||
nzOpenGLExtension_TextureArray,
|
||||
nzOpenGLExtension_TextureCompression_s3tc,
|
||||
nzOpenGLExtension_TextureStorage,
|
||||
nzOpenGLExtension_VertexArrayObjects,
|
||||
enum OpenGLExtension
|
||||
{
|
||||
OpenGLExtension_AnisotropicFilter,
|
||||
OpenGLExtension_ConditionalRender,
|
||||
OpenGLExtension_DebugOutput,
|
||||
OpenGLExtension_DrawInstanced,
|
||||
OpenGLExtension_FP64,
|
||||
OpenGLExtension_FrameBufferObject,
|
||||
OpenGLExtension_GetProgramBinary,
|
||||
OpenGLExtension_InstancedArray,
|
||||
OpenGLExtension_PixelBufferObject,
|
||||
OpenGLExtension_SamplerObjects,
|
||||
OpenGLExtension_SeparateShaderObjects,
|
||||
OpenGLExtension_Shader_ImageLoadStore,
|
||||
OpenGLExtension_TextureArray,
|
||||
OpenGLExtension_TextureCompression_s3tc,
|
||||
OpenGLExtension_TextureStorage,
|
||||
OpenGLExtension_VertexArrayObjects,
|
||||
|
||||
nzOpenGLExtension_Max = nzOpenGLExtension_VertexArrayObjects
|
||||
};
|
||||
OpenGLExtension_Max = OpenGLExtension_VertexArrayObjects
|
||||
};
|
||||
|
||||
class NzContext;
|
||||
class NzRenderTarget;
|
||||
class Context;
|
||||
class RenderTarget;
|
||||
|
||||
using NzOpenGLFunc = void (*)();
|
||||
using OpenGLFunc = void (*)();
|
||||
|
||||
class NAZARA_RENDERER_API NzOpenGL
|
||||
{
|
||||
friend NzContext;
|
||||
class NAZARA_RENDERER_API OpenGL
|
||||
{
|
||||
friend Context;
|
||||
|
||||
public:
|
||||
enum FormatType
|
||||
{
|
||||
FormatType_RenderBuffer,
|
||||
// FormatType_MultisampleTexture,
|
||||
FormatType_Texture
|
||||
};
|
||||
public:
|
||||
enum FormatType
|
||||
{
|
||||
FormatType_RenderBuffer,
|
||||
// FormatType_MultisampleTexture,
|
||||
FormatType_Texture
|
||||
};
|
||||
|
||||
struct Format
|
||||
{
|
||||
GLenum dataFormat;
|
||||
GLenum dataType;
|
||||
GLint internalFormat;
|
||||
GLint swizzle[4];
|
||||
};
|
||||
struct Format
|
||||
{
|
||||
GLenum dataFormat;
|
||||
GLenum dataType;
|
||||
GLint internalFormat;
|
||||
GLint swizzle[4];
|
||||
};
|
||||
|
||||
NzOpenGL() = delete;
|
||||
~NzOpenGL() = delete;
|
||||
OpenGL() = delete;
|
||||
~OpenGL() = delete;
|
||||
|
||||
static void ApplyStates(const NzRenderStates& states);
|
||||
static void ApplyStates(const RenderStates& states);
|
||||
|
||||
static void BindBuffer(nzBufferType type, GLuint id);
|
||||
static void BindProgram(GLuint id);
|
||||
static void BindSampler(GLuint unit, GLuint id);
|
||||
static void BindScissorBox(const NzRecti& scissorBox);
|
||||
static void BindTexture(nzImageType type, GLuint id);
|
||||
static void BindTexture(unsigned int textureUnit, nzImageType type, GLuint id);
|
||||
static void BindTextureUnit(unsigned int textureUnit);
|
||||
static void BindViewport(const NzRecti& viewport);
|
||||
static void BindBuffer(BufferType type, GLuint id);
|
||||
static void BindProgram(GLuint id);
|
||||
static void BindSampler(GLuint unit, GLuint id);
|
||||
static void BindScissorBox(const Recti& scissorBox);
|
||||
static void BindTexture(ImageType type, GLuint id);
|
||||
static void BindTexture(unsigned int textureUnit, ImageType type, GLuint id);
|
||||
static void BindTextureUnit(unsigned int textureUnit);
|
||||
static void BindViewport(const Recti& viewport);
|
||||
|
||||
static void DeleteBuffer(nzBufferType type, GLuint id);
|
||||
static void DeleteFrameBuffer(const NzContext* context, GLuint id);
|
||||
static void DeleteProgram(GLuint id);
|
||||
static void DeleteSampler(GLuint id);
|
||||
static void DeleteTexture(GLuint id);
|
||||
static void DeleteVertexArray(const NzContext* context, GLuint id);
|
||||
static void DeleteBuffer(BufferType type, GLuint id);
|
||||
static void DeleteFrameBuffer(const Context* context, GLuint id);
|
||||
static void DeleteProgram(GLuint id);
|
||||
static void DeleteSampler(GLuint id);
|
||||
static void DeleteTexture(GLuint id);
|
||||
static void DeleteVertexArray(const Context* context, GLuint id);
|
||||
|
||||
static GLuint GetCurrentBuffer(nzBufferType type);
|
||||
static GLuint GetCurrentProgram();
|
||||
static NzRecti GetCurrentScissorBox();
|
||||
static const NzRenderTarget* GetCurrentTarget();
|
||||
static GLuint GetCurrentTexture();
|
||||
static GLuint GetCurrentTexture(unsigned int textureUnit);
|
||||
static unsigned int GetCurrentTextureUnit();
|
||||
static NzRecti GetCurrentViewport();
|
||||
static GLuint GetCurrentBuffer(BufferType type);
|
||||
static GLuint GetCurrentProgram();
|
||||
static Recti GetCurrentScissorBox();
|
||||
static const RenderTarget* GetCurrentTarget();
|
||||
static GLuint GetCurrentTexture();
|
||||
static GLuint GetCurrentTexture(unsigned int textureUnit);
|
||||
static unsigned int GetCurrentTextureUnit();
|
||||
static Recti GetCurrentViewport();
|
||||
|
||||
static NzOpenGLFunc GetEntry(const NzString& entryPoint);
|
||||
static unsigned int GetGLSLVersion();
|
||||
static NzString GetRendererName();
|
||||
static NzString GetVendorName();
|
||||
static unsigned int GetVersion();
|
||||
static OpenGLFunc GetEntry(const String& entryPoint);
|
||||
static unsigned int GetGLSLVersion();
|
||||
static String GetRendererName();
|
||||
static String GetVendorName();
|
||||
static unsigned int GetVersion();
|
||||
|
||||
static bool Initialize();
|
||||
static bool Initialize();
|
||||
|
||||
static bool IsInitialized();
|
||||
static bool IsSupported(nzOpenGLExtension extension);
|
||||
static bool IsSupported(const NzString& string);
|
||||
static bool IsInitialized();
|
||||
static bool IsSupported(OpenGLExtension extension);
|
||||
static bool IsSupported(const String& string);
|
||||
|
||||
static void SetBuffer(nzBufferType type, GLuint id);
|
||||
static void SetProgram(GLuint id);
|
||||
static void SetScissorBox(const NzRecti& scissorBox);
|
||||
static void SetTarget(const NzRenderTarget* renderTarget);
|
||||
static void SetTexture(GLuint id);
|
||||
static void SetTexture(unsigned int textureUnit, GLuint id);
|
||||
static void SetTextureUnit(unsigned int textureUnit);
|
||||
static void SetViewport(const NzRecti& viewport);
|
||||
static void SetBuffer(BufferType type, GLuint id);
|
||||
static void SetProgram(GLuint id);
|
||||
static void SetScissorBox(const Recti& scissorBox);
|
||||
static void SetTarget(const RenderTarget* renderTarget);
|
||||
static void SetTexture(GLuint id);
|
||||
static void SetTexture(unsigned int textureUnit, GLuint id);
|
||||
static void SetTextureUnit(unsigned int textureUnit);
|
||||
static void SetViewport(const Recti& viewport);
|
||||
|
||||
static bool TranslateFormat(nzPixelFormat pixelFormat, Format* format, FormatType target);
|
||||
static bool TranslateFormat(PixelFormatType pixelFormat, Format* format, FormatType target);
|
||||
|
||||
static void Uninitialize();
|
||||
static void Uninitialize();
|
||||
|
||||
static GLenum Attachment[nzAttachmentPoint_Max+1];
|
||||
static GLenum BlendFunc[nzBlendFunc_Max+1];
|
||||
static GLenum BufferLock[nzBufferAccess_Max+1];
|
||||
static GLenum BufferLockRange[nzBufferAccess_Max+1];
|
||||
static GLenum BufferTarget[nzBufferType_Max+1];
|
||||
static GLenum BufferTargetBinding[nzBufferType_Max+1];
|
||||
static GLenum BufferUsage[nzBufferUsage_Max+1];
|
||||
static GLenum ComponentType[nzComponentType_Max+1];
|
||||
static GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas près de changer
|
||||
static GLenum FaceFilling[nzFaceFilling_Max+1];
|
||||
static GLenum FaceSide[nzFaceSide_Max+1];
|
||||
static GLenum PrimitiveMode[nzPrimitiveMode_Max+1];
|
||||
static GLenum QueryCondition[nzGpuQueryCondition_Max+1];
|
||||
static GLenum QueryMode[nzGpuQueryMode_Max+1];
|
||||
static GLenum RendererComparison[nzRendererComparison_Max+1];
|
||||
static GLenum RendererParameter[nzRendererParameter_Max+1];
|
||||
static GLenum SamplerWrapMode[nzSamplerWrap_Max+1];
|
||||
static GLenum ShaderStage[nzShaderStage_Max+1];
|
||||
static GLenum StencilOperation[nzStencilOperation_Max+1];
|
||||
static GLenum TextureTarget[nzImageType_Max+1];
|
||||
static GLenum TextureTargetBinding[nzImageType_Max+1];
|
||||
static GLenum TextureTargetProxy[nzImageType_Max+1];
|
||||
static nzUInt8 VertexComponentIndex[nzVertexComponent_Max+1];
|
||||
static GLenum Attachment[AttachmentPoint_Max+1];
|
||||
static GLenum BlendFunc[BlendFunc_Max+1];
|
||||
static GLenum BufferLock[BufferAccess_Max+1];
|
||||
static GLenum BufferLockRange[BufferAccess_Max+1];
|
||||
static GLenum BufferTarget[BufferType_Max+1];
|
||||
static GLenum BufferTargetBinding[BufferType_Max+1];
|
||||
static GLenum BufferUsage[BufferUsage_Max+1];
|
||||
static GLenum ComponentType[ComponentType_Max+1];
|
||||
static GLenum CubemapFace[6]; // Un cube possède six faces et ça n'est pas près de changer
|
||||
static GLenum FaceFilling[FaceFilling_Max+1];
|
||||
static GLenum FaceSide[FaceSide_Max+1];
|
||||
static GLenum PrimitiveMode[PrimitiveMode_Max+1];
|
||||
static GLenum QueryCondition[GpuQueryCondition_Max+1];
|
||||
static GLenum QueryMode[GpuQueryMode_Max+1];
|
||||
static GLenum RendererComparison[RendererComparison_Max+1];
|
||||
static GLenum RendererParameter[RendererParameter_Max+1];
|
||||
static GLenum SamplerWrapMode[SamplerWrap_Max+1];
|
||||
static GLenum ShaderStage[ShaderStageType_Max+1];
|
||||
static GLenum StencilOperation[nzStencilOperation_Max+1];
|
||||
static GLenum TextureTarget[ImageType_Max+1];
|
||||
static GLenum TextureTargetBinding[ImageType_Max+1];
|
||||
static GLenum TextureTargetProxy[ImageType_Max+1];
|
||||
static UInt8 VertexComponentIndex[VertexComponent_Max+1];
|
||||
|
||||
private:
|
||||
static void OnContextChanged(const NzContext* newContext);
|
||||
static void OnContextDestruction(const NzContext* context);
|
||||
};
|
||||
private:
|
||||
static void OnContextChanged(const Context* newContext);
|
||||
static void OnContextDestruction(const Context* context);
|
||||
};
|
||||
}
|
||||
|
||||
NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
|
||||
@@ -15,56 +15,59 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
class NzRenderBuffer;
|
||||
|
||||
using NzRenderBufferConstRef = NzObjectRef<const NzRenderBuffer>;
|
||||
using NzRenderBufferLibrary = NzObjectLibrary<NzRenderBuffer>;
|
||||
using NzRenderBufferRef = NzObjectRef<NzRenderBuffer>;
|
||||
|
||||
class NAZARA_RENDERER_API NzRenderBuffer : public NzRefCounted
|
||||
namespace Nz
|
||||
{
|
||||
friend NzRenderBufferLibrary;
|
||||
friend class NzRenderer;
|
||||
class RenderBuffer;
|
||||
|
||||
public:
|
||||
NzRenderBuffer();
|
||||
NzRenderBuffer(const NzRenderBuffer&) = delete;
|
||||
NzRenderBuffer(NzRenderBuffer&&) = delete;
|
||||
~NzRenderBuffer();
|
||||
using RenderBufferConstRef = ObjectRef<const RenderBuffer>;
|
||||
using RenderBufferLibrary = ObjectLibrary<RenderBuffer>;
|
||||
using RenderBufferRef = ObjectRef<RenderBuffer>;
|
||||
|
||||
bool Create(nzPixelFormat format, unsigned int width, unsigned int height);
|
||||
void Destroy();
|
||||
class NAZARA_RENDERER_API RenderBuffer : public RefCounted
|
||||
{
|
||||
friend RenderBufferLibrary;
|
||||
friend class Renderer;
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
nzPixelFormat GetFormat() const;
|
||||
unsigned int GetWidth() const;
|
||||
public:
|
||||
RenderBuffer();
|
||||
RenderBuffer(const RenderBuffer&) = delete;
|
||||
RenderBuffer(RenderBuffer&&) = delete;
|
||||
~RenderBuffer();
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
bool Create(PixelFormatType format, unsigned int width, unsigned int height);
|
||||
void Destroy();
|
||||
|
||||
bool IsValid() const;
|
||||
unsigned int GetHeight() const;
|
||||
PixelFormatType GetFormat() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
NzRenderBuffer& operator=(const NzRenderBuffer&) = delete;
|
||||
NzRenderBuffer& operator=(NzRenderBuffer&&) = delete;
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
static bool IsSupported();
|
||||
template<typename... Args> static NzRenderBufferRef New(Args&&... args);
|
||||
bool IsValid() const;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnRenderBufferDestroy, const NzRenderBuffer* /*renderBuffer*/);
|
||||
NazaraSignal(OnRenderBufferRelease, const NzRenderBuffer* /*renderBuffer*/);
|
||||
RenderBuffer& operator=(const RenderBuffer&) = delete;
|
||||
RenderBuffer& operator=(RenderBuffer&&) = delete;
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
static bool IsSupported();
|
||||
template<typename... Args> static RenderBufferRef New(Args&&... args);
|
||||
|
||||
nzPixelFormat m_pixelFormat;
|
||||
unsigned int m_height;
|
||||
unsigned int m_id;
|
||||
unsigned int m_width;
|
||||
// Signals:
|
||||
NazaraSignal(OnRenderBufferDestroy, const RenderBuffer* /*renderBuffer*/);
|
||||
NazaraSignal(OnRenderBufferRelease, const RenderBuffer* /*renderBuffer*/);
|
||||
|
||||
static NzRenderBufferLibrary::LibraryMap s_library;
|
||||
};
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
PixelFormatType m_pixelFormat;
|
||||
unsigned int m_height;
|
||||
unsigned int m_id;
|
||||
unsigned int m_width;
|
||||
|
||||
static RenderBufferLibrary::LibraryMap s_library;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderBuffer.inl>
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
#include <memory>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
NzRenderBufferRef NzRenderBuffer::New(Args&&... args)
|
||||
namespace Nz
|
||||
{
|
||||
std::unique_ptr<NzRenderBuffer> object(new NzRenderBuffer(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
RenderBufferRef RenderBuffer::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<RenderBuffer> object(new RenderBuffer(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
@@ -9,35 +9,38 @@
|
||||
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
struct NzRenderStates
|
||||
namespace Nz
|
||||
{
|
||||
NzRenderStates();
|
||||
NzRenderStates(const NzRenderStates& states);
|
||||
~NzRenderStates() = default;
|
||||
|
||||
NzRenderStates& operator=(const NzRenderStates& states);
|
||||
|
||||
struct Face
|
||||
struct RenderStates
|
||||
{
|
||||
nzRendererComparison stencilCompare;
|
||||
nzStencilOperation stencilFail;
|
||||
nzStencilOperation stencilPass;
|
||||
nzStencilOperation stencilZFail;
|
||||
nzUInt32 stencilMask;
|
||||
unsigned int stencilReference;
|
||||
};
|
||||
RenderStates();
|
||||
RenderStates(const RenderStates& states);
|
||||
~RenderStates() = default;
|
||||
|
||||
Face backFace;
|
||||
Face frontFace;
|
||||
nzBlendFunc dstBlend;
|
||||
nzBlendFunc srcBlend;
|
||||
nzFaceFilling faceFilling;
|
||||
nzFaceSide faceCulling;
|
||||
nzRendererComparison depthFunc;
|
||||
bool parameters[nzRendererParameter_Max+1];
|
||||
float lineWidth;
|
||||
float pointSize;
|
||||
};
|
||||
RenderStates& operator=(const RenderStates& states);
|
||||
|
||||
struct Face
|
||||
{
|
||||
RendererComparison stencilCompare;
|
||||
nzStencilOperation stencilFail;
|
||||
nzStencilOperation stencilPass;
|
||||
nzStencilOperation stencilZFail;
|
||||
UInt32 stencilMask;
|
||||
unsigned int stencilReference;
|
||||
};
|
||||
|
||||
Face backFace;
|
||||
Face frontFace;
|
||||
BlendFunc dstBlend;
|
||||
BlendFunc srcBlend;
|
||||
FaceFilling faceFilling;
|
||||
FaceSide faceCulling;
|
||||
RendererComparison depthFunc;
|
||||
bool parameters[RendererParameter_Max+1];
|
||||
float lineWidth;
|
||||
float pointSize;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderStates.inl>
|
||||
|
||||
|
||||
@@ -5,46 +5,49 @@
|
||||
#include <cstring>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
inline NzRenderStates::NzRenderStates() :
|
||||
dstBlend(nzBlendFunc_Zero),
|
||||
srcBlend(nzBlendFunc_One),
|
||||
faceFilling(nzFaceFilling_Fill),
|
||||
faceCulling(nzFaceSide_Back),
|
||||
depthFunc(nzRendererComparison_Less),
|
||||
lineWidth(1.f),
|
||||
pointSize(1.f)
|
||||
namespace Nz
|
||||
{
|
||||
parameters[nzRendererParameter_Blend] = false;
|
||||
parameters[nzRendererParameter_ColorWrite] = true;
|
||||
parameters[nzRendererParameter_DepthBuffer] = false;
|
||||
parameters[nzRendererParameter_DepthWrite] = true;
|
||||
parameters[nzRendererParameter_FaceCulling] = false;
|
||||
parameters[nzRendererParameter_ScissorTest] = false;
|
||||
parameters[nzRendererParameter_StencilTest] = false;
|
||||
|
||||
for (unsigned int i = 0; i < 2; ++i)
|
||||
inline RenderStates::RenderStates() :
|
||||
dstBlend(BlendFunc_Zero),
|
||||
srcBlend(BlendFunc_One),
|
||||
faceFilling(FaceFilling_Fill),
|
||||
faceCulling(FaceSide_Back),
|
||||
depthFunc(RendererComparison_Less),
|
||||
lineWidth(1.f),
|
||||
pointSize(1.f)
|
||||
{
|
||||
Face& face = (i == 0) ? backFace : frontFace;
|
||||
parameters[RendererParameter_Blend] = false;
|
||||
parameters[RendererParameter_ColorWrite] = true;
|
||||
parameters[RendererParameter_DepthBuffer] = false;
|
||||
parameters[RendererParameter_DepthWrite] = true;
|
||||
parameters[RendererParameter_FaceCulling] = false;
|
||||
parameters[RendererParameter_ScissorTest] = false;
|
||||
parameters[RendererParameter_StencilTest] = false;
|
||||
|
||||
face.stencilCompare = nzRendererComparison_Always;
|
||||
face.stencilFail = nzStencilOperation_Keep;
|
||||
face.stencilMask = 0xFFFFFFFF;
|
||||
face.stencilPass = nzStencilOperation_Keep;
|
||||
face.stencilReference = 0;
|
||||
face.stencilZFail = nzStencilOperation_Keep;
|
||||
for (unsigned int i = 0; i < 2; ++i)
|
||||
{
|
||||
Face& face = (i == 0) ? backFace : frontFace;
|
||||
|
||||
face.stencilCompare = RendererComparison_Always;
|
||||
face.stencilFail = nzStencilOperation_Keep;
|
||||
face.stencilMask = 0xFFFFFFFF;
|
||||
face.stencilPass = nzStencilOperation_Keep;
|
||||
face.stencilReference = 0;
|
||||
face.stencilZFail = nzStencilOperation_Keep;
|
||||
}
|
||||
}
|
||||
|
||||
inline RenderStates::RenderStates(const RenderStates& states)
|
||||
{
|
||||
std::memcpy(this, &states, sizeof(RenderStates));
|
||||
}
|
||||
|
||||
inline RenderStates& RenderStates::operator=(const RenderStates& states)
|
||||
{
|
||||
std::memcpy(this, &states, sizeof(RenderStates));
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
inline NzRenderStates::NzRenderStates(const NzRenderStates& states)
|
||||
{
|
||||
std::memcpy(this, &states, sizeof(NzRenderStates));
|
||||
}
|
||||
|
||||
inline NzRenderStates& NzRenderStates::operator=(const NzRenderStates& states)
|
||||
{
|
||||
std::memcpy(this, &states, sizeof(NzRenderStates));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
@@ -13,42 +13,45 @@
|
||||
#include <Nazara/Renderer/RenderTargetParameters.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NzRenderer;
|
||||
|
||||
class NAZARA_RENDERER_API NzRenderTarget
|
||||
namespace Nz
|
||||
{
|
||||
friend class NzRenderer;
|
||||
class Renderer;
|
||||
|
||||
public:
|
||||
NzRenderTarget() = default;
|
||||
NzRenderTarget(const NzRenderTarget&) = delete;
|
||||
NzRenderTarget(NzRenderTarget&&) = delete; ///TOOD?
|
||||
virtual ~NzRenderTarget();
|
||||
class NAZARA_RENDERER_API RenderTarget
|
||||
{
|
||||
friend class Renderer;
|
||||
|
||||
virtual unsigned int GetHeight() const = 0;
|
||||
virtual NzRenderTargetParameters GetParameters() const = 0;
|
||||
virtual unsigned int GetWidth() const = 0;
|
||||
public:
|
||||
RenderTarget() = default;
|
||||
RenderTarget(const RenderTarget&) = delete;
|
||||
RenderTarget(RenderTarget&&) = delete; ///TOOD?
|
||||
virtual ~RenderTarget();
|
||||
|
||||
bool IsActive() const;
|
||||
virtual bool IsRenderable() const = 0;
|
||||
virtual unsigned int GetHeight() const = 0;
|
||||
virtual RenderTargetParameters GetParameters() const = 0;
|
||||
virtual unsigned int GetWidth() const = 0;
|
||||
|
||||
bool SetActive(bool active);
|
||||
bool IsActive() const;
|
||||
virtual bool IsRenderable() const = 0;
|
||||
|
||||
// Fonctions OpenGL
|
||||
virtual bool HasContext() const = 0;
|
||||
bool SetActive(bool active);
|
||||
|
||||
NzRenderTarget& operator=(const NzRenderTarget&) = delete;
|
||||
NzRenderTarget& operator=(NzRenderTarget&&) = delete; ///TOOD?
|
||||
// Fonctions OpenGL
|
||||
virtual bool HasContext() const = 0;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnRenderTargetParametersChange, const NzRenderTarget* /*renderTarget*/);
|
||||
NazaraSignal(OnRenderTargetRelease, const NzRenderTarget* /*renderTarget*/);
|
||||
NazaraSignal(OnRenderTargetSizeChange, const NzRenderTarget* /*renderTarget*/);
|
||||
RenderTarget& operator=(const RenderTarget&) = delete;
|
||||
RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD?
|
||||
|
||||
protected:
|
||||
virtual bool Activate() const = 0;
|
||||
virtual void Desactivate() const;
|
||||
virtual void EnsureTargetUpdated() const = 0;
|
||||
};
|
||||
// Signals:
|
||||
NazaraSignal(OnRenderTargetParametersChange, const RenderTarget* /*renderTarget*/);
|
||||
NazaraSignal(OnRenderTargetRelease, const RenderTarget* /*renderTarget*/);
|
||||
NazaraSignal(OnRenderTargetSizeChange, const RenderTarget* /*renderTarget*/);
|
||||
|
||||
protected:
|
||||
virtual bool Activate() const = 0;
|
||||
virtual void Desactivate() const;
|
||||
virtual void EnsureTargetUpdated() const = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_RENDERTARGET_HPP
|
||||
|
||||
@@ -9,18 +9,21 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
|
||||
struct NzRenderTargetParameters
|
||||
namespace Nz
|
||||
{
|
||||
NzRenderTargetParameters(nzUInt8 antialiasing = 0, nzUInt8 depth = 24, nzUInt8 stencil = 0) :
|
||||
antialiasingLevel(antialiasing),
|
||||
depthBits(depth),
|
||||
stencilBits(stencil)
|
||||
struct RenderTargetParameters
|
||||
{
|
||||
}
|
||||
RenderTargetParameters(UInt8 antialiasing = 0, UInt8 depth = 24, UInt8 stencil = 0) :
|
||||
antialiasingLevel(antialiasing),
|
||||
depthBits(depth),
|
||||
stencilBits(stencil)
|
||||
{
|
||||
}
|
||||
|
||||
nzUInt8 antialiasingLevel;
|
||||
nzUInt8 depthBits;
|
||||
nzUInt8 stencilBits;
|
||||
};
|
||||
UInt8 antialiasingLevel;
|
||||
UInt8 depthBits;
|
||||
UInt8 stencilBits;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_RENDERTARGETPARAMETERS_HPP
|
||||
|
||||
@@ -16,79 +16,82 @@
|
||||
|
||||
///TODO: Faire fonctionner les RenderTexture indépendamment du contexte (un FBO par instance et par contexte l'utilisant)
|
||||
|
||||
class NzContext;
|
||||
class NzRenderBuffer;
|
||||
class NzTexture;
|
||||
|
||||
struct NzRenderTextureImpl;
|
||||
|
||||
class NAZARA_RENDERER_API NzRenderTexture : public NzRenderTarget
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
inline NzRenderTexture();
|
||||
NzRenderTexture(const NzRenderTexture&) = delete;
|
||||
NzRenderTexture(NzRenderTexture&&) = delete; ///TODO?
|
||||
inline ~NzRenderTexture();
|
||||
class Context;
|
||||
class RenderBuffer;
|
||||
class Texture;
|
||||
|
||||
bool AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzRenderBuffer* buffer);
|
||||
bool AttachBuffer(nzAttachmentPoint attachmentPoint, nzUInt8 index, nzPixelFormat format, unsigned int width, unsigned int height);
|
||||
bool AttachTexture(nzAttachmentPoint attachmentPoint, nzUInt8 index, NzTexture* texture, unsigned int z = 0);
|
||||
struct RenderTextureImpl;
|
||||
|
||||
bool Create(bool lock = false);
|
||||
void Destroy();
|
||||
class NAZARA_RENDERER_API RenderTexture : public RenderTarget
|
||||
{
|
||||
public:
|
||||
inline RenderTexture();
|
||||
RenderTexture(const RenderTexture&) = delete;
|
||||
RenderTexture(RenderTexture&&) = delete; ///TODO?
|
||||
inline ~RenderTexture();
|
||||
|
||||
void Detach(nzAttachmentPoint attachmentPoint, nzUInt8 index);
|
||||
bool AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, RenderBuffer* buffer);
|
||||
bool AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, PixelFormatType format, unsigned int width, unsigned int height);
|
||||
bool AttachTexture(AttachmentPoint attachmentPoint, UInt8 index, Texture* texture, unsigned int z = 0);
|
||||
|
||||
unsigned int GetHeight() const override;
|
||||
NzRenderTargetParameters GetParameters() const;
|
||||
NzVector2ui GetSize() const;
|
||||
unsigned int GetWidth() const override;
|
||||
bool Create(bool lock = false);
|
||||
void Destroy();
|
||||
|
||||
bool IsComplete() const;
|
||||
bool IsRenderable() const;
|
||||
inline bool IsValid() const;
|
||||
void Detach(AttachmentPoint attachmentPoint, UInt8 index);
|
||||
|
||||
bool Lock() const;
|
||||
unsigned int GetHeight() const override;
|
||||
RenderTargetParameters GetParameters() const;
|
||||
Vector2ui GetSize() const;
|
||||
unsigned int GetWidth() const override;
|
||||
|
||||
inline void SetColorTarget(nzUInt8 target) const;
|
||||
void SetColorTargets(const nzUInt8* targets, unsigned int targetCount) const;
|
||||
void SetColorTargets(const std::initializer_list<nzUInt8>& targets) const;
|
||||
bool IsComplete() const;
|
||||
bool IsRenderable() const;
|
||||
inline bool IsValid() const;
|
||||
|
||||
void Unlock() const;
|
||||
bool Lock() const;
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
bool HasContext() const override;
|
||||
inline void SetColorTarget(UInt8 target) const;
|
||||
void SetColorTargets(const UInt8* targets, unsigned int targetCount) const;
|
||||
void SetColorTargets(const std::initializer_list<UInt8>& targets) const;
|
||||
|
||||
NzRenderTexture& operator=(const NzRenderTexture&) = delete;
|
||||
NzRenderTexture& operator=(NzRenderTexture&&) = delete; ///TODO?
|
||||
void Unlock() const;
|
||||
|
||||
static inline void Blit(NzRenderTexture* src, NzRenderTexture* dst, nzUInt32 buffers = nzRendererBuffer_Color | nzRendererBuffer_Depth | nzRendererBuffer_Stencil, bool bilinearFilter = false);
|
||||
static void Blit(NzRenderTexture* src, NzRectui srcRect, NzRenderTexture* dst, NzRectui dstRect, nzUInt32 buffers = nzRendererBuffer_Color | nzRendererBuffer_Depth | nzRendererBuffer_Stencil, bool bilinearFilter = false);
|
||||
static bool IsSupported();
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
bool HasContext() const override;
|
||||
|
||||
protected:
|
||||
bool Activate() const override;
|
||||
void Desactivate() const override;
|
||||
void EnsureTargetUpdated() const override;
|
||||
RenderTexture& operator=(const RenderTexture&) = delete;
|
||||
RenderTexture& operator=(RenderTexture&&) = delete; ///TODO?
|
||||
|
||||
private:
|
||||
inline void InvalidateDrawBuffers() const;
|
||||
inline void InvalidateSize() const;
|
||||
inline void InvalidateTargets() const;
|
||||
void OnContextDestroy(const NzContext* context);
|
||||
void OnRenderBufferDestroy(const NzRenderBuffer* renderBuffer, unsigned int attachmentIndex);
|
||||
void OnTextureDestroy(const NzTexture* texture, unsigned int attachmentIndex);
|
||||
void UpdateDrawBuffers() const;
|
||||
void UpdateSize() const;
|
||||
void UpdateTargets() const;
|
||||
static inline void Blit(RenderTexture* src, RenderTexture* dst, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false);
|
||||
static void Blit(RenderTexture* src, Rectui srcRect, RenderTexture* dst, Rectui dstRect, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false);
|
||||
static bool IsSupported();
|
||||
|
||||
NzRenderTextureImpl* m_impl;
|
||||
mutable bool m_checked ;
|
||||
mutable bool m_drawBuffersUpdated;
|
||||
mutable bool m_sizeUpdated;
|
||||
mutable bool m_targetsUpdated;
|
||||
};
|
||||
protected:
|
||||
bool Activate() const override;
|
||||
void Desactivate() const override;
|
||||
void EnsureTargetUpdated() const override;
|
||||
|
||||
private:
|
||||
inline void InvalidateDrawBuffers() const;
|
||||
inline void InvalidateSize() const;
|
||||
inline void InvalidateTargets() const;
|
||||
void OnContextDestroy(const Context* context);
|
||||
void OnRenderBufferDestroy(const RenderBuffer* renderBuffer, unsigned int attachmentIndex);
|
||||
void OnTextureDestroy(const Texture* texture, unsigned int attachmentIndex);
|
||||
void UpdateDrawBuffers() const;
|
||||
void UpdateSize() const;
|
||||
void UpdateTargets() const;
|
||||
|
||||
RenderTextureImpl* m_impl;
|
||||
mutable bool m_checked ;
|
||||
mutable bool m_drawBuffersUpdated;
|
||||
mutable bool m_sizeUpdated;
|
||||
mutable bool m_targetsUpdated;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/RenderTexture.inl>
|
||||
|
||||
|
||||
@@ -6,48 +6,51 @@
|
||||
#include <cstring>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
inline NzRenderTexture::NzRenderTexture() :
|
||||
m_impl(nullptr)
|
||||
namespace Nz
|
||||
{
|
||||
}
|
||||
inline RenderTexture::RenderTexture() :
|
||||
m_impl(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzRenderTexture::~NzRenderTexture()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
inline RenderTexture::~RenderTexture()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
inline bool NzRenderTexture::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
inline bool RenderTexture::IsValid() const
|
||||
{
|
||||
return m_impl != nullptr;
|
||||
}
|
||||
|
||||
inline void NzRenderTexture::SetColorTarget(nzUInt8 target) const
|
||||
{
|
||||
SetColorTargets(&target, 1);
|
||||
}
|
||||
inline void RenderTexture::SetColorTarget(UInt8 target) const
|
||||
{
|
||||
SetColorTargets(&target, 1);
|
||||
}
|
||||
|
||||
inline void NzRenderTexture::Blit(NzRenderTexture* src, NzRenderTexture* dst, nzUInt32 buffers, bool bilinearFilter)
|
||||
{
|
||||
Blit(src, src->GetSize(), dst, dst->GetSize(), buffers, bilinearFilter);
|
||||
}
|
||||
inline void RenderTexture::Blit(RenderTexture* src, RenderTexture* dst, UInt32 buffers, bool bilinearFilter)
|
||||
{
|
||||
Blit(src, src->GetSize(), dst, dst->GetSize(), buffers, bilinearFilter);
|
||||
}
|
||||
|
||||
inline void NzRenderTexture::InvalidateDrawBuffers() const
|
||||
{
|
||||
m_drawBuffersUpdated = false;
|
||||
}
|
||||
inline void RenderTexture::InvalidateDrawBuffers() const
|
||||
{
|
||||
m_drawBuffersUpdated = false;
|
||||
}
|
||||
|
||||
inline void NzRenderTexture::InvalidateSize() const
|
||||
{
|
||||
m_sizeUpdated = false;
|
||||
inline void RenderTexture::InvalidateSize() const
|
||||
{
|
||||
m_sizeUpdated = false;
|
||||
|
||||
OnRenderTargetSizeChange(this);
|
||||
}
|
||||
OnRenderTargetSizeChange(this);
|
||||
}
|
||||
|
||||
inline void NzRenderTexture::InvalidateTargets() const
|
||||
{
|
||||
m_checked = false;
|
||||
m_drawBuffersUpdated = false;
|
||||
m_targetsUpdated = false;
|
||||
inline void RenderTexture::InvalidateTargets() const
|
||||
{
|
||||
m_checked = false;
|
||||
m_drawBuffersUpdated = false;
|
||||
m_targetsUpdated = false;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
@@ -19,61 +19,64 @@
|
||||
#include <Nazara/Utility/Window.hpp>
|
||||
#include <vector>
|
||||
|
||||
class NzAbstractImage;
|
||||
class NzContext;
|
||||
class NzTexture;
|
||||
struct NzContextParameters;
|
||||
|
||||
class NAZARA_RENDERER_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzRenderWindow() = default;
|
||||
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
NzRenderWindow(const NzRenderWindow&) = delete;
|
||||
NzRenderWindow(NzRenderWindow&&) = delete; ///TODO
|
||||
virtual ~NzRenderWindow();
|
||||
class AbstractImage;
|
||||
class Context;
|
||||
class Texture;
|
||||
struct ContextParameters;
|
||||
|
||||
bool CopyToImage(NzAbstractImage* image, const NzVector3ui& dstPos = NzVector3ui(0U)) const;
|
||||
bool CopyToImage(NzAbstractImage* image, const NzRectui& rect, const NzVector3ui& dstPos = NzVector3ui(0U)) const;
|
||||
class NAZARA_RENDERER_API RenderWindow : public RenderTarget, public Window
|
||||
{
|
||||
public:
|
||||
RenderWindow() = default;
|
||||
RenderWindow(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
|
||||
RenderWindow(const RenderWindow&) = delete;
|
||||
RenderWindow(RenderWindow&&) = delete; ///TODO
|
||||
virtual ~RenderWindow();
|
||||
|
||||
bool Create(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool Create(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
bool CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const;
|
||||
bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const;
|
||||
|
||||
void Display();
|
||||
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
|
||||
|
||||
void EnableVerticalSync(bool enabled);
|
||||
void Display();
|
||||
|
||||
unsigned int GetHeight() const;
|
||||
NzRenderTargetParameters GetParameters() const;
|
||||
unsigned int GetWidth() const;
|
||||
void EnableVerticalSync(bool enabled);
|
||||
|
||||
bool IsRenderable() const;
|
||||
bool IsValid() const;
|
||||
unsigned int GetHeight() const;
|
||||
RenderTargetParameters GetParameters() const;
|
||||
unsigned int GetWidth() const;
|
||||
|
||||
void SetFramerateLimit(unsigned int limit);
|
||||
bool IsRenderable() const;
|
||||
bool IsValid() const;
|
||||
|
||||
// Fonctions OpenGL
|
||||
NzContextParameters GetContextParameters() const;
|
||||
bool HasContext() const override;
|
||||
void SetFramerateLimit(unsigned int limit);
|
||||
|
||||
NzRenderWindow& operator=(const NzRenderWindow&) = delete;
|
||||
NzRenderWindow& operator=(NzRenderWindow&&) = delete; ///TODO
|
||||
// Fonctions OpenGL
|
||||
ContextParameters GetContextParameters() const;
|
||||
bool HasContext() const override;
|
||||
|
||||
protected:
|
||||
bool Activate() const override;
|
||||
void EnsureTargetUpdated() const override;
|
||||
RenderWindow& operator=(const RenderWindow&) = delete;
|
||||
RenderWindow& operator=(RenderWindow&&) = delete; ///TODO
|
||||
|
||||
private:
|
||||
bool OnWindowCreated() override;
|
||||
void OnWindowDestroy() override;
|
||||
void OnWindowResized() override;
|
||||
protected:
|
||||
bool Activate() const override;
|
||||
void EnsureTargetUpdated() const override;
|
||||
|
||||
mutable std::vector<nzUInt8> m_buffer;
|
||||
NzClock m_clock;
|
||||
NzContextParameters m_parameters;
|
||||
mutable NzContext* m_context = nullptr;
|
||||
unsigned int m_framerateLimit = 0;
|
||||
};
|
||||
private:
|
||||
bool OnWindowCreated() override;
|
||||
void OnWindowDestroy() override;
|
||||
void OnWindowResized() override;
|
||||
|
||||
mutable std::vector<UInt8> m_buffer;
|
||||
Clock m_clock;
|
||||
ContextParameters m_parameters;
|
||||
mutable Context* m_context = nullptr;
|
||||
unsigned int m_framerateLimit = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_RENDERWINDOW_HPP
|
||||
|
||||
@@ -18,107 +18,110 @@
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Utility/VertexDeclaration.hpp>
|
||||
|
||||
class NzColor;
|
||||
class NzContext;
|
||||
class NzIndexBuffer;
|
||||
class NzRenderTarget;
|
||||
class NzShader;
|
||||
class NzTexture;
|
||||
class NzVertexBuffer;
|
||||
|
||||
class NAZARA_RENDERER_API NzRenderer
|
||||
namespace Nz
|
||||
{
|
||||
friend NzTexture;
|
||||
class Color;
|
||||
class Context;
|
||||
class IndexBuffer;
|
||||
class RenderTarget;
|
||||
class Shader;
|
||||
class Texture;
|
||||
class VertexBuffer;
|
||||
|
||||
public:
|
||||
using DrawCall = void (*)(nzPrimitiveMode, unsigned int, unsigned int);
|
||||
using DrawCallInstanced = void (*)(unsigned int, nzPrimitiveMode, unsigned int, unsigned int);
|
||||
class NAZARA_RENDERER_API Renderer
|
||||
{
|
||||
friend Texture;
|
||||
|
||||
NzRenderer() = delete;
|
||||
~NzRenderer() = delete;
|
||||
public:
|
||||
using DrawCall = void (*)(PrimitiveMode, unsigned int, unsigned int);
|
||||
using DrawCallInstanced = void (*)(unsigned int, PrimitiveMode, unsigned int, unsigned int);
|
||||
|
||||
static void BeginCondition(const NzGpuQuery& query, nzGpuQueryCondition condition);
|
||||
Renderer() = delete;
|
||||
~Renderer() = delete;
|
||||
|
||||
static void Clear(nzUInt32 flags = nzRendererBuffer_Color | nzRendererBuffer_Depth);
|
||||
static void BeginCondition(const GpuQuery& query, GpuQueryCondition condition);
|
||||
|
||||
static void DrawFullscreenQuad();
|
||||
static void DrawIndexedPrimitives(nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawPrimitives(nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
|
||||
static void DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
|
||||
static void Clear(UInt32 flags = RendererBuffer_Color | RendererBuffer_Depth);
|
||||
|
||||
static void Enable(nzRendererParameter parameter, bool enable);
|
||||
static void DrawFullscreenQuad();
|
||||
static void DrawIndexedPrimitives(PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawPrimitives(PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
|
||||
static void DrawPrimitivesInstanced(unsigned int instanceCount, PrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
|
||||
|
||||
static void EndCondition();
|
||||
static void Enable(RendererParameter parameter, bool enable);
|
||||
|
||||
static void Flush();
|
||||
static void EndCondition();
|
||||
|
||||
static nzRendererComparison GetDepthFunc();
|
||||
static NzVertexBuffer* GetInstanceBuffer();
|
||||
static float GetLineWidth();
|
||||
static NzMatrix4f GetMatrix(nzMatrixType type);
|
||||
static nzUInt8 GetMaxAnisotropyLevel();
|
||||
static unsigned int GetMaxColorAttachments();
|
||||
static unsigned int GetMaxRenderTargets();
|
||||
static unsigned int GetMaxTextureSize();
|
||||
static unsigned int GetMaxTextureUnits();
|
||||
static unsigned int GetMaxVertexAttribs();
|
||||
static float GetPointSize();
|
||||
static const NzRenderStates& GetRenderStates();
|
||||
static NzRecti GetScissorRect();
|
||||
static const NzShader* GetShader();
|
||||
static const NzRenderTarget* GetTarget();
|
||||
static NzRecti GetViewport();
|
||||
static void Flush();
|
||||
|
||||
static bool HasCapability(nzRendererCap capability);
|
||||
static RendererComparison GetDepthFunc();
|
||||
static VertexBuffer* GetInstanceBuffer();
|
||||
static float GetLineWidth();
|
||||
static Matrix4f GetMatrix(MatrixType type);
|
||||
static UInt8 GetMaxAnisotropyLevel();
|
||||
static unsigned int GetMaxColorAttachments();
|
||||
static unsigned int GetMaxRenderTargets();
|
||||
static unsigned int GetMaxTextureSize();
|
||||
static unsigned int GetMaxTextureUnits();
|
||||
static unsigned int GetMaxVertexAttribs();
|
||||
static float GetPointSize();
|
||||
static const RenderStates& GetRenderStates();
|
||||
static Recti GetScissorRect();
|
||||
static const Shader* GetShader();
|
||||
static const RenderTarget* GetTarget();
|
||||
static Recti GetViewport();
|
||||
|
||||
static bool Initialize();
|
||||
static bool HasCapability(RendererCap capability);
|
||||
|
||||
static bool IsComponentTypeSupported(nzComponentType type);
|
||||
static bool IsEnabled(nzRendererParameter parameter);
|
||||
static bool IsInitialized();
|
||||
static bool Initialize();
|
||||
|
||||
static void SetBlendFunc(nzBlendFunc srcBlend, nzBlendFunc dstBlend);
|
||||
static void SetClearColor(const NzColor& color);
|
||||
static void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255);
|
||||
static void SetClearDepth(double depth);
|
||||
static void SetClearStencil(unsigned int value);
|
||||
static void SetDepthFunc(nzRendererComparison compareFunc);
|
||||
static void SetFaceCulling(nzFaceSide faceSide);
|
||||
static void SetFaceFilling(nzFaceFilling fillingMode);
|
||||
static void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
static void SetLineWidth(float size);
|
||||
static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix);
|
||||
static void SetPointSize(float size);
|
||||
static void SetRenderStates(const NzRenderStates& states);
|
||||
static void SetScissorRect(const NzRecti& rect);
|
||||
static void SetShader(const NzShader* shader);
|
||||
static void SetStencilCompareFunction(nzRendererComparison compareFunc, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static void SetStencilFailOperation(nzStencilOperation failOperation, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static void SetStencilMask(nzUInt32 mask, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static void SetStencilPassOperation(nzStencilOperation passOperation, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static void SetStencilReferenceValue(unsigned int refValue, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static void SetStencilZFailOperation(nzStencilOperation zfailOperation, nzFaceSide faceSide = nzFaceSide_FrontAndBack);
|
||||
static bool SetTarget(const NzRenderTarget* target);
|
||||
static void SetTexture(nzUInt8 unit, const NzTexture* texture);
|
||||
static void SetTextureSampler(nzUInt8 textureUnit, const NzTextureSampler& sampler);
|
||||
static void SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||
static void SetViewport(const NzRecti& viewport);
|
||||
static bool IsComponentTypeSupported(ComponentType type);
|
||||
static bool IsEnabled(RendererParameter parameter);
|
||||
static bool IsInitialized();
|
||||
|
||||
static void Uninitialize();
|
||||
static void SetBlendFunc(BlendFunc srcBlend, BlendFunc dstBlend);
|
||||
static void SetClearColor(const Color& color);
|
||||
static void SetClearColor(UInt8 r, UInt8 g, UInt8 b, UInt8 a = 255);
|
||||
static void SetClearDepth(double depth);
|
||||
static void SetClearStencil(unsigned int value);
|
||||
static void SetDepthFunc(RendererComparison compareFunc);
|
||||
static void SetFaceCulling(FaceSide faceSide);
|
||||
static void SetFaceFilling(FaceFilling fillingMode);
|
||||
static void SetIndexBuffer(const IndexBuffer* indexBuffer);
|
||||
static void SetLineWidth(float size);
|
||||
static void SetMatrix(MatrixType type, const Matrix4f& matrix);
|
||||
static void SetPointSize(float size);
|
||||
static void SetRenderStates(const RenderStates& states);
|
||||
static void SetScissorRect(const Recti& rect);
|
||||
static void SetShader(const Shader* shader);
|
||||
static void SetStencilCompareFunction(RendererComparison compareFunc, FaceSide faceSide = FaceSide_FrontAndBack);
|
||||
static void SetStencilFailOperation(nzStencilOperation failOperation, FaceSide faceSide = FaceSide_FrontAndBack);
|
||||
static void SetStencilMask(UInt32 mask, FaceSide faceSide = FaceSide_FrontAndBack);
|
||||
static void SetStencilPassOperation(nzStencilOperation passOperation, FaceSide faceSide = FaceSide_FrontAndBack);
|
||||
static void SetStencilReferenceValue(unsigned int refValue, FaceSide faceSide = FaceSide_FrontAndBack);
|
||||
static void SetStencilZFailOperation(nzStencilOperation zfailOperation, FaceSide faceSide = FaceSide_FrontAndBack);
|
||||
static bool SetTarget(const RenderTarget* target);
|
||||
static void SetTexture(UInt8 unit, const Texture* texture);
|
||||
static void SetTextureSampler(UInt8 textureUnit, const TextureSampler& sampler);
|
||||
static void SetVertexBuffer(const VertexBuffer* vertexBuffer);
|
||||
static void SetViewport(const Recti& viewport);
|
||||
|
||||
private:
|
||||
static void EnableInstancing(bool instancing);
|
||||
static bool EnsureStateUpdate();
|
||||
static void OnContextRelease(const NzContext* context);
|
||||
static void OnIndexBufferRelease(const NzIndexBuffer* indexBuffer);
|
||||
static void OnShaderReleased(const NzShader* shader);
|
||||
static void OnTextureReleased(const NzTexture* texture);
|
||||
static void OnVertexBufferRelease(const NzVertexBuffer* vertexBuffer);
|
||||
static void OnVertexDeclarationRelease(const NzVertexDeclaration* vertexDeclaration);
|
||||
static void UpdateMatrix(nzMatrixType type);
|
||||
static void Uninitialize();
|
||||
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
private:
|
||||
static void EnableInstancing(bool instancing);
|
||||
static bool EnsureStateUpdate();
|
||||
static void OnContextRelease(const Context* context);
|
||||
static void OnIndexBufferRelease(const IndexBuffer* indexBuffer);
|
||||
static void OnShaderReleased(const Shader* shader);
|
||||
static void OnTextureReleased(const Texture* texture);
|
||||
static void OnVertexBufferRelease(const VertexBuffer* vertexBuffer);
|
||||
static void OnVertexDeclarationRelease(const VertexDeclaration* vertexDeclaration);
|
||||
static void UpdateMatrix(MatrixType type);
|
||||
|
||||
static unsigned int s_moduleReferenceCounter;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_RENDERER_HPP
|
||||
|
||||
@@ -22,107 +22,110 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
class NzShader;
|
||||
class NzShaderStage;
|
||||
|
||||
using NzShaderConstRef = NzObjectRef<const NzShader>;
|
||||
using NzShaderLibrary = NzObjectLibrary<NzShader>;
|
||||
using NzShaderRef = NzObjectRef<NzShader>;
|
||||
|
||||
class NAZARA_RENDERER_API NzShader : public NzRefCounted
|
||||
namespace Nz
|
||||
{
|
||||
friend NzShaderLibrary;
|
||||
friend class NzRenderer;
|
||||
class Shader;
|
||||
class ShaderStage;
|
||||
|
||||
public:
|
||||
NzShader();
|
||||
NzShader(const NzShader&) = delete;
|
||||
NzShader(NzShader&&) = delete;
|
||||
~NzShader();
|
||||
using ShaderConstRef = ObjectRef<const Shader>;
|
||||
using ShaderLibrary = ObjectLibrary<Shader>;
|
||||
using ShaderRef = ObjectRef<Shader>;
|
||||
|
||||
void AttachStage(nzShaderStage stage, const NzShaderStage& shaderStage);
|
||||
bool AttachStageFromFile(nzShaderStage stage, const NzString& filePath);
|
||||
bool AttachStageFromSource(nzShaderStage stage, const char* source, unsigned int length);
|
||||
bool AttachStageFromSource(nzShaderStage stage, const NzString& source);
|
||||
class NAZARA_RENDERER_API Shader : public RefCounted
|
||||
{
|
||||
friend ShaderLibrary;
|
||||
friend class Renderer;
|
||||
|
||||
void Bind() const;
|
||||
public:
|
||||
Shader();
|
||||
Shader(const Shader&) = delete;
|
||||
Shader(Shader&&) = delete;
|
||||
~Shader();
|
||||
|
||||
bool Create();
|
||||
void Destroy();
|
||||
void AttachStage(ShaderStageType stage, const ShaderStage& shaderStage);
|
||||
bool AttachStageFromFile(ShaderStageType stage, const String& filePath);
|
||||
bool AttachStageFromSource(ShaderStageType stage, const char* source, unsigned int length);
|
||||
bool AttachStageFromSource(ShaderStageType stage, const String& source);
|
||||
|
||||
NzByteArray GetBinary() const;
|
||||
NzString GetLog() const;
|
||||
NzString GetSourceCode(nzShaderStage stage) const;
|
||||
int GetUniformLocation(const NzString& name) const;
|
||||
int GetUniformLocation(nzShaderUniform shaderUniform) const;
|
||||
void Bind() const;
|
||||
|
||||
bool HasStage(nzShaderStage stage) const;
|
||||
bool Create();
|
||||
void Destroy();
|
||||
|
||||
bool IsBinaryRetrievable() const;
|
||||
bool IsLinked() const;
|
||||
bool IsValid() const;
|
||||
ByteArray GetBinary() const;
|
||||
String GetLog() const;
|
||||
String GetSourceCode(ShaderStageType stage) const;
|
||||
int GetUniformLocation(const String& name) const;
|
||||
int GetUniformLocation(ShaderUniform shaderUniform) const;
|
||||
|
||||
bool Link();
|
||||
bool HasStage(ShaderStageType stage) const;
|
||||
|
||||
bool LoadFromBinary(const void* buffer, unsigned int size);
|
||||
bool LoadFromBinary(const NzByteArray& byteArray);
|
||||
bool IsBinaryRetrievable() const;
|
||||
bool IsLinked() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void SendBoolean(int location, bool value) const;
|
||||
void SendColor(int location, const NzColor& color) const;
|
||||
void SendDouble(int location, double value) const;
|
||||
void SendDoubleArray(int location, const double* values, unsigned int count) const;
|
||||
void SendFloat(int location, float value) const;
|
||||
void SendFloatArray(int location, const float* values, unsigned int count) const;
|
||||
void SendInteger(int location, int value) const;
|
||||
void SendIntegerArray(int location, const int* values, unsigned int count) const;
|
||||
void SendMatrix(int location, const NzMatrix4d& matrix) const;
|
||||
void SendMatrix(int location, const NzMatrix4f& matrix) const;
|
||||
void SendVector(int location, const NzVector2d& vector) const;
|
||||
void SendVector(int location, const NzVector2f& vector) const;
|
||||
void SendVector(int location, const NzVector2i& vector) const;
|
||||
void SendVector(int location, const NzVector3d& vector) const;
|
||||
void SendVector(int location, const NzVector3f& vector) const;
|
||||
void SendVector(int location, const NzVector3i& vector) const;
|
||||
void SendVector(int location, const NzVector4d& vector) const;
|
||||
void SendVector(int location, const NzVector4f& vector) const;
|
||||
void SendVector(int location, const NzVector4i& vector) const;
|
||||
void SendVectorArray(int location, const NzVector2d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector2f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector2i* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector3d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector3f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector3i* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector4d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector4f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const NzVector4i* vectors, unsigned int count) const;
|
||||
bool Link();
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
bool LoadFromBinary(const void* buffer, unsigned int size);
|
||||
bool LoadFromBinary(const ByteArray& byteArray);
|
||||
|
||||
NzShader& operator=(const NzShader&) = delete;
|
||||
NzShader& operator=(NzShader&&) = delete;
|
||||
void SendBoolean(int location, bool value) const;
|
||||
void SendColor(int location, const Color& color) const;
|
||||
void SendDouble(int location, double value) const;
|
||||
void SendDoubleArray(int location, const double* values, unsigned int count) const;
|
||||
void SendFloat(int location, float value) const;
|
||||
void SendFloatArray(int location, const float* values, unsigned int count) const;
|
||||
void SendInteger(int location, int value) const;
|
||||
void SendIntegerArray(int location, const int* values, unsigned int count) const;
|
||||
void SendMatrix(int location, const Matrix4d& matrix) const;
|
||||
void SendMatrix(int location, const Matrix4f& matrix) const;
|
||||
void SendVector(int location, const Vector2d& vector) const;
|
||||
void SendVector(int location, const Vector2f& vector) const;
|
||||
void SendVector(int location, const Vector2i& vector) const;
|
||||
void SendVector(int location, const Vector3d& vector) const;
|
||||
void SendVector(int location, const Vector3f& vector) const;
|
||||
void SendVector(int location, const Vector3i& vector) const;
|
||||
void SendVector(int location, const Vector4d& vector) const;
|
||||
void SendVector(int location, const Vector4f& vector) const;
|
||||
void SendVector(int location, const Vector4i& vector) const;
|
||||
void SendVectorArray(int location, const Vector2d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector2f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector2i* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector3d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector3f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector3i* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector4d* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector4f* vectors, unsigned int count) const;
|
||||
void SendVectorArray(int location, const Vector4i* vectors, unsigned int count) const;
|
||||
|
||||
static bool IsStageSupported(nzShaderStage stage);
|
||||
template<typename... Args> static NzShaderRef New(Args&&... args);
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnShaderDestroy, const NzShader* /*shader*/);
|
||||
NazaraSignal(OnShaderRelease, const NzShader* /*shader*/);
|
||||
NazaraSignal(OnShaderUniformInvalidated, const NzShader* /*shader*/);
|
||||
Shader& operator=(const Shader&) = delete;
|
||||
Shader& operator=(Shader&&) = delete;
|
||||
|
||||
private:
|
||||
bool PostLinkage();
|
||||
static bool IsStageSupported(ShaderStageType stage);
|
||||
template<typename... Args> static ShaderRef New(Args&&... args);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
// Signals:
|
||||
NazaraSignal(OnShaderDestroy, const Shader* /*shader*/);
|
||||
NazaraSignal(OnShaderRelease, const Shader* /*shader*/);
|
||||
NazaraSignal(OnShaderUniformInvalidated, const Shader* /*shader*/);
|
||||
|
||||
std::vector<unsigned int> m_attachedShaders[nzShaderStage_Max+1];
|
||||
bool m_linked;
|
||||
int m_uniformLocations[nzShaderUniform_Max+1];
|
||||
unsigned int m_program;
|
||||
private:
|
||||
bool PostLinkage();
|
||||
|
||||
static NzShaderLibrary::LibraryMap s_library;
|
||||
};
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
std::vector<unsigned int> m_attachedShaders[ShaderStageType_Max+1];
|
||||
bool m_linked;
|
||||
int m_uniformLocations[ShaderUniform_Max+1];
|
||||
unsigned int m_program;
|
||||
|
||||
static ShaderLibrary::LibraryMap s_library;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/Shader.inl>
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
#include <memory>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
NzShaderRef NzShader::New(Args&&... args)
|
||||
namespace Nz
|
||||
{
|
||||
std::unique_ptr<NzShader> object(new NzShader(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
ShaderRef Shader::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<Shader> object(new Shader(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
@@ -12,42 +12,45 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
class NAZARA_RENDERER_API NzShaderStage
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzShaderStage();
|
||||
NzShaderStage(nzShaderStage stage);
|
||||
NzShaderStage(const NzShaderStage&) = delete;
|
||||
NzShaderStage(NzShaderStage&& stage);
|
||||
~NzShaderStage();
|
||||
class NAZARA_RENDERER_API ShaderStage
|
||||
{
|
||||
public:
|
||||
ShaderStage();
|
||||
ShaderStage(ShaderStageType stage);
|
||||
ShaderStage(const ShaderStage&) = delete;
|
||||
ShaderStage(ShaderStage&& stage);
|
||||
~ShaderStage();
|
||||
|
||||
bool Compile();
|
||||
bool Compile();
|
||||
|
||||
bool Create(nzShaderStage stage);
|
||||
void Destroy();
|
||||
bool Create(ShaderStageType stage);
|
||||
void Destroy();
|
||||
|
||||
NzString GetLog() const;
|
||||
NzString GetSource() const;
|
||||
String GetLog() const;
|
||||
String GetSource() const;
|
||||
|
||||
bool IsCompiled() const;
|
||||
bool IsValid() const;
|
||||
bool IsCompiled() const;
|
||||
bool IsValid() const;
|
||||
|
||||
void SetSource(const char* source, unsigned int length);
|
||||
void SetSource(const NzString& source);
|
||||
bool SetSourceFromFile(const NzString& filePath);
|
||||
void SetSource(const char* source, unsigned int length);
|
||||
void SetSource(const String& source);
|
||||
bool SetSourceFromFile(const String& filePath);
|
||||
|
||||
NzShaderStage& operator=(const NzShaderStage&) = delete;
|
||||
NzShaderStage& operator=(NzShaderStage&& shader);
|
||||
ShaderStage& operator=(const ShaderStage&) = delete;
|
||||
ShaderStage& operator=(ShaderStage&& shader);
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
static bool IsSupported(nzShaderStage stage);
|
||||
static bool IsSupported(ShaderStageType stage);
|
||||
|
||||
private:
|
||||
nzShaderStage m_stage;
|
||||
bool m_compiled;
|
||||
unsigned int m_id;
|
||||
};
|
||||
private:
|
||||
ShaderStageType m_stage;
|
||||
bool m_compiled;
|
||||
unsigned int m_id;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_SHADERSTAGE_HPP
|
||||
|
||||
@@ -20,114 +20,117 @@
|
||||
#include <Nazara/Utility/CubemapParams.hpp>
|
||||
#include <Nazara/Utility/Image.hpp>
|
||||
|
||||
class NzTexture;
|
||||
|
||||
using NzTextureConstRef = NzObjectRef<const NzTexture>;
|
||||
using NzTextureLibrary = NzObjectLibrary<NzTexture>;
|
||||
using NzTextureManager = NzResourceManager<NzTexture, NzImageParams>;
|
||||
using NzTextureRef = NzObjectRef<NzTexture>;
|
||||
|
||||
struct NzTextureImpl;
|
||||
|
||||
class NAZARA_RENDERER_API NzTexture : public NzAbstractImage, public NzRefCounted, public NzResource
|
||||
namespace Nz
|
||||
{
|
||||
friend NzTextureLibrary;
|
||||
friend NzTextureManager;
|
||||
friend class NzRenderer;
|
||||
class Texture;
|
||||
|
||||
public:
|
||||
NzTexture() = default;
|
||||
NzTexture(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
explicit NzTexture(const NzImage& image);
|
||||
NzTexture(const NzTexture&) = delete;
|
||||
NzTexture(NzTexture&&) = delete;
|
||||
~NzTexture();
|
||||
using TextureConstRef = ObjectRef<const Texture>;
|
||||
using TextureLibrary = ObjectLibrary<Texture>;
|
||||
using TextureManager = ResourceManager<Texture, ImageParams>;
|
||||
using TextureRef = ObjectRef<Texture>;
|
||||
|
||||
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
|
||||
void Destroy();
|
||||
struct TextureImpl;
|
||||
|
||||
bool Download(NzImage* image) const;
|
||||
class NAZARA_RENDERER_API Texture : public AbstractImage, public RefCounted, public Resource
|
||||
{
|
||||
friend TextureLibrary;
|
||||
friend TextureManager;
|
||||
friend class Renderer;
|
||||
|
||||
bool EnableMipmapping(bool enable);
|
||||
public:
|
||||
Texture() = default;
|
||||
Texture(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
|
||||
explicit Texture(const Image& image);
|
||||
Texture(const Texture&) = delete;
|
||||
Texture(Texture&&) = delete;
|
||||
~Texture();
|
||||
|
||||
void EnsureMipmapsUpdate() const;
|
||||
bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
|
||||
void Destroy();
|
||||
|
||||
unsigned int GetDepth(nzUInt8 level = 0) const;
|
||||
nzPixelFormat GetFormat() const;
|
||||
unsigned int GetHeight(nzUInt8 level = 0) const;
|
||||
nzUInt8 GetLevelCount() const;
|
||||
nzUInt8 GetMaxLevel() const;
|
||||
unsigned int GetMemoryUsage() const;
|
||||
unsigned int GetMemoryUsage(nzUInt8 level) const;
|
||||
NzVector3ui GetSize(nzUInt8 level = 0) const;
|
||||
nzImageType GetType() const;
|
||||
unsigned int GetWidth(nzUInt8 level = 0) const;
|
||||
bool Download(Image* image) const;
|
||||
|
||||
bool HasMipmaps() const;
|
||||
bool EnableMipmapping(bool enable);
|
||||
|
||||
void InvalidateMipmaps();
|
||||
bool IsValid() const;
|
||||
void EnsureMipmapsUpdate() const;
|
||||
|
||||
// Load
|
||||
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromImage(const NzImage& image, bool generateMipmaps = true);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
unsigned int GetDepth(UInt8 level = 0) const;
|
||||
PixelFormatType GetFormat() const;
|
||||
unsigned int GetHeight(UInt8 level = 0) const;
|
||||
UInt8 GetLevelCount() const;
|
||||
UInt8 GetMaxLevel() const;
|
||||
unsigned int GetMemoryUsage() const;
|
||||
unsigned int GetMemoryUsage(UInt8 level) const;
|
||||
Vector3ui GetSize(UInt8 level = 0) const;
|
||||
ImageType GetType() const;
|
||||
unsigned int GetWidth(UInt8 level = 0) const;
|
||||
|
||||
// LoadArray
|
||||
bool LoadArrayFromFile(const NzString& filePath, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool LoadArrayFromImage(const NzImage& image, bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool LoadArrayFromMemory(const void* data, std::size_t size, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool LoadArrayFromStream(NzInputStream& stream, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzVector2ui& atlasSize = NzVector2ui(2, 2));
|
||||
bool HasMipmaps() const;
|
||||
|
||||
// LoadCubemap
|
||||
bool LoadCubemapFromFile(const NzString& filePath, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzCubemapParams& cubemapParams = NzCubemapParams());
|
||||
bool LoadCubemapFromImage(const NzImage& image, bool generateMipmaps = true, const NzCubemapParams& params = NzCubemapParams());
|
||||
bool LoadCubemapFromMemory(const void* data, std::size_t size, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzCubemapParams& cubemapParams = NzCubemapParams());
|
||||
bool LoadCubemapFromStream(NzInputStream& stream, const NzImageParams& imageParams = NzImageParams(), bool generateMipmaps = true, const NzCubemapParams& cubemapParams = NzCubemapParams());
|
||||
void InvalidateMipmaps();
|
||||
bool IsValid() const;
|
||||
|
||||
// LoadFace
|
||||
bool LoadFaceFromFile(nzCubemapFace face, const NzString& filePath, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFaceFromMemory(nzCubemapFace face, const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFaceFromStream(nzCubemapFace face, NzInputStream& stream, const NzImageParams& params = NzImageParams());
|
||||
// Load
|
||||
bool LoadFromFile(const String& filePath, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromImage(const Image& image, bool generateMipmaps = true);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromStream(InputStream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
|
||||
|
||||
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
|
||||
// LoadArray
|
||||
bool LoadArrayFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromImage(const Image& image, bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
bool LoadArrayFromStream(InputStream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
|
||||
|
||||
bool Update(const NzImage& image, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzBoxui& box, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
bool Update(const nzUInt8* pixels, const NzRectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
|
||||
// LoadCubemap
|
||||
bool LoadCubemapFromFile(const String& filePath, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
bool LoadCubemapFromImage(const Image& image, bool generateMipmaps = true, const CubemapParams& params = CubemapParams());
|
||||
bool LoadCubemapFromMemory(const void* data, std::size_t size, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
bool LoadCubemapFromStream(InputStream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
|
||||
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
// LoadFace
|
||||
bool LoadFaceFromFile(CubemapFace face, const String& filePath, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromMemory(CubemapFace face, const void* data, std::size_t size, const ImageParams& params = ImageParams());
|
||||
bool LoadFaceFromStream(CubemapFace face, InputStream& stream, const ImageParams& params = ImageParams());
|
||||
|
||||
NzTexture& operator=(const NzTexture&) = delete;
|
||||
NzTexture& operator=(NzTexture&&) = delete;
|
||||
bool SetMipmapRange(UInt8 minLevel, UInt8 maxLevel);
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(nzImageType type);
|
||||
template<typename... Args> static NzTextureRef New(Args&&... args);
|
||||
bool Update(const Image& image, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Boxui& box, UInt8 level = 0);
|
||||
bool Update(const Image& image, const Rectui& rect, unsigned int z = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, const Boxui& box, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
bool Update(const UInt8* pixels, const Rectui& rect, unsigned int z = 0, unsigned int srcWidth = 0, unsigned int srcHeight = 0, UInt8 level = 0);
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnTextureDestroy, const NzTexture* /*texture*/);
|
||||
NazaraSignal(OnTextureRelease, const NzTexture* /*texture*/);
|
||||
// Fonctions OpenGL
|
||||
unsigned int GetOpenGLID() const;
|
||||
|
||||
private:
|
||||
bool CreateTexture(bool proxy);
|
||||
Texture& operator=(const Texture&) = delete;
|
||||
Texture& operator=(Texture&&) = delete;
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(PixelFormatType format);
|
||||
static bool IsMipmappingSupported();
|
||||
static bool IsTypeSupported(ImageType type);
|
||||
template<typename... Args> static TextureRef New(Args&&... args);
|
||||
|
||||
NzTextureImpl* m_impl = nullptr;
|
||||
// Signals:
|
||||
NazaraSignal(OnTextureDestroy, const Texture* /*texture*/);
|
||||
NazaraSignal(OnTextureRelease, const Texture* /*texture*/);
|
||||
|
||||
static NzTextureLibrary::LibraryMap s_library;
|
||||
static NzTextureManager::ManagerMap s_managerMap;
|
||||
static NzTextureManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
private:
|
||||
bool CreateTexture(bool proxy);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
TextureImpl* m_impl = nullptr;
|
||||
|
||||
static TextureLibrary::LibraryMap s_library;
|
||||
static TextureManager::ManagerMap s_managerMap;
|
||||
static TextureManager::ManagerParams s_managerParameters;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/Texture.inl>
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
#include <memory>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
NzTextureRef NzTexture::New(Args&&... args)
|
||||
namespace Nz
|
||||
{
|
||||
std::unique_ptr<NzTexture> object(new NzTexture(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
TextureRef Texture::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<Texture> object(new Texture(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
}
|
||||
|
||||
return object.release();
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
@@ -11,53 +11,56 @@
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
|
||||
class NzTexture;
|
||||
|
||||
class NAZARA_RENDERER_API NzTextureSampler
|
||||
namespace Nz
|
||||
{
|
||||
friend class NzRenderer;
|
||||
class Texture;
|
||||
|
||||
public:
|
||||
NzTextureSampler();
|
||||
NzTextureSampler(const NzTextureSampler& sampler) = default;
|
||||
class NAZARA_RENDERER_API TextureSampler
|
||||
{
|
||||
friend class Renderer;
|
||||
|
||||
nzUInt8 GetAnisotropicLevel() const;
|
||||
nzSamplerFilter GetFilterMode() const;
|
||||
nzSamplerWrap GetWrapMode() const;
|
||||
public:
|
||||
TextureSampler();
|
||||
TextureSampler(const TextureSampler& sampler) = default;
|
||||
|
||||
void SetAnisotropyLevel(nzUInt8 anisotropyLevel);
|
||||
void SetFilterMode(nzSamplerFilter filterMode);
|
||||
void SetWrapMode(nzSamplerWrap wrapMode);
|
||||
UInt8 GetAnisotropicLevel() const;
|
||||
SamplerFilter GetFilterMode() const;
|
||||
SamplerWrap GetWrapMode() const;
|
||||
|
||||
NzTextureSampler& operator=(const NzTextureSampler& sampler) = default;
|
||||
void SetAnisotropyLevel(UInt8 anisotropyLevel);
|
||||
void SetFilterMode(SamplerFilter filterMode);
|
||||
void SetWrapMode(SamplerWrap wrapMode);
|
||||
|
||||
static nzUInt8 GetDefaultAnisotropicLevel();
|
||||
static nzSamplerFilter GetDefaultFilterMode();
|
||||
static nzSamplerWrap GetDefaultWrapMode();
|
||||
TextureSampler& operator=(const TextureSampler& sampler) = default;
|
||||
|
||||
static void SetDefaultAnisotropyLevel(nzUInt8 anisotropyLevel);
|
||||
static void SetDefaultFilterMode(nzSamplerFilter filterMode);
|
||||
static void SetDefaultWrapMode(nzSamplerWrap wrapMode);
|
||||
static UInt8 GetDefaultAnisotropicLevel();
|
||||
static SamplerFilter GetDefaultFilterMode();
|
||||
static SamplerWrap GetDefaultWrapMode();
|
||||
|
||||
private:
|
||||
void Apply(const NzTexture* texture) const;
|
||||
void Bind(unsigned int unit) const;
|
||||
unsigned int GetOpenGLID() const;
|
||||
void UpdateSamplerId() const;
|
||||
bool UseMipmaps(bool mipmaps);
|
||||
static void SetDefaultAnisotropyLevel(UInt8 anisotropyLevel);
|
||||
static void SetDefaultFilterMode(SamplerFilter filterMode);
|
||||
static void SetDefaultWrapMode(SamplerWrap wrapMode);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
private:
|
||||
void Apply(const Texture* texture) const;
|
||||
void Bind(unsigned int unit) const;
|
||||
unsigned int GetOpenGLID() const;
|
||||
void UpdateSamplerId() const;
|
||||
bool UseMipmaps(bool mipmaps);
|
||||
|
||||
nzSamplerFilter m_filterMode;
|
||||
nzSamplerWrap m_wrapMode;
|
||||
nzUInt8 m_anisotropicLevel;
|
||||
bool m_mipmaps;
|
||||
mutable unsigned int m_samplerId;
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
static nzSamplerFilter s_defaultFilterMode;
|
||||
static nzSamplerWrap s_defaultWrapMode;
|
||||
static nzUInt8 s_defaultAnisotropyLevel;
|
||||
};
|
||||
SamplerFilter m_filterMode;
|
||||
SamplerWrap m_wrapMode;
|
||||
UInt8 m_anisotropicLevel;
|
||||
bool m_mipmaps;
|
||||
mutable unsigned int m_samplerId;
|
||||
|
||||
static SamplerFilter s_defaultFilterMode;
|
||||
static SamplerWrap s_defaultWrapMode;
|
||||
static UInt8 s_defaultAnisotropyLevel;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_TEXTURESAMPLER_HPP
|
||||
|
||||
@@ -15,36 +15,39 @@
|
||||
#include <Nazara/Renderer/UberShaderInstance.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NzUberShader;
|
||||
|
||||
using NzUberShaderConstRef = NzObjectRef<const NzUberShader>;
|
||||
using NzUberShaderLibrary = NzObjectLibrary<NzUberShader>;
|
||||
using NzUberShaderRef = NzObjectRef<NzUberShader>;
|
||||
|
||||
class NAZARA_RENDERER_API NzUberShader : public NzRefCounted
|
||||
namespace Nz
|
||||
{
|
||||
friend NzUberShaderLibrary;
|
||||
friend class NzRenderer;
|
||||
class UberShader;
|
||||
|
||||
public:
|
||||
NzUberShader() = default;
|
||||
NzUberShader(const NzUberShader&) = delete;
|
||||
NzUberShader(NzUberShader&&) = delete;
|
||||
virtual ~NzUberShader();
|
||||
using UberShaderConstRef = ObjectRef<const UberShader>;
|
||||
using UberShaderLibrary = ObjectLibrary<UberShader>;
|
||||
using UberShaderRef = ObjectRef<UberShader>;
|
||||
|
||||
virtual NzUberShaderInstance* Get(const NzParameterList& parameters) const = 0;
|
||||
class NAZARA_RENDERER_API UberShader : public RefCounted
|
||||
{
|
||||
friend UberShaderLibrary;
|
||||
friend class Renderer;
|
||||
|
||||
NzUberShader& operator=(const NzUberShader&) = delete;
|
||||
NzUberShader& operator=(NzUberShader&&) = delete;
|
||||
public:
|
||||
UberShader() = default;
|
||||
UberShader(const UberShader&) = delete;
|
||||
UberShader(UberShader&&) = delete;
|
||||
virtual ~UberShader();
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnUberShaderRelease, const NzUberShader* /*uberShader*/);
|
||||
virtual UberShaderInstance* Get(const ParameterList& parameters) const = 0;
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
UberShader& operator=(const UberShader&) = delete;
|
||||
UberShader& operator=(UberShader&&) = delete;
|
||||
|
||||
static NzUberShaderLibrary::LibraryMap s_library;
|
||||
};
|
||||
// Signals:
|
||||
NazaraSignal(OnUberShaderRelease, const UberShader* /*uberShader*/);
|
||||
|
||||
private:
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
static UberShaderLibrary::LibraryMap s_library;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_UBERSHADER_HPP
|
||||
|
||||
@@ -10,23 +10,21 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
|
||||
class NAZARA_RENDERER_API NzUberShaderInstance
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzUberShaderInstance(const NzShader* shader);
|
||||
NzUberShaderInstance(const NzUberShaderInstance&) = delete;
|
||||
NzUberShaderInstance(NzUberShaderInstance&&) = delete;
|
||||
virtual ~NzUberShaderInstance();
|
||||
class NAZARA_RENDERER_API UberShaderInstance
|
||||
{
|
||||
public:
|
||||
UberShaderInstance(const Shader* shader);
|
||||
virtual ~UberShaderInstance();
|
||||
|
||||
virtual bool Activate() const = 0;
|
||||
virtual bool Activate() const = 0;
|
||||
|
||||
const NzShader* GetShader() const;
|
||||
const Shader* GetShader() const;
|
||||
|
||||
NzUberShaderInstance& operator=(const NzUberShaderInstance&) = delete;
|
||||
NzUberShaderInstance& operator=(NzUberShaderInstance&&) = delete;
|
||||
|
||||
protected:
|
||||
NzShaderConstRef m_shader;
|
||||
};
|
||||
protected:
|
||||
ShaderConstRef m_shader;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_UBERSHADERINSTANCE_HPP
|
||||
|
||||
@@ -10,13 +10,16 @@
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Renderer/UberShaderInstance.hpp>
|
||||
|
||||
class NAZARA_RENDERER_API NzUberShaderInstancePreprocessor : public NzUberShaderInstance
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzUberShaderInstancePreprocessor(const NzShader* shader);
|
||||
virtual ~NzUberShaderInstancePreprocessor();
|
||||
class NAZARA_RENDERER_API UberShaderInstancePreprocessor : public UberShaderInstance
|
||||
{
|
||||
public:
|
||||
UberShaderInstancePreprocessor(const Shader* shader);
|
||||
virtual ~UberShaderInstancePreprocessor();
|
||||
|
||||
bool Activate() const;
|
||||
};
|
||||
bool Activate() const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP
|
||||
|
||||
@@ -16,42 +16,45 @@
|
||||
#include <Nazara/Renderer/UberShaderInstancePreprocessor.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
class NzUberShaderPreprocessor;
|
||||
|
||||
using NzUberShaderPreprocessorConstRef = NzObjectRef<const NzUberShaderPreprocessor>;
|
||||
using NzUberShaderPreprocessorRef = NzObjectRef<NzUberShaderPreprocessor>;
|
||||
|
||||
class NAZARA_RENDERER_API NzUberShaderPreprocessor : public NzUberShader
|
||||
namespace Nz
|
||||
{
|
||||
public:
|
||||
NzUberShaderPreprocessor() = default;
|
||||
~NzUberShaderPreprocessor();
|
||||
class UberShaderPreprocessor;
|
||||
|
||||
NzUberShaderInstance* Get(const NzParameterList& parameters) const;
|
||||
using UberShaderPreprocessorConstRef = ObjectRef<const UberShaderPreprocessor>;
|
||||
using UberShaderPreprocessorRef = ObjectRef<UberShaderPreprocessor>;
|
||||
|
||||
void SetShader(nzShaderStage stage, const NzString& source, const NzString& shaderFlags, const NzString& requiredFlags = NzString());
|
||||
bool SetShaderFromFile(nzShaderStage stage, const NzString& filePath, const NzString& shaderFlags, const NzString& requiredFlags = NzString());
|
||||
class NAZARA_RENDERER_API UberShaderPreprocessor : public UberShader
|
||||
{
|
||||
public:
|
||||
UberShaderPreprocessor() = default;
|
||||
~UberShaderPreprocessor();
|
||||
|
||||
static bool IsSupported();
|
||||
template<typename... Args> static NzUberShaderPreprocessorRef New(Args&&... args);
|
||||
UberShaderInstance* Get(const ParameterList& parameters) const;
|
||||
|
||||
// Signals:
|
||||
NazaraSignal(OnUberShaderPreprocessorRelease, const NzUberShaderPreprocessor* /*uberShaderPreprocessor*/);
|
||||
void SetShader(ShaderStageType stage, const String& source, const String& shaderFlags, const String& requiredFlags = String());
|
||||
bool SetShaderFromFile(ShaderStageType stage, const String& filePath, const String& shaderFlags, const String& requiredFlags = String());
|
||||
|
||||
private:
|
||||
struct Shader
|
||||
{
|
||||
mutable std::unordered_map<nzUInt32, NzShaderStage> cache;
|
||||
std::unordered_map<NzString, nzUInt32> flags;
|
||||
nzUInt32 requiredFlags;
|
||||
NzString source;
|
||||
bool present = false;
|
||||
};
|
||||
static bool IsSupported();
|
||||
template<typename... Args> static UberShaderPreprocessorRef New(Args&&... args);
|
||||
|
||||
mutable std::unordered_map<nzUInt32, NzUberShaderInstancePreprocessor> m_cache;
|
||||
std::unordered_map<NzString, nzUInt32> m_flags;
|
||||
Shader m_shaders[nzShaderStage_Max+1];
|
||||
};
|
||||
// Signals:
|
||||
NazaraSignal(OnUberShaderPreprocessorRelease, const UberShaderPreprocessor* /*uberShaderPreprocessor*/);
|
||||
|
||||
private:
|
||||
struct CachedShader
|
||||
{
|
||||
mutable std::unordered_map<UInt32, ShaderStage> cache;
|
||||
std::unordered_map<String, UInt32> flags;
|
||||
UInt32 requiredFlags;
|
||||
String source;
|
||||
bool present = false;
|
||||
};
|
||||
|
||||
mutable std::unordered_map<UInt32, UberShaderInstancePreprocessor> m_cache;
|
||||
std::unordered_map<String, UInt32> m_flags;
|
||||
CachedShader m_shaders[ShaderStageType_Max+1];
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/UberShaderPreprocessor.inl>
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
#include <memory>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
template<typename... Args>
|
||||
NzUberShaderPreprocessorRef NzUberShaderPreprocessor::New(Args&&... args)
|
||||
namespace Nz
|
||||
{
|
||||
std::unique_ptr<NzUberShaderPreprocessor> object(new NzUberShaderPreprocessor(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
template<typename... Args>
|
||||
UberShaderPreprocessorRef UberShaderPreprocessor::New(Args&&... args)
|
||||
{
|
||||
std::unique_ptr<UberShaderPreprocessor> object(new UberShaderPreprocessor(std::forward<Args>(args)...));
|
||||
object->SetPersistent(false);
|
||||
|
||||
return object.release();
|
||||
return object.release();
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user