Greatly improved Renderer

Separated Viewport from Scissor rect
Improved performances
Removed Lock/Unlock system from Shader/Texture class


Former-commit-id: f54bca6de58fe9d495d9192dc0d761f92594ee86
This commit is contained in:
Lynix
2013-05-03 02:58:35 +02:00
parent 76c19624d8
commit 4f3060a40d
15 changed files with 389 additions and 561 deletions

View File

@@ -113,9 +113,10 @@ enum nzRendererParameter
nzRendererParameter_DepthTest,
nzRendererParameter_DepthWrite,
nzRendererParameter_FaceCulling,
nzRendererParameter_Stencil,
nzRendererParameter_ScissorTest,
nzRendererParameter_StencilTest,
nzRendererParameter_Max = nzRendererParameter_Stencil
nzRendererParameter_Max = nzRendererParameter_StencilTest
};
enum nzSamplerFilter

View File

@@ -51,7 +51,7 @@ class NAZARA_API NzOpenGL
enum FormatType
{
FormatType_RenderBuffer,
// FormatType_MultisampleTexture,
// FormatType_MultisampleTexture,
FormatType_Texture
};
@@ -65,15 +65,33 @@ class NAZARA_API NzOpenGL
NzOpenGL() = delete;
~NzOpenGL() = delete;
static void BindBuffer(nzBufferType type, GLuint id);
static void BindProgram(GLuint id);
static void BindTexture(nzImageType type, GLuint id);
static void DeleteBuffer(nzBufferType type, GLuint id);
static void DeleteProgram(GLuint id);
static void DeleteTexture(GLuint id);
static GLuint GetCurrentBuffer(nzBufferType type);
static GLuint GetCurrentProgram();
static GLuint GetCurrentTexture();
static NzOpenGLFunc GetEntry(const NzString& entryPoint);
static NzString GetRendererName();
static unsigned int GetTextureUnit();
static NzString GetVendorName();
static unsigned int GetVersion();
static bool Initialize();
static bool IsInitialized();
static bool IsSupported(nzOpenGLExtension extension);
static bool IsSupported(const NzString& string);
static void SetTextureUnit(unsigned int textureUnit);
static bool TranslateFormat(nzPixelFormat pixelFormat, Format* format, FormatType target);
static void Uninitialize();
static GLenum Attachment[nzAttachmentPoint_Max+1];

View File

@@ -53,6 +53,7 @@ class NAZARA_API NzRenderer
static unsigned int GetMaxRenderTargets();
static unsigned int GetMaxTextureUnits();
static float GetPointSize();
static NzRectui GetScissorRect();
static const NzShader* GetShader();
static const NzRenderTarget* GetTarget();
static NzRectui GetViewport();
@@ -72,12 +73,13 @@ class NAZARA_API NzRenderer
static void SetDepthFunc(nzRendererComparison compareFunc);
static void SetFaceCulling(nzFaceCulling cullingMode);
static void SetFaceFilling(nzFaceFilling fillingMode);
static bool SetIndexBuffer(const NzIndexBuffer* indexBuffer);
static void SetIndexBuffer(const NzIndexBuffer* indexBuffer);
static void SetInstancingData(const InstancingData* instancingData, unsigned int instanceCount);
static void SetLineWidth(float size);
static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix);
static void SetPointSize(float size);
static bool SetShader(const NzShader* shader);
static void SetScissorRect(const NzRectui& viewport);
static void SetShader(const NzShader* shader);
static void SetStencilCompareFunction(nzRendererComparison compareFunc);
static void SetStencilFailOperation(nzStencilOperation failOperation);
static void SetStencilMask(nzUInt32 mask);
@@ -87,13 +89,14 @@ class NAZARA_API NzRenderer
static bool SetTarget(const NzRenderTarget* target);
static void SetTexture(nzUInt8 unit, const NzTexture* texture);
static void SetTextureSampler(nzUInt8 textureUnit, const NzTextureSampler& sampler);
static bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
static void SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
static void SetViewport(const NzRectui& viewport);
static void Uninitialize();
private:
static bool EnsureStateUpdate(bool instancing);
static void EnableInstancing(bool instancing);
static bool EnsureStateUpdate();
static unsigned int s_moduleReferenceCounter;
};

View File

@@ -57,8 +57,6 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
bool Load(nzShaderType type, const NzString& source);
bool LoadFromFile(nzShaderType type, const NzString& source);
bool Lock();
bool SendBoolean(int location, bool value) const;
bool SendColor(int location, const NzColor& color) const;
bool SendDouble(int location, double value) const;
@@ -76,8 +74,6 @@ class NAZARA_API NzShader : public NzResource, NzNonCopyable
void SetFlags(nzUInt32 flags);
void Unlock();
NzShader& operator=(NzShader&& shader);
static bool IsLanguageSupported(nzShaderLanguage language);

View File

@@ -34,7 +34,7 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
explicit NzTexture(const NzImage& image);
~NzTexture();
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1, bool lock = false);
bool Create(nzImageType type, nzPixelFormat format, unsigned int width, unsigned int height, unsigned int depth = 1, nzUInt8 levelCount = 1);
void Destroy();
bool Download(NzImage* image) const;
@@ -72,8 +72,6 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
bool LoadFaceFromMemory(nzCubemapFace face, const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
bool LoadFaceFromStream(nzCubemapFace face, NzInputStream& stream, const NzImageParams& params = NzImageParams());
bool Lock();
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
bool Update(const NzImage& image, nzUInt8 level = 0);
@@ -87,8 +85,6 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
bool UpdateFace(nzCubemapFace face, const nzUInt8* pixels, const NzRectui& rect, unsigned int srcWidth = 0, unsigned int srcHeight = 0, nzUInt8 level = 0);
void Unlock();
// Fonctions OpenGL
bool Bind() const;
unsigned int GetOpenGLID() const;