Refactored mathematics module
Added AABBs Added code examples Added experimental support for texture arrays (1D/2D) Added initialisers (new way of initialising modules) Added global headers (Plus a global header generator script) Added pattern support for directory Added support for spinlocks critical section on Windows Added NzRenderWindow::SetFramerateLimit Core project now includes Mathematics files Fixed color implementation using double Fixed declaration needing renderer include Fixed MLT not clearing nextFree(File/Line) after Free Fixed move operators not being noexcept Fixed thread-safety (Now working correctly - If I'm lucky) Moved Resource to core New interface for modules New interface for the renderer Put some global functions to anonymous namespace Removed empty modules Renamed ThreadCondition to ConditionVariable Replaced redirect to cerr log option by duplicate to cout Setting mouse position relative to a window will make this window ignore the event Shaders sending methods no longer takes the uniform variable name (it's using ID instead) Using new OpenGL 4.3 header
This commit is contained in:
@@ -32,9 +32,6 @@
|
||||
// Active une fenêtre de rendu (NzRenderWindow) lors de sa création
|
||||
#define NAZARA_RENDERER_ACTIVATE_RENDERWINDOW_ON_CREATION 1
|
||||
|
||||
// Force les buffers à posséder un stride multiple de 32 bytes (Gain de performances sur certaines cartes/plus de consommation mémoire)
|
||||
#define NAZARA_RENDERER_FORCE_DECLARATION_STRIDE_MULTIPLE_OF_32 0
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
|
||||
|
||||
|
||||
@@ -35,6 +35,15 @@ enum nzFaceFilling
|
||||
nzFaceFilling_Fill
|
||||
};
|
||||
|
||||
enum nzMatrixType
|
||||
{
|
||||
nzMatrixType_Projection,
|
||||
nzMatrixType_View,
|
||||
nzMatrixType_World,
|
||||
|
||||
nzMatrixType_Max = nzMatrixType_World
|
||||
};
|
||||
|
||||
enum nzPixelBufferType
|
||||
{
|
||||
nzPixelBufferType_Pack,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#ifdef NAZARA_RENDERER_COMMON
|
||||
#error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it
|
||||
#error This file is not part of the common renderer interface, you must undefine NAZARA_RENDERER_COMMON to use it
|
||||
#endif
|
||||
|
||||
#pragma once
|
||||
@@ -12,18 +12,16 @@
|
||||
#define NAZARA_OPENGL_HPP
|
||||
|
||||
// gl3.h définit WIN32_LEAN_AND_MEAN qui entre en conflit avec la définition de Nazara et doit donc être inclut en premier
|
||||
#include <GL3/gl3.h>
|
||||
#include <GL3/glcorearb.h>
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
|
||||
// Il semblerait qu'il ne soit pas conseillé d'inclure gl3.h t glext.h en même temps, mais je ne vois pas oomment gérer les extensions autrement...
|
||||
// Inclusion des extensions
|
||||
#include <GL3/glext.h>
|
||||
#if defined(NAZARA_PLATFORM_WINDOWS)
|
||||
#include <GL3/wglext.h>
|
||||
#elif defined(NAZARA_PLATFORM_LINUX)
|
||||
#include <GL3/glxext.h>
|
||||
#else
|
||||
#error OS not handled
|
||||
#endif
|
||||
|
||||
typedef void (*NzOpenGLFunc)();
|
||||
@@ -40,11 +38,12 @@ class NAZARA_API NzOpenGL
|
||||
PixelBufferObject,
|
||||
SeparateShaderObjects,
|
||||
Texture3D,
|
||||
TextureArray,
|
||||
TextureCompression_s3tc,
|
||||
TextureStorage,
|
||||
VertexArrayObject,
|
||||
|
||||
Count
|
||||
Max = VertexArrayObject
|
||||
};
|
||||
|
||||
static NzOpenGLFunc GetEntry(const NzString& entryPoint);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#define NAZARA_RENDERWINDOW_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/Clock.hpp>
|
||||
#include <Nazara/Renderer/Config.hpp>
|
||||
#include <Nazara/Renderer/ContextParameters.hpp>
|
||||
#include <Nazara/Renderer/RenderTarget.hpp>
|
||||
@@ -23,7 +24,7 @@ struct NzContextParameters;
|
||||
class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
{
|
||||
public:
|
||||
NzRenderWindow();
|
||||
NzRenderWindow() = default;
|
||||
NzRenderWindow(NzVideoMode mode, const NzString& title, nzUInt32 style = nzWindowStyle_Default, const NzContextParameters& parameters = NzContextParameters());
|
||||
NzRenderWindow(NzWindowHandle handle, const NzContextParameters& parameters = NzContextParameters());
|
||||
virtual ~NzRenderWindow();
|
||||
@@ -52,15 +53,19 @@ class NAZARA_API NzRenderWindow : public NzRenderTarget, public NzWindow
|
||||
|
||||
bool IsValid() const;
|
||||
|
||||
void SetFramerateLimit(unsigned int limit);
|
||||
|
||||
protected:
|
||||
bool Activate();
|
||||
virtual bool Activate() override;
|
||||
|
||||
private:
|
||||
void OnClose();
|
||||
bool OnCreate();
|
||||
virtual void OnWindowDestroying() override;
|
||||
virtual bool OnWindowCreated() override;
|
||||
|
||||
NzContext* m_context;
|
||||
NzClock m_clock;
|
||||
NzContextParameters m_parameters;
|
||||
NzContext* m_context = nullptr;
|
||||
unsigned int m_framerateLimit = 0;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERWINDOW_HPP
|
||||
|
||||
@@ -8,99 +8,76 @@
|
||||
#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/Utility/Enums.hpp>
|
||||
#include <map>
|
||||
#include <tuple>
|
||||
|
||||
#define NazaraRenderer NzRenderer::Instance()
|
||||
|
||||
class NzColor;
|
||||
class NzContext;
|
||||
class NzIndexBuffer;
|
||||
class NzRenderTarget;
|
||||
class NzShader;
|
||||
class NzUtility;
|
||||
class NzVertexBuffer;
|
||||
class NzVertexDeclaration;
|
||||
|
||||
class NAZARA_API NzRenderer
|
||||
{
|
||||
public:
|
||||
NzRenderer();
|
||||
~NzRenderer();
|
||||
NzRenderer() = delete;
|
||||
~NzRenderer() = delete;
|
||||
|
||||
void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth);
|
||||
static void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth);
|
||||
|
||||
void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount);
|
||||
void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount);
|
||||
static void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount);
|
||||
|
||||
void Enable(nzRendererParameter parameter, bool enable);
|
||||
static void Enable(nzRendererParameter parameter, bool enable);
|
||||
|
||||
unsigned int GetMaxAnisotropyLevel() const;
|
||||
unsigned int GetMaxRenderTargets() const;
|
||||
unsigned int GetMaxTextureUnits() const;
|
||||
NzShader* GetShader() const;
|
||||
NzRenderTarget* GetTarget() const;
|
||||
NzRectui GetViewport() const;
|
||||
//static NzMatrix4f GetMatrix(nzMatrixCombination combination);
|
||||
static NzMatrix4f GetMatrix(nzMatrixType type);
|
||||
static unsigned int GetMaxAnisotropyLevel();
|
||||
static unsigned int GetMaxRenderTargets();
|
||||
static unsigned int GetMaxTextureUnits();
|
||||
static NzShader* GetShader();
|
||||
static NzRenderTarget* GetTarget();
|
||||
static NzRectui GetViewport();
|
||||
|
||||
bool HasCapability(nzRendererCap capability) const;
|
||||
bool Initialize();
|
||||
static bool HasCapability(nzRendererCap capability);
|
||||
|
||||
void SetBlendFunc(nzBlendFunc src, nzBlendFunc dest);
|
||||
void SetClearColor(const NzColor& color);
|
||||
void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255);
|
||||
void SetClearDepth(double depth);
|
||||
void SetClearStencil(unsigned int value);
|
||||
void SetFaceCulling(nzFaceCulling cullingMode);
|
||||
void SetFaceFilling(nzFaceFilling fillingMode);
|
||||
bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
bool SetShader(NzShader* shader);
|
||||
void SetStencilCompareFunction(nzRendererComparison compareFunc);
|
||||
void SetStencilFailOperation(nzStencilOperation failOperation);
|
||||
void SetStencilMask(nzUInt32 mask);
|
||||
void SetStencilPassOperation(nzStencilOperation passOperation);
|
||||
void SetStencilReferenceValue(unsigned int refValue);
|
||||
void SetStencilZFailOperation(nzStencilOperation zfailOperation);
|
||||
bool SetTarget(NzRenderTarget* target);
|
||||
bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||
bool SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration);
|
||||
void SetViewport(const NzRectui& viewport);
|
||||
static bool Initialize();
|
||||
|
||||
void Uninitialize();
|
||||
|
||||
static NzRenderer* Instance();
|
||||
static bool IsInitialized();
|
||||
|
||||
static void SetBlendFunc(nzBlendFunc src, nzBlendFunc dest);
|
||||
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 SetFaceCulling(nzFaceCulling cullingMode);
|
||||
static void SetFaceFilling(nzFaceFilling fillingMode);
|
||||
static bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
|
||||
static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix);
|
||||
static bool SetShader(NzShader* shader);
|
||||
static void SetStencilCompareFunction(nzRendererComparison compareFunc);
|
||||
static void SetStencilFailOperation(nzStencilOperation failOperation);
|
||||
static void SetStencilMask(nzUInt32 mask);
|
||||
static void SetStencilPassOperation(nzStencilOperation passOperation);
|
||||
static void SetStencilReferenceValue(unsigned int refValue);
|
||||
static void SetStencilZFailOperation(nzStencilOperation zfailOperation);
|
||||
static bool SetTarget(NzRenderTarget* target);
|
||||
static bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||
static bool SetVertexDeclaration(const NzVertexDeclaration* vertexDeclaration);
|
||||
static void SetViewport(const NzRectui& viewport);
|
||||
|
||||
static void Uninitialize();
|
||||
|
||||
private:
|
||||
bool EnsureStateUpdate();
|
||||
static bool EnsureStateUpdate();
|
||||
|
||||
typedef std::tuple<const NzContext*, const NzIndexBuffer*, const NzVertexBuffer*, const NzVertexDeclaration*> VAO_Key;
|
||||
|
||||
std::map<VAO_Key, unsigned int> m_vaos;
|
||||
nzRendererComparison m_stencilCompare;
|
||||
nzStencilOperation m_stencilFail;
|
||||
nzStencilOperation m_stencilPass;
|
||||
nzStencilOperation m_stencilZFail;
|
||||
nzUInt32 m_stencilMask;
|
||||
const NzIndexBuffer* m_indexBuffer;
|
||||
NzRenderTarget* m_target;
|
||||
NzShader* m_shader;
|
||||
NzUtility* m_utilityModule;
|
||||
const NzVertexBuffer* m_vertexBuffer;
|
||||
const NzVertexDeclaration* m_vertexDeclaration;
|
||||
bool m_vaoUpdated;
|
||||
bool m_capabilities[nzRendererCap_Max+1];
|
||||
bool m_stencilFuncUpdated;
|
||||
bool m_stencilOpUpdated;
|
||||
unsigned int m_maxAnisotropyLevel;
|
||||
unsigned int m_maxRenderTarget;
|
||||
unsigned int m_maxTextureUnit;
|
||||
unsigned int m_stencilReference;
|
||||
|
||||
static NzRenderer* s_instance;
|
||||
static bool s_initialized;
|
||||
static unsigned int s_moduleReferenceCouter;
|
||||
};
|
||||
|
||||
#endif // NAZARA_RENDERER_HPP
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Core/NonCopyable.hpp>
|
||||
#include <Nazara/Core/Resource.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/Enums.hpp>
|
||||
#include <Nazara/Utility/Resource.hpp>
|
||||
|
||||
class NzRenderer;
|
||||
class NzShaderImpl;
|
||||
@@ -38,6 +38,9 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
||||
NzString GetLog() const;
|
||||
nzShaderLanguage GetLanguage() const;
|
||||
NzString GetSourceCode(nzShaderType type) const;
|
||||
int GetUniformLocation(const NzString& name) const;
|
||||
|
||||
bool HasUniform(const NzString& name) const;
|
||||
|
||||
bool IsCompiled() const;
|
||||
bool IsLoaded(nzShaderType type) const;
|
||||
@@ -47,19 +50,19 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
|
||||
|
||||
bool Lock();
|
||||
|
||||
bool SendBoolean(const NzString& name, bool value);
|
||||
bool SendDouble(const NzString& name, double value);
|
||||
bool SendFloat(const NzString& name, float value);
|
||||
bool SendInteger(const NzString& name, int value);
|
||||
bool SendMatrix(const NzString& name, const NzMatrix4d& matrix);
|
||||
bool SendMatrix(const NzString& name, const NzMatrix4f& matrix);
|
||||
bool SendVector(const NzString& name, const NzVector2d& vector);
|
||||
bool SendVector(const NzString& name, const NzVector2f& vector);
|
||||
bool SendVector(const NzString& name, const NzVector3d& vector);
|
||||
bool SendVector(const NzString& name, const NzVector3f& vector);
|
||||
bool SendVector(const NzString& name, const NzVector4d& vector);
|
||||
bool SendVector(const NzString& name, const NzVector4f& vector);
|
||||
bool SendTexture(const NzString& name, NzTexture* texture);
|
||||
bool SendBoolean(int location, bool value);
|
||||
bool SendDouble(int location, double value);
|
||||
bool SendFloat(int location, float value);
|
||||
bool SendInteger(int location, int value);
|
||||
bool SendMatrix(int location, const NzMatrix4d& matrix);
|
||||
bool SendMatrix(int location, const NzMatrix4f& matrix);
|
||||
bool SendTexture(int location, const NzTexture* texture);
|
||||
bool SendVector(int location, const NzVector2d& vector);
|
||||
bool SendVector(int location, const NzVector2f& vector);
|
||||
bool SendVector(int location, const NzVector3d& vector);
|
||||
bool SendVector(int location, const NzVector3f& vector);
|
||||
bool SendVector(int location, const NzVector4d& vector);
|
||||
bool SendVector(int location, const NzVector4f& vector);
|
||||
|
||||
void Unlock();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user