Add new Renderer architecture (far from complete)

Former-commit-id: 52226793d7a087dfe0523315d3303934daffee49 [formerly 9de1c04df6b371f861a2eee8bba38902ee5041cd] [formerly ecd3099df5498722f6390447f40bd3907b8e40c4 [formerly 3076df585565fc9759ab3e718270f2e5ef620840]]
Former-commit-id: 92d52f967d0b088d1271afef26069e08cacd6b0f [formerly 5fe27e2ead104278951c772c2121a7b677f88d4d]
Former-commit-id: fb6c2456d8edd3ec022d5d953f79fecdd4f2b8f4
This commit is contained in:
Lynix
2016-08-23 12:52:34 +02:00
parent d7a10031d7
commit bdedd05032
132 changed files with 6300 additions and 12587 deletions

View File

@@ -1,80 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_CONTEXT_HPP
#define NAZARA_CONTEXT_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
#include <memory>
#include <vector>
namespace Nz
{
class Context;
using ContextConstRef = ObjectRef<const Context>;
using ContextLibrary = ObjectLibrary<Context>;
using ContextRef = ObjectRef<Context>;
class ContextImpl;
class NAZARA_RENDERER_API Context : public RefCounted
{
friend ContextImpl;
friend ContextLibrary;
friend class OpenGL;
public:
Context() = default;
Context(const Context&) = delete;
Context(Context&&) = delete;
~Context();
bool Create(const ContextParameters& parameters = ContextParameters());
void Destroy();
void EnableVerticalSync(bool enabled);
const ContextParameters& GetParameters() const;
bool IsActive() const;
bool SetActive(bool active) const;
void SwapBuffers();
Context& operator=(const Context&) = delete;
Context& operator=(Context&&) = delete;
static bool EnsureContext();
static const Context* GetCurrent();
static const Context* GetReference();
static const Context* GetThreadContext();
// 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

View File

@@ -1,60 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_CONTEXTPARAMETERS_HPP
#define NAZARA_CONTEXTPARAMETERS_HPP
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/RenderTargetParameters.hpp>
#include <Nazara/Utility/VideoMode.hpp>
#include <Nazara/Utility/WindowHandle.hpp>
namespace Nz
{
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)
{
}
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 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

View File

@@ -1,61 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_DEBUGDRAWER_HPP
#define NAZARA_DEBUGDRAWER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Math/BoundingVolume.hpp>
#include <Nazara/Math/Box.hpp>
#include <Nazara/Math/Frustum.hpp>
#include <Nazara/Math/OrientedBox.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Utility/StaticMesh.hpp>
namespace Nz
{
class Skeleton;
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 void EnableDepthBuffer(bool depthBuffer);
static float GetLineWidth();
static float GetPointSize();
static Color GetPrimaryColor();
static Color GetSecondaryColor();
static bool Initialize();
static bool IsDepthBufferEnabled();
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

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2015 Jérôme Leclercq
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -9,114 +9,29 @@
namespace Nz
{
enum AttachmentPoint
enum RenderAPI
{
AttachmentPoint_Color,
AttachmentPoint_Depth,
AttachmentPoint_DepthStencil,
AttachmentPoint_Stencil,
RenderAPI_Direct3D, ///< Microsoft Render API, only works on MS platforms
RenderAPI_Mantle, ///< AMD Render API, Vulkan predecessor, only works on AMD GPUs
RenderAPI_Metal, ///< Apple Render API, only works on OS X platforms
RenderAPI_OpenGL, ///< Khronos Render API, works on Web/Desktop/Mobile and some consoles
RenderAPI_Vulkan, ///< New Khronos Render API, made to replace OpenGL, works on desktop (Windows/Linux) and mobile (Android)
AttachmentPoint_Max = AttachmentPoint_Stencil
RenderAPI_Other, ///< RenderAPI not corresponding to an entry of the enum, or result of a failed query
RenderAPI_Max = RenderAPI_Other
};
enum GpuQueryCondition
enum RenderDeviceType
{
GpuQueryCondition_Region_NoWait,
GpuQueryCondition_Region_Wait,
GpuQueryCondition_NoWait,
GpuQueryCondition_Wait,
RenderDeviceType_Integrated, ///< Hardware-accelerated chipset integrated to a CPU (ex: Intel Graphics HD 4000)
RenderDeviceType_Dedicated, ///< Hardware-accelerated GPU (ex: AMD R9 390)
RenderDeviceType_Software, ///< Software-renderer
RenderDeviceType_Virtual, ///< Proxy renderer relaying instructions to another unknown device
GpuQueryCondition_Max = GpuQueryCondition_Wait
};
RenderDeviceType_Unknown, ///< Device type not corresponding to an entry of the enum, or result of a failed query
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_FP64,
RendererCap_Instancing,
RendererCap_Max = RendererCap_Instancing
};
enum RendererBufferFlags
{
RendererBuffer_Color = 0x1,
RendererBuffer_Depth = 0x2,
RendererBuffer_Stencil = 0x4,
RendererBuffer_Max = RendererBuffer_Stencil*2-1
};
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
RenderDeviceType_Max = RenderDeviceType_Unknown
};
}

View File

@@ -1,46 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_GPUQUERY_HPP
#define NAZARA_GPUQUERY_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
namespace Nz
{
class NAZARA_RENDERER_API GpuQuery
{
public:
GpuQuery();
GpuQuery(const GpuQuery&) = delete;
GpuQuery(GpuQuery&&) = delete; ///TODO
~GpuQuery();
void Begin(GpuQueryMode mode);
void End();
unsigned int GetResult() const;
bool IsResultAvailable() const;
// Fonctions OpenGL
unsigned int GetOpenGLID() const;
GpuQuery& operator=(const GpuQuery&) = delete;
GpuQuery& operator=(GpuQuery&&) = delete; ///TODO
static bool IsModeSupported(GpuQueryMode mode);
static bool IsSupported();
private:
GpuQueryMode m_mode;
unsigned int m_id;
};
}
#endif // NAZARA_GPUQUERY_HPP

View File

@@ -1,346 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_OPENGL_HPP
#define NAZARA_OPENGL_HPP
#ifdef NAZARA_RENDERER_OPENGL
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/RenderStates.hpp>
#include <Nazara/Utility/Enums.hpp>
// Inclusion des headers OpenGL
#include <GL3/glcorearb.h>
#include <GL3/glext.h>
#if defined(NAZARA_PLATFORM_WINDOWS)
#include <GL3/wglext.h>
#elif defined(NAZARA_PLATFORM_GLX)
namespace GLX
{
#include <GL/glx.h> // Defined in a namespace to avoid conflict
}
#include <GL3/glxext.h>
#endif
namespace Nz
{
enum OpenGLExtension
{
OpenGLExtension_AnisotropicFilter,
OpenGLExtension_DebugOutput,
OpenGLExtension_FP64,
OpenGLExtension_GetProgramBinary,
OpenGLExtension_SeparateShaderObjects,
OpenGLExtension_Shader_ImageLoadStore,
OpenGLExtension_TextureCompression_s3tc,
OpenGLExtension_TextureStorage,
OpenGLExtension_Max = OpenGLExtension_TextureStorage
};
class Context;
class RenderTarget;
using OpenGLFunc = void (*)();
class NAZARA_RENDERER_API OpenGL
{
friend Context;
public:
enum FormatType
{
FormatType_RenderBuffer,
// FormatType_MultisampleTexture,
FormatType_Texture
};
struct Format
{
GLenum dataFormat;
GLenum dataType;
GLint internalFormat;
GLint swizzle[4];
};
OpenGL() = delete;
~OpenGL() = delete;
static void ApplyStates(const RenderStates& states);
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(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(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 OpenGLFunc GetEntry(const String& entryPoint);
static unsigned int GetGLSLVersion();
static String GetRendererName();
static String GetVendorName();
static unsigned int GetVersion();
static bool Initialize();
static bool IsInitialized();
static bool IsSupported(OpenGLExtension extension);
static bool IsSupported(const String& string);
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(PixelFormatType pixelFormat, Format* format, FormatType target);
static void Uninitialize();
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[StencilOperation_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 Context* newContext);
static void OnContextDestruction(const Context* context);
};
NAZARA_RENDERER_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
NAZARA_RENDERER_API extern PFNGLATTACHSHADERPROC glAttachShader;
NAZARA_RENDERER_API extern PFNGLBEGINCONDITIONALRENDERPROC glBeginConditionalRender;
NAZARA_RENDERER_API extern PFNGLBEGINQUERYPROC glBeginQuery;
NAZARA_RENDERER_API extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
NAZARA_RENDERER_API extern PFNGLBINDBUFFERPROC glBindBuffer;
NAZARA_RENDERER_API extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
NAZARA_RENDERER_API extern PFNGLBINDFRAGDATALOCATIONPROC glBindFragDataLocation;
NAZARA_RENDERER_API extern PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer;
NAZARA_RENDERER_API extern PFNGLBINDSAMPLERPROC glBindSampler;
NAZARA_RENDERER_API extern PFNGLBINDTEXTUREPROC glBindTexture;
NAZARA_RENDERER_API extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
NAZARA_RENDERER_API extern PFNGLBLENDFUNCPROC glBlendFunc;
NAZARA_RENDERER_API extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate;
NAZARA_RENDERER_API extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
NAZARA_RENDERER_API extern PFNGLBUFFERDATAPROC glBufferData;
NAZARA_RENDERER_API extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
NAZARA_RENDERER_API extern PFNGLCLEARPROC glClear;
NAZARA_RENDERER_API extern PFNGLCLEARCOLORPROC glClearColor;
NAZARA_RENDERER_API extern PFNGLCLEARDEPTHPROC glClearDepth;
NAZARA_RENDERER_API extern PFNGLCLEARSTENCILPROC glClearStencil;
NAZARA_RENDERER_API extern PFNGLCREATEPROGRAMPROC glCreateProgram;
NAZARA_RENDERER_API extern PFNGLCREATESHADERPROC glCreateShader;
NAZARA_RENDERER_API extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
NAZARA_RENDERER_API extern PFNGLCOLORMASKPROC glColorMask;
NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glCompressedTexSubImage1D;
NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glCompressedTexSubImage2D;
NAZARA_RENDERER_API extern PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glCompressedTexSubImage3D;
NAZARA_RENDERER_API extern PFNGLCULLFACEPROC glCullFace;
NAZARA_RENDERER_API extern PFNGLCOMPILESHADERPROC glCompileShader;
NAZARA_RENDERER_API extern PFNGLCOPYTEXSUBIMAGE2DPROC glCopyTexSubImage2D;
NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECALLBACKPROC glDebugMessageCallback;
NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGECONTROLPROC glDebugMessageControl;
NAZARA_RENDERER_API extern PFNGLDEBUGMESSAGEINSERTPROC glDebugMessageInsert;
NAZARA_RENDERER_API extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
NAZARA_RENDERER_API extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
NAZARA_RENDERER_API extern PFNGLDELETEPROGRAMPROC glDeleteProgram;
NAZARA_RENDERER_API extern PFNGLDELETEQUERIESPROC glDeleteQueries;
NAZARA_RENDERER_API extern PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers;
NAZARA_RENDERER_API extern PFNGLDELETESAMPLERSPROC glDeleteSamplers;
NAZARA_RENDERER_API extern PFNGLDELETESHADERPROC glDeleteShader;
NAZARA_RENDERER_API extern PFNGLDELETETEXTURESPROC glDeleteTextures;
NAZARA_RENDERER_API extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
NAZARA_RENDERER_API extern PFNGLDEPTHFUNCPROC glDepthFunc;
NAZARA_RENDERER_API extern PFNGLDEPTHMASKPROC glDepthMask;
NAZARA_RENDERER_API extern PFNGLDISABLEPROC glDisable;
NAZARA_RENDERER_API extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
NAZARA_RENDERER_API extern PFNGLDRAWARRAYSPROC glDrawArrays;
NAZARA_RENDERER_API extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
NAZARA_RENDERER_API extern PFNGLDRAWBUFFERPROC glDrawBuffer;
NAZARA_RENDERER_API extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSPROC glDrawElements;
NAZARA_RENDERER_API extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced;
NAZARA_RENDERER_API extern PFNGLDRAWTEXTURENVPROC glDrawTexture;
NAZARA_RENDERER_API extern PFNGLENABLEPROC glEnable;
NAZARA_RENDERER_API extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
NAZARA_RENDERER_API extern PFNGLENDCONDITIONALRENDERPROC glEndConditionalRender;
NAZARA_RENDERER_API extern PFNGLENDQUERYPROC glEndQuery;
NAZARA_RENDERER_API extern PFNGLFLUSHPROC glFlush;
NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer;
NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE1DPROC glFramebufferTexture1D;
NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURE3DPROC glFramebufferTexture3D;
NAZARA_RENDERER_API extern PFNGLFRAMEBUFFERTEXTURELAYERPROC glFramebufferTextureLayer;
NAZARA_RENDERER_API extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
NAZARA_RENDERER_API extern PFNGLGENBUFFERSPROC glGenBuffers;
NAZARA_RENDERER_API extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
NAZARA_RENDERER_API extern PFNGLGENQUERIESPROC glGenQueries;
NAZARA_RENDERER_API extern PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers;
NAZARA_RENDERER_API extern PFNGLGENSAMPLERSPROC glGenSamplers;
NAZARA_RENDERER_API extern PFNGLGENTEXTURESPROC glGenTextures;
NAZARA_RENDERER_API extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
NAZARA_RENDERER_API extern PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform;
NAZARA_RENDERER_API extern PFNGLGETBOOLEANVPROC glGetBooleanv;
NAZARA_RENDERER_API extern PFNGLGETBUFFERPARAMETERIVPROC glGetBufferParameteriv;
NAZARA_RENDERER_API extern PFNGLGETDEBUGMESSAGELOGPROC glGetDebugMessageLog;
NAZARA_RENDERER_API extern PFNGLGETERRORPROC glGetError;
NAZARA_RENDERER_API extern PFNGLGETFLOATVPROC glGetFloatv;
NAZARA_RENDERER_API extern PFNGLGETINTEGERVPROC glGetIntegerv;
NAZARA_RENDERER_API extern PFNGLGETPROGRAMBINARYPROC glGetProgramBinary;
NAZARA_RENDERER_API extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
NAZARA_RENDERER_API extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
NAZARA_RENDERER_API extern PFNGLGETQUERYIVPROC glGetQueryiv;
NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTIVPROC glGetQueryObjectiv;
NAZARA_RENDERER_API extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
NAZARA_RENDERER_API extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
NAZARA_RENDERER_API extern PFNGLGETSHADERIVPROC glGetShaderiv;
NAZARA_RENDERER_API extern PFNGLGETSHADERSOURCEPROC glGetShaderSource;
NAZARA_RENDERER_API extern PFNGLGETSTRINGPROC glGetString;
NAZARA_RENDERER_API extern PFNGLGETSTRINGIPROC glGetStringi;
NAZARA_RENDERER_API extern PFNGLGETTEXIMAGEPROC glGetTexImage;
NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERFVPROC glGetTexLevelParameterfv;
NAZARA_RENDERER_API extern PFNGLGETTEXLEVELPARAMETERIVPROC glGetTexLevelParameteriv;
NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERFVPROC glGetTexParameterfv;
NAZARA_RENDERER_API extern PFNGLGETTEXPARAMETERIVPROC glGetTexParameteriv;
NAZARA_RENDERER_API extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
NAZARA_RENDERER_API extern PFNGLINVALIDATEBUFFERDATAPROC glInvalidateBufferData;
NAZARA_RENDERER_API extern PFNGLISENABLEDPROC glIsEnabled;
NAZARA_RENDERER_API extern PFNGLLINEWIDTHPROC glLineWidth;
NAZARA_RENDERER_API extern PFNGLLINKPROGRAMPROC glLinkProgram;
NAZARA_RENDERER_API extern PFNGLMAPBUFFERPROC glMapBuffer;
NAZARA_RENDERER_API extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
NAZARA_RENDERER_API extern PFNGLPIXELSTOREIPROC glPixelStorei;
NAZARA_RENDERER_API extern PFNGLPOINTSIZEPROC glPointSize;
NAZARA_RENDERER_API extern PFNGLPOLYGONMODEPROC glPolygonMode;
NAZARA_RENDERER_API extern PFNGLPROGRAMBINARYPROC glProgramBinary;
NAZARA_RENDERER_API extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DPROC glProgramUniform1d;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FPROC glProgramUniform1f;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IPROC glProgramUniform1i;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1DVPROC glProgramUniform1dv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1FVPROC glProgramUniform1fv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM1IVPROC glProgramUniform1iv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2DVPROC glProgramUniform2dv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2FVPROC glProgramUniform2fv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM2IVPROC glProgramUniform2iv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3DVPROC glProgramUniform3dv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3FVPROC glProgramUniform3fv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM3IVPROC glProgramUniform3iv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4DVPROC glProgramUniform4dv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4FVPROC glProgramUniform4fv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORM4IVPROC glProgramUniform4iv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4DVPROC glProgramUniformMatrix4dv;
NAZARA_RENDERER_API extern PFNGLPROGRAMUNIFORMMATRIX4FVPROC glProgramUniformMatrix4fv;
NAZARA_RENDERER_API extern PFNGLREADPIXELSPROC glReadPixels;
NAZARA_RENDERER_API extern PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage;
NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
NAZARA_RENDERER_API extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
NAZARA_RENDERER_API extern PFNGLSCISSORPROC glScissor;
NAZARA_RENDERER_API extern PFNGLSHADERSOURCEPROC glShaderSource;
NAZARA_RENDERER_API extern PFNGLSTENCILFUNCPROC glStencilFunc;
NAZARA_RENDERER_API extern PFNGLSTENCILFUNCSEPARATEPROC glStencilFuncSeparate;
NAZARA_RENDERER_API extern PFNGLSTENCILOPPROC glStencilOp;
NAZARA_RENDERER_API extern PFNGLSTENCILOPSEPARATEPROC glStencilOpSeparate;
NAZARA_RENDERER_API extern PFNGLTEXIMAGE1DPROC glTexImage1D;
NAZARA_RENDERER_API extern PFNGLTEXIMAGE2DPROC glTexImage2D;
NAZARA_RENDERER_API extern PFNGLTEXIMAGE3DPROC glTexImage3D;
NAZARA_RENDERER_API extern PFNGLTEXPARAMETERFPROC glTexParameterf;
NAZARA_RENDERER_API extern PFNGLTEXPARAMETERIPROC glTexParameteri;
NAZARA_RENDERER_API extern PFNGLTEXSTORAGE1DPROC glTexStorage1D;
NAZARA_RENDERER_API extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
NAZARA_RENDERER_API extern PFNGLTEXSTORAGE3DPROC glTexStorage3D;
NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE1DPROC glTexSubImage1D;
NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE2DPROC glTexSubImage2D;
NAZARA_RENDERER_API extern PFNGLTEXSUBIMAGE3DPROC glTexSubImage3D;
NAZARA_RENDERER_API extern PFNGLUNIFORM1DPROC glUniform1d;
NAZARA_RENDERER_API extern PFNGLUNIFORM1FPROC glUniform1f;
NAZARA_RENDERER_API extern PFNGLUNIFORM1IPROC glUniform1i;
NAZARA_RENDERER_API extern PFNGLUNIFORM1DVPROC glUniform1dv;
NAZARA_RENDERER_API extern PFNGLUNIFORM1FVPROC glUniform1fv;
NAZARA_RENDERER_API extern PFNGLUNIFORM1IVPROC glUniform1iv;
NAZARA_RENDERER_API extern PFNGLUNIFORM2DVPROC glUniform2dv;
NAZARA_RENDERER_API extern PFNGLUNIFORM2FVPROC glUniform2fv;
NAZARA_RENDERER_API extern PFNGLUNIFORM2IVPROC glUniform2iv;
NAZARA_RENDERER_API extern PFNGLUNIFORM3DVPROC glUniform3dv;
NAZARA_RENDERER_API extern PFNGLUNIFORM3FVPROC glUniform3fv;
NAZARA_RENDERER_API extern PFNGLUNIFORM3IVPROC glUniform3iv;
NAZARA_RENDERER_API extern PFNGLUNIFORM4DVPROC glUniform4dv;
NAZARA_RENDERER_API extern PFNGLUNIFORM4FVPROC glUniform4fv;
NAZARA_RENDERER_API extern PFNGLUNIFORM4IVPROC glUniform4iv;
NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4DVPROC glUniformMatrix4dv;
NAZARA_RENDERER_API extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
NAZARA_RENDERER_API extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
NAZARA_RENDERER_API extern PFNGLUSEPROGRAMPROC glUseProgram;
NAZARA_RENDERER_API extern PFNGLVALIDATEPROGRAMPROC glValidateProgram;
NAZARA_RENDERER_API extern PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f;
NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
NAZARA_RENDERER_API extern PFNGLVERTEXATTRIBLPOINTERPROC glVertexAttribLPointer;
NAZARA_RENDERER_API extern PFNGLVIEWPORTPROC glViewport;
#if defined(NAZARA_PLATFORM_WINDOWS)
NAZARA_RENDERER_API extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormat;
NAZARA_RENDERER_API extern PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribs;
NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB;
NAZARA_RENDERER_API extern PFNWGLGETEXTENSIONSSTRINGEXTPROC wglGetExtensionsStringEXT;
NAZARA_RENDERER_API extern PFNWGLSWAPINTERVALEXTPROC wglSwapInterval;
#elif defined(NAZARA_PLATFORM_GLX)
NAZARA_RENDERER_API extern GLX::PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs;
NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALMESAPROC NzglXSwapIntervalMESA;
NAZARA_RENDERER_API extern GLX::PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
#endif
}
#endif // NAZARA_RENDERER_OPENGL
#endif // NAZARA_OPENGL_HPP

View File

@@ -1,73 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERBUFFER_HPP
#define NAZARA_RENDERBUFFER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
namespace Nz
{
class RenderBuffer;
using RenderBufferConstRef = ObjectRef<const RenderBuffer>;
using RenderBufferLibrary = ObjectLibrary<RenderBuffer>;
using RenderBufferRef = ObjectRef<RenderBuffer>;
class NAZARA_RENDERER_API RenderBuffer : public RefCounted
{
friend RenderBufferLibrary;
friend class Renderer;
public:
RenderBuffer();
RenderBuffer(const RenderBuffer&) = delete;
RenderBuffer(RenderBuffer&&) = delete;
~RenderBuffer();
bool Create(PixelFormatType format, unsigned int width, unsigned int height);
void Destroy();
unsigned int GetHeight() const;
PixelFormatType GetFormat() const;
unsigned int GetWidth() const;
// Fonctions OpenGL
unsigned int GetOpenGLID() const;
bool IsValid() const;
RenderBuffer& operator=(const RenderBuffer&) = delete;
RenderBuffer& operator=(RenderBuffer&&) = delete;
template<typename... Args> static RenderBufferRef New(Args&&... args);
// Signals:
NazaraSignal(OnRenderBufferDestroy, const RenderBuffer* /*renderBuffer*/);
NazaraSignal(OnRenderBufferRelease, const RenderBuffer* /*renderBuffer*/);
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>
#endif // NAZARA_RENDERBUFFER_HPP

View File

@@ -1,20 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
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();
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -0,0 +1,23 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERDEVICE_HPP
#define NAZARA_RENDERDEVICE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Renderer/Enums.hpp>
namespace Nz
{
struct RenderDevice
{
RenderDeviceType type;
String name;
};
}
#endif // NAZARA_RENDERER_HPP

View File

@@ -1,42 +0,0 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERPIPELINE_HPP
#define NAZARA_RENDERPIPELINE_HPP
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Renderer/RenderStates.hpp>
#include <Nazara/Renderer/Shader.hpp>
namespace Nz
{
struct RenderPipelineInfo : RenderStates
{
ShaderConstRef shader;
};
class RenderPipeline
{
public:
inline RenderPipeline();
inline ~RenderPipeline();
inline bool Create(const RenderPipelineInfo& pipelineInfo);
inline void Destroy();
inline const RenderPipelineInfo& GetInfo() const;
inline bool IsValid() const;
private:
RenderPipelineInfo m_pipelineInfo;
bool m_valid;
};
}
#include <Nazara/Renderer/RenderPipeline.inl>
#endif // NAZARA_RENDERPIPELINE_HPP

View File

@@ -1,48 +0,0 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/RenderPipeline.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
inline RenderPipeline::RenderPipeline() :
m_valid(false)
{
}
inline RenderPipeline::~RenderPipeline()
{
}
inline bool RenderPipeline::Create(const RenderPipelineInfo& pipelineInfo)
{
NazaraAssert(pipelineInfo.shader, "Invalid shader");
m_pipelineInfo = pipelineInfo;
m_valid = true;
return true;
}
inline void RenderPipeline::Destroy()
{
m_valid = false;
}
inline const RenderPipelineInfo& RenderPipeline::GetInfo() const
{
NazaraAssert(m_valid, "Invalid pipeline info");
return m_pipelineInfo;
}
inline bool RenderPipeline::IsValid() const
{
return m_valid;
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -1,82 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERSTATES_HPP
#define NAZARA_RENDERSTATES_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Enums.hpp>
namespace Nz
{
struct RenderStates
{
BlendFunc dstBlend = BlendFunc_Zero;
BlendFunc srcBlend = BlendFunc_One;
FaceFilling faceFilling = FaceFilling_Fill;
FaceSide cullingSide = FaceSide_Back;
RendererComparison depthFunc = RendererComparison_Less;
struct
{
RendererComparison back = RendererComparison_Always;
RendererComparison front = RendererComparison_Always;
} stencilCompare;
struct
{
UInt32 back = 0xFFFFFFFF;
UInt32 front = 0xFFFFFFFF;
} stencilCompareMask;
struct
{
StencilOperation back = StencilOperation_Keep;
StencilOperation front = StencilOperation_Keep;
} stencilDepthFail;
struct
{
StencilOperation back = StencilOperation_Keep;
StencilOperation front = StencilOperation_Keep;
} stencilFail;
struct
{
StencilOperation back = StencilOperation_Keep;
StencilOperation front = StencilOperation_Keep;
} stencilPass;
struct
{
UInt32 back = 0U;
UInt32 front = 0U;
} stencilReference;
struct
{
UInt32 back = 0xFFFFFFFF;
UInt32 front = 0xFFFFFFFF;
} stencilWriteMask;
bool blending = false;
bool colorWrite = true;
bool depthBuffer = false;
bool depthWrite = true;
bool faceCulling = false;
bool scissorTest = false;
bool stencilTest = false;
float lineWidth = 1.f;
float pointSize = 1.f;
};
inline bool operator==(const RenderStates& lhs, const RenderStates& rhs);
}
#include <Nazara/Renderer/RenderStates.inl>
#endif // NAZARA_RENDERSTATES_HPP

View File

@@ -1,145 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/RenderStates.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Math/Algorithm.hpp>
#include <functional>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
bool operator==(const RenderStates& lhs, const RenderStates& rhs)
{
#define NazaraRenderStateMember(field) if (lhs.field != rhs.field) return false
#define NazaraRenderStateBoolMember NazaraRenderStateMember
#define NazaraRenderStateFloatMember(field, maxDiff) if (!NumberEquals(lhs.field, rhs.field, maxDiff)) return false
NazaraRenderStateBoolMember(blending);
NazaraRenderStateBoolMember(colorWrite);
NazaraRenderStateBoolMember(depthBuffer);
NazaraRenderStateBoolMember(faceCulling);
NazaraRenderStateBoolMember(scissorTest);
NazaraRenderStateBoolMember(stencilTest);
if (lhs.depthBuffer)
NazaraRenderStateBoolMember(depthWrite);
NazaraRenderStateMember(faceFilling);
if (lhs.blending) //< Remember, at this time we know lhs.blending == rhs.blending
{
NazaraRenderStateMember(dstBlend);
NazaraRenderStateMember(srcBlend);
}
if (lhs.depthBuffer)
NazaraRenderStateMember(depthFunc);
if (lhs.faceCulling)
NazaraRenderStateMember(cullingSide);
if (lhs.stencilTest)
{
NazaraRenderStateMember(stencilCompare.back);
NazaraRenderStateMember(stencilCompare.front);
NazaraRenderStateMember(stencilCompareMask.back);
NazaraRenderStateMember(stencilCompareMask.front);
NazaraRenderStateMember(stencilDepthFail.back);
NazaraRenderStateMember(stencilDepthFail.front);
NazaraRenderStateMember(stencilFail.back);
NazaraRenderStateMember(stencilFail.front);
NazaraRenderStateMember(stencilPass.back);
NazaraRenderStateMember(stencilPass.front);
NazaraRenderStateMember(stencilReference.back);
NazaraRenderStateMember(stencilReference.front);
NazaraRenderStateMember(stencilWriteMask.back);
NazaraRenderStateMember(stencilWriteMask.front);
}
NazaraRenderStateFloatMember(lineWidth, 0.001f);
NazaraRenderStateFloatMember(pointSize, 0.001f);
#undef NazaraRenderStateMember
#undef NazaraRenderStateBoolMember
#undef NazaraRenderStateFloatMember
return true;
}
}
namespace std
{
template<>
struct hash<Nz::RenderStates>
{
size_t operator()(const Nz::RenderStates& pipelineInfo) const
{
std::size_t seed = 0;
Nz::UInt8 parameterHash = 0;
Nz::UInt8 parameterIndex = 0;
#define NazaraRenderStateBool(member) parameterHash |= ((pipelineInfo.member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateBoolDep(dependency, member) parameterHash |= ((pipelineInfo.dependency && pipelineInfo.member) ? 1U : 0U) << (parameterIndex++)
#define NazaraRenderStateEnum(member) Nz::HashCombine(seed, static_cast<Nz::UInt8>(pipelineInfo.member))
#define NazaraRenderStateFloat(member, maxDiff) Nz::HashCombine(seed, std::floor(pipelineInfo.member / maxDiff) * maxDiff)
NazaraRenderStateBool(blending);
NazaraRenderStateBool(colorWrite);
NazaraRenderStateBool(depthBuffer);
NazaraRenderStateBool(faceCulling);
NazaraRenderStateBool(scissorTest);
NazaraRenderStateBool(stencilTest);
NazaraRenderStateBoolDep(depthBuffer, depthWrite);
NazaraRenderStateEnum(faceFilling);
if (pipelineInfo.blending) //< Remember, at this time we know lhs.blending == rhs.blending
{
NazaraRenderStateEnum(dstBlend);
NazaraRenderStateEnum(srcBlend);
}
if (pipelineInfo.depthBuffer)
NazaraRenderStateEnum(depthFunc);
if (pipelineInfo.faceCulling)
NazaraRenderStateEnum(cullingSide);
if (pipelineInfo.stencilTest)
{
NazaraRenderStateEnum(stencilCompare.back);
NazaraRenderStateEnum(stencilCompare.front);
NazaraRenderStateEnum(stencilCompareMask.back);
NazaraRenderStateEnum(stencilCompareMask.front);
NazaraRenderStateEnum(stencilDepthFail.back);
NazaraRenderStateEnum(stencilDepthFail.front);
NazaraRenderStateEnum(stencilFail.back);
NazaraRenderStateEnum(stencilFail.front);
NazaraRenderStateEnum(stencilPass.back);
NazaraRenderStateEnum(stencilPass.front);
NazaraRenderStateEnum(stencilReference.back);
NazaraRenderStateEnum(stencilReference.front);
NazaraRenderStateEnum(stencilWriteMask.back);
NazaraRenderStateEnum(stencilWriteMask.front);
}
NazaraRenderStateFloat(lineWidth, 0.001f);
NazaraRenderStateFloat(pointSize, 0.001f);
#undef NazaraRenderStateBool
#undef NazaraRenderStateBoolDep
#undef NazaraRenderStateEnum
#undef NazaraRenderStateFloat
Nz::HashCombine(seed, parameterHash);
return seed;
}
};
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -1,57 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERTARGET_HPP
#define NAZARA_RENDERTARGET_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/RenderTargetParameters.hpp>
#include <unordered_map>
namespace Nz
{
class Renderer;
class NAZARA_RENDERER_API RenderTarget
{
friend class Renderer;
public:
RenderTarget() = default;
RenderTarget(const RenderTarget&) = delete;
RenderTarget(RenderTarget&&) = delete; ///TOOD?
virtual ~RenderTarget();
virtual unsigned int GetHeight() const = 0;
virtual RenderTargetParameters GetParameters() const = 0;
virtual unsigned int GetWidth() const = 0;
bool IsActive() const;
virtual bool IsRenderable() const = 0;
bool SetActive(bool active);
// Fonctions OpenGL
virtual bool HasContext() const = 0;
RenderTarget& operator=(const RenderTarget&) = delete;
RenderTarget& operator=(RenderTarget&&) = delete; ///TOOD?
// 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

View File

@@ -1,29 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERTARGETPARAMETERS_HPP
#define NAZARA_RENDERTARGETPARAMETERS_HPP
#include <Nazara/Prerequesites.hpp>
namespace Nz
{
struct RenderTargetParameters
{
RenderTargetParameters(UInt8 antialiasing = 0, UInt8 depth = 24, UInt8 stencil = 0) :
antialiasingLevel(antialiasing),
depthBits(depth),
stencilBits(stencil)
{
}
UInt8 antialiasingLevel;
UInt8 depthBits;
UInt8 stencilBits;
};
}
#endif // NAZARA_RENDERTARGETPARAMETERS_HPP

View File

@@ -1,98 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERTEXTURE_HPP
#define NAZARA_RENDERTEXTURE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/PixelFormat.hpp>
///TODO: Faire fonctionner les RenderTexture indépendamment du contexte (un FBO par instance et par contexte l'utilisant)
namespace Nz
{
class Context;
class RenderBuffer;
class Texture;
struct RenderTextureImpl;
class NAZARA_RENDERER_API RenderTexture : public RenderTarget
{
public:
inline RenderTexture();
RenderTexture(const RenderTexture&) = delete;
RenderTexture(RenderTexture&&) = delete; ///TODO?
inline ~RenderTexture();
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);
bool Create(bool lock = false);
void Destroy();
void Detach(AttachmentPoint attachmentPoint, UInt8 index);
unsigned int GetHeight() const override;
RenderTargetParameters GetParameters() const override;
Vector2ui GetSize() const;
unsigned int GetWidth() const override;
bool IsComplete() const;
bool IsRenderable() const override;
inline bool IsValid() const;
bool Lock() const;
inline void SetColorTarget(UInt8 target) const;
void SetColorTargets(const UInt8* targets, unsigned int targetCount) const;
void SetColorTargets(const std::initializer_list<UInt8>& targets) const;
void Unlock() const;
// Fonctions OpenGL
unsigned int GetOpenGLID() const;
bool HasContext() const override;
RenderTexture& operator=(const RenderTexture&) = delete;
RenderTexture& operator=(RenderTexture&&) = delete; ///TODO?
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);
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>
#endif // NAZARA_RENDERTEXTURE_HPP

View File

@@ -1,56 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Core/Error.hpp>
#include <cstring>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
inline RenderTexture::RenderTexture() :
m_impl(nullptr)
{
}
inline RenderTexture::~RenderTexture()
{
Destroy();
}
inline bool RenderTexture::IsValid() const
{
return m_impl != nullptr;
}
inline void RenderTexture::SetColorTarget(UInt8 target) const
{
SetColorTargets(&target, 1);
}
inline void RenderTexture::Blit(RenderTexture* src, RenderTexture* dst, UInt32 buffers, bool bilinearFilter)
{
Blit(src, src->GetSize(), dst, dst->GetSize(), buffers, bilinearFilter);
}
inline void RenderTexture::InvalidateDrawBuffers() const
{
m_drawBuffersUpdated = false;
}
inline void RenderTexture::InvalidateSize() const
{
m_sizeUpdated = false;
OnRenderTargetSizeChange(this);
}
inline void RenderTexture::InvalidateTargets() const
{
m_checked = false;
m_drawBuffersUpdated = false;
m_targetsUpdated = false;
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -13,9 +13,6 @@
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/Window.hpp>
#include <vector>

View File

@@ -0,0 +1,81 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Interface inspirée de la SFML par Laurent Gomila
#pragma once
#ifndef NAZARA_RENDERWINDOW_HPP
#define NAZARA_RENDERWINDOW_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/Window.hpp>
#include <vector>
namespace Nz
{
class AbstractImage;
class Context;
class Texture;
struct ContextParameters;
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 CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const;
bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const;
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
void Display();
void EnableVerticalSync(bool enabled);
unsigned int GetHeight() const override;
RenderTargetParameters GetParameters() const override;
unsigned int GetWidth() const override;
bool IsRenderable() const override;
bool IsValid() const;
void SetFramerateLimit(unsigned int limit);
// Fonctions OpenGL
ContextParameters GetContextParameters() const;
bool HasContext() const override;
RenderWindow& operator=(const RenderWindow&) = delete;
RenderWindow& operator=(RenderWindow&&) = delete; ///TODO
protected:
bool Activate() const override;
void EnsureTargetUpdated() const override;
bool OnWindowCreated() override;
void OnWindowDestroy() override;
void OnWindowResized() override;
private:
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

View File

@@ -0,0 +1,81 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
// Interface inspirée de la SFML par Laurent Gomila
#pragma once
#ifndef NAZARA_RENDERWINDOW_HPP
#define NAZARA_RENDERWINDOW_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Clock.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/ContextParameters.hpp>
#include <Nazara/Renderer/RenderTarget.hpp>
#include <Nazara/Utility/Window.hpp>
#include <vector>
namespace Nz
{
class AbstractImage;
class Context;
class Texture;
struct ContextParameters;
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 CopyToImage(AbstractImage* image, const Vector3ui& dstPos = Vector3ui(0U)) const;
bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const;
bool Create(VideoMode mode, const String& title, UInt32 style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
void Display();
void EnableVerticalSync(bool enabled);
unsigned int GetHeight() const override;
RenderTargetParameters GetParameters() const override;
unsigned int GetWidth() const override;
bool IsRenderable() const override;
bool IsValid() const;
void SetFramerateLimit(unsigned int limit);
// Fonctions OpenGL
ContextParameters GetContextParameters() const;
bool HasContext() const override;
RenderWindow& operator=(const RenderWindow&) = delete;
RenderWindow& operator=(RenderWindow&&) = delete; ///TODO
protected:
bool Activate() const override;
void EnsureTargetUpdated() const override;
bool OnWindowCreated() override;
void OnWindowDestroy() override;
void OnWindowResized() override;
private:
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

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2015 Jérôme Leclercq
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
@@ -8,120 +8,33 @@
#define NAZARA_RENDERER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Initializer.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Rect.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/GpuQuery.hpp>
#include <Nazara/Renderer/RenderStates.hpp>
#include <Nazara/Renderer/TextureSampler.hpp>
#include <Nazara/Utility/Enums.hpp>
#include <Nazara/Utility/VertexDeclaration.hpp>
#include <Nazara/Core/DynLib.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/RendererImpl.hpp>
namespace Nz
{
class Color;
class Context;
class IndexBuffer;
class RenderTarget;
class Shader;
class Texture;
class VertexBuffer;
class NAZARA_RENDERER_API Renderer
{
friend Texture;
public:
using DrawCall = void (*)(PrimitiveMode, unsigned int, unsigned int);
using DrawCallInstanced = void (*)(unsigned int, PrimitiveMode, unsigned int, unsigned int);
Renderer() = delete;
~Renderer() = delete;
static void BeginCondition(const GpuQuery& query, GpuQueryCondition condition);
static void Clear(UInt32 flags = RendererBuffer_Color | RendererBuffer_Depth);
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 Enable(RendererParameter parameter, bool enable);
static void EndCondition();
static void Flush();
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 HasCapability(RendererCap capability);
static inline RendererImpl* GetRendererImpl();
static bool Initialize();
static bool IsComponentTypeSupported(ComponentType type);
static bool IsEnabled(RendererParameter parameter);
static bool IsInitialized();
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(StencilOperation failOperation, FaceSide faceSide = FaceSide_FrontAndBack);
static void SetStencilMask(UInt32 mask, FaceSide faceSide = FaceSide_FrontAndBack);
static void SetStencilPassOperation(StencilOperation passOperation, FaceSide faceSide = FaceSide_FrontAndBack);
static void SetStencilReferenceValue(unsigned int refValue, FaceSide faceSide = FaceSide_FrontAndBack);
static void SetStencilZFailOperation(StencilOperation 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);
static inline bool IsInitialized();
static void Uninitialize();
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 DynLib s_rendererLib;
static std::unique_ptr<RendererImpl> s_rendererImpl;
static unsigned int s_moduleReferenceCounter;
};
}
#include <Nazara/Renderer/Renderer.inl>
#endif // NAZARA_RENDERER_HPP

View File

@@ -0,0 +1,21 @@
// Copyright (C) 2016 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Renderer/Renderer.hpp>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
inline RendererImpl* Renderer::GetRendererImpl()
{
return s_rendererImpl.get();
}
inline bool Renderer::IsInitialized()
{
return s_moduleReferenceCounter != 0;
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -0,0 +1,42 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_RENDERER_RENDERERIMPL_HPP
#define NAZARA_RENDERER_RENDERERIMPL_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ParameterList.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Renderer/RenderDevice.hpp>
#include <vector>
namespace Nz
{
class RendererImpl;
using CreateRendererImplFunc = RendererImpl*(*)();
class NAZARA_RENDERER_API RendererImpl
{
public:
RendererImpl() = default;
virtual ~RendererImpl();
virtual bool IsBetterThan(const RendererImpl* other) const = 0;
virtual RenderAPI QueryAPI() const = 0;
virtual String QueryAPIString() const = 0;
virtual UInt32 QueryAPIVersion() const = 0;
virtual std::vector<RenderDevice> QueryRenderDevices() const = 0;
virtual bool Prepare(const ParameterList& parameters) = 0;
};
}
#endif // NAZARA_RENDERER_RENDERERIMPL_HPP

View File

@@ -1,134 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_SHADER_HPP
#define NAZARA_SHADER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ByteArray.hpp>
#include <Nazara/Core/Color.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Matrix4.hpp>
#include <Nazara/Math/Vector2.hpp>
#include <Nazara/Math/Vector3.hpp>
#include <Nazara/Math/Vector4.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
namespace Nz
{
class Shader;
class ShaderStage;
using ShaderConstRef = ObjectRef<const Shader>;
using ShaderLibrary = ObjectLibrary<Shader>;
using ShaderRef = ObjectRef<Shader>;
class NAZARA_RENDERER_API Shader : public RefCounted
{
friend ShaderLibrary;
friend class Renderer;
public:
Shader();
Shader(const Shader&) = delete;
Shader(Shader&&) = delete;
~Shader();
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);
void Bind() const;
bool Create();
void Destroy();
ByteArray GetBinary() const;
String GetLog() const;
String GetSourceCode(ShaderStageType stage) const;
int GetUniformLocation(const String& name) const;
int GetUniformLocation(ShaderUniform shaderUniform) const;
bool HasStage(ShaderStageType stage) const;
bool IsBinaryRetrievable() const;
bool IsLinked() const;
bool IsValid() const;
bool Link();
bool LoadFromBinary(const void* buffer, unsigned int size);
bool LoadFromBinary(const ByteArray& byteArray);
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;
bool Validate() const;
// Fonctions OpenGL
unsigned int GetOpenGLID() const;
Shader& operator=(const Shader&) = delete;
Shader& operator=(Shader&&) = delete;
static bool IsStageSupported(ShaderStageType stage);
template<typename... Args> static ShaderRef New(Args&&... args);
// Signals:
NazaraSignal(OnShaderDestroy, const Shader* /*shader*/);
NazaraSignal(OnShaderRelease, const Shader* /*shader*/);
NazaraSignal(OnShaderUniformInvalidated, const Shader* /*shader*/);
private:
bool PostLinkage();
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>
#endif // NAZARA_SHADER_HPP

View File

@@ -1,20 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
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();
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -1,56 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_SHADERSTAGE_HPP
#define NAZARA_SHADERSTAGE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
namespace Nz
{
class NAZARA_RENDERER_API ShaderStage
{
public:
ShaderStage();
ShaderStage(ShaderStageType stage);
ShaderStage(const ShaderStage&) = delete;
ShaderStage(ShaderStage&& stage);
~ShaderStage();
bool Compile();
bool Create(ShaderStageType stage);
void Destroy();
String GetLog() const;
String GetSource() const;
bool IsCompiled() const;
bool IsValid() const;
void SetSource(const char* source, unsigned int length);
void SetSource(const String& source);
bool SetSourceFromFile(const String& filePath);
ShaderStage& operator=(const ShaderStage&) = delete;
ShaderStage& operator=(ShaderStage&& shader);
// Fonctions OpenGL
unsigned int GetOpenGLID() const;
static bool IsSupported(ShaderStageType stage);
private:
ShaderStageType m_stage;
bool m_compiled;
unsigned int m_id;
};
}
#endif // NAZARA_SHADERSTAGE_HPP

View File

@@ -1,140 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_TEXTURE_HPP
#define NAZARA_TEXTURE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Core/Resource.hpp>
#include <Nazara/Core/ResourceManager.hpp>
#include <Nazara/Core/Signal.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Utility/AbstractImage.hpp>
#include <Nazara/Utility/CubemapParams.hpp>
#include <Nazara/Utility/Image.hpp>
namespace Nz
{
class Texture;
using TextureConstRef = ObjectRef<const Texture>;
using TextureLibrary = ObjectLibrary<Texture>;
using TextureManager = ResourceManager<Texture, ImageParams>;
using TextureRef = ObjectRef<Texture>;
struct TextureImpl;
class NAZARA_RENDERER_API Texture : public AbstractImage, public RefCounted, public Resource
{
friend TextureLibrary;
friend TextureManager;
friend class Renderer;
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();
bool Create(ImageType type, PixelFormatType format, unsigned int width, unsigned int height, unsigned int depth = 1, UInt8 levelCount = 1);
void Destroy();
bool Download(Image* image) const;
bool EnableMipmapping(bool enable);
void EnsureMipmapsUpdate() const;
unsigned int GetDepth(UInt8 level = 0) const;
PixelFormatType GetFormat() const;
unsigned int GetHeight(UInt8 level = 0) const;
UInt8 GetLevelCount() const;
UInt8 GetMaxLevel() const;
std::size_t GetMemoryUsage() const;
std::size_t GetMemoryUsage(UInt8 level) const;
Vector3ui GetSize(UInt8 level = 0) const;
ImageType GetType() const;
unsigned int GetWidth(UInt8 level = 0) const;
bool HasMipmaps() const;
void InvalidateMipmaps();
bool IsValid() const;
// 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(Stream& stream, const ImageParams& params = ImageParams(), bool generateMipmaps = true);
// 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(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const Vector2ui& atlasSize = Vector2ui(2, 2));
// 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(Stream& stream, const ImageParams& imageParams = ImageParams(), bool generateMipmaps = true, const CubemapParams& cubemapParams = CubemapParams());
// 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, Stream& stream, const ImageParams& params = ImageParams());
// Save
bool SaveToFile(const String& filePath, const ImageParams& params = ImageParams());
bool SaveToStream(Stream& stream, const String& format, const ImageParams& params = ImageParams());
bool SetMipmapRange(UInt8 minLevel, UInt8 maxLevel);
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);
// Fonctions OpenGL
unsigned int GetOpenGLID() const;
Texture& operator=(const Texture&) = delete;
Texture& operator=(Texture&&) = delete;
static bool IsFormatSupported(PixelFormatType format);
static bool IsMipmappingSupported();
static bool IsTypeSupported(ImageType type);
template<typename... Args> static TextureRef New(Args&&... args);
// Signals:
NazaraSignal(OnTextureDestroy, const Texture* /*texture*/);
NazaraSignal(OnTextureRelease, const Texture* /*texture*/);
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>
#endif // NAZARA_TEXTURE_HPP

View File

@@ -1,20 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
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();
}
}
#include <Nazara/Renderer/DebugOff.hpp>

View File

@@ -1,66 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_TEXTURESAMPLER_HPP
#define NAZARA_TEXTURESAMPLER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Config.hpp>
#include <Nazara/Utility/Enums.hpp>
namespace Nz
{
class Texture;
class NAZARA_RENDERER_API TextureSampler
{
friend class Renderer;
public:
TextureSampler();
TextureSampler(const TextureSampler& sampler) = default;
UInt8 GetAnisotropicLevel() const;
SamplerFilter GetFilterMode() const;
SamplerWrap GetWrapMode() const;
void SetAnisotropyLevel(UInt8 anisotropyLevel);
void SetFilterMode(SamplerFilter filterMode);
void SetWrapMode(SamplerWrap wrapMode);
TextureSampler& operator=(const TextureSampler& sampler) = default;
static UInt8 GetDefaultAnisotropicLevel();
static SamplerFilter GetDefaultFilterMode();
static SamplerWrap GetDefaultWrapMode();
static void SetDefaultAnisotropyLevel(UInt8 anisotropyLevel);
static void SetDefaultFilterMode(SamplerFilter filterMode);
static void SetDefaultWrapMode(SamplerWrap wrapMode);
private:
void Apply(const Texture* texture) const;
void Bind(unsigned int unit) const;
unsigned int GetOpenGLID() const;
void UpdateSamplerId() const;
bool UseMipmaps(bool mipmaps);
static bool Initialize();
static void Uninitialize();
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

View File

@@ -1,53 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_UBERSHADER_HPP
#define NAZARA_UBERSHADER_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ParameterList.hpp>
#include <Nazara/Core/ObjectLibrary.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Core/RefCounted.hpp>
#include <Nazara/Renderer/UberShaderInstance.hpp>
#include <unordered_map>
namespace Nz
{
class UberShader;
using UberShaderConstRef = ObjectRef<const UberShader>;
using UberShaderLibrary = ObjectLibrary<UberShader>;
using UberShaderRef = ObjectRef<UberShader>;
class NAZARA_RENDERER_API UberShader : public RefCounted
{
friend UberShaderLibrary;
friend class Renderer;
public:
UberShader() = default;
UberShader(const UberShader&) = delete;
UberShader(UberShader&&) = delete;
virtual ~UberShader();
virtual UberShaderInstance* Get(const ParameterList& parameters) const = 0;
UberShader& operator=(const UberShader&) = delete;
UberShader& operator=(UberShader&&) = delete;
// Signals:
NazaraSignal(OnUberShaderRelease, const UberShader* /*uberShader*/);
private:
static bool Initialize();
static void Uninitialize();
static UberShaderLibrary::LibraryMap s_library;
};
}
#endif // NAZARA_UBERSHADER_HPP

View File

@@ -1,30 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_UBERSHADERINSTANCE_HPP
#define NAZARA_UBERSHADERINSTANCE_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Shader.hpp>
namespace Nz
{
class NAZARA_RENDERER_API UberShaderInstance
{
public:
UberShaderInstance(const Shader* shader);
virtual ~UberShaderInstance();
virtual bool Activate() const = 0;
const Shader* GetShader() const;
protected:
ShaderConstRef m_shader;
};
}
#endif // NAZARA_UBERSHADERINSTANCE_HPP

View File

@@ -1,25 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP
#define NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/UberShaderInstance.hpp>
namespace Nz
{
class NAZARA_RENDERER_API UberShaderInstancePreprocessor : public UberShaderInstance
{
public:
UberShaderInstancePreprocessor(const Shader* shader);
virtual ~UberShaderInstancePreprocessor();
bool Activate() const;
};
}
#endif // NAZARA_UBERSHADERINSTANCEPREPROCESSOR_HPP

View File

@@ -1,61 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_UBERSHADERPREPROCESSOR_HPP
#define NAZARA_UBERSHADERPREPROCESSOR_HPP
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Renderer/Enums.hpp>
#include <Nazara/Core/ObjectRef.hpp>
#include <Nazara/Renderer/Shader.hpp>
#include <Nazara/Renderer/ShaderStage.hpp>
#include <Nazara/Renderer/UberShader.hpp>
#include <Nazara/Renderer/UberShaderInstancePreprocessor.hpp>
#include <unordered_map>
namespace Nz
{
class UberShaderPreprocessor;
using UberShaderPreprocessorConstRef = ObjectRef<const UberShaderPreprocessor>;
using UberShaderPreprocessorRef = ObjectRef<UberShaderPreprocessor>;
class NAZARA_RENDERER_API UberShaderPreprocessor : public UberShader
{
public:
UberShaderPreprocessor() = default;
~UberShaderPreprocessor();
UberShaderInstance* Get(const ParameterList& parameters) const;
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());
static bool IsSupported();
template<typename... Args> static UberShaderPreprocessorRef New(Args&&... args);
// 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>
#endif // NAZARA_UBERSHADERPREPROCESSOR_HPP

View File

@@ -1,20 +0,0 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Renderer module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <memory>
#include <Nazara/Renderer/Debug.hpp>
namespace Nz
{
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();
}
}
#include <Nazara/Renderer/DebugOff.hpp>