Added RenderStates
Former-commit-id: c742cf2fc1cac807b9e2bcbd88c2b3d77327c106
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include <Nazara/Core/ResourceRef.hpp>
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/Shader.hpp>
|
||||
#include <Nazara/Renderer/Texture.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
@@ -44,16 +45,16 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
|
||||
void Apply(const NzShader* shader) const;
|
||||
|
||||
void EnableAlphaBlending(bool alphaBlending);
|
||||
void EnableAlphaBlending(bool blending);
|
||||
void EnableFaceCulling(bool faceCulling);
|
||||
void EnableLighting(bool lighting);
|
||||
void EnableZBuffer(bool zBuffer);
|
||||
void EnableZWrite(bool zWrite);
|
||||
|
||||
NzColor GetAmbientColor() const;
|
||||
NzTexture* GetAlphaMap() const;
|
||||
const NzShader* GetCustomShader() const;
|
||||
NzColor GetDiffuseColor() const;
|
||||
NzTexture* GetAlphaMap() const;
|
||||
NzTexture* GetDiffuseMap() const;
|
||||
NzTextureSampler& GetDiffuseSampler();
|
||||
const NzTextureSampler& GetDiffuseSampler() const;
|
||||
@@ -119,15 +120,11 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
private:
|
||||
void Copy(const NzMaterial& material);
|
||||
|
||||
nzBlendFunc m_dstBlend;
|
||||
nzBlendFunc m_srcBlend;
|
||||
nzFaceCulling m_faceCulling;
|
||||
nzFaceFilling m_faceFilling;
|
||||
nzRendererComparison m_zTestCompareFunc;
|
||||
nzUInt32 m_shaderFlags;
|
||||
NzColor m_ambientColor;
|
||||
NzColor m_diffuseColor;
|
||||
NzColor m_specularColor;
|
||||
NzRenderStates m_states;
|
||||
NzTextureSampler m_diffuseSampler;
|
||||
NzTextureSampler m_specularSampler;
|
||||
mutable NzShaderConstRef m_customShader;
|
||||
@@ -137,11 +134,7 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
NzTextureRef m_heightMap;
|
||||
NzTextureRef m_normalMap;
|
||||
NzTextureRef m_specularMap;
|
||||
bool m_alphaBlendingEnabled;
|
||||
bool m_faceCullingEnabled;
|
||||
bool m_lightingEnabled;
|
||||
bool m_zBufferEnabled;
|
||||
bool m_zWriteEnabled;
|
||||
float m_shininess;
|
||||
|
||||
static NzMaterialLoader::LoaderList s_loaders;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <Nazara/Core/String.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
|
||||
// Inclusion des extensions
|
||||
#include <GL3/glext.h>
|
||||
@@ -65,6 +66,8 @@ class NAZARA_API NzOpenGL
|
||||
NzOpenGL() = delete;
|
||||
~NzOpenGL() = delete;
|
||||
|
||||
static void ApplyStates(const NzRenderStates& states);
|
||||
|
||||
static void BindBuffer(nzBufferType type, GLuint id);
|
||||
static void BindProgram(GLuint id);
|
||||
static void BindTexture(nzImageType type, GLuint id);
|
||||
|
||||
38
include/Nazara/Renderer/RenderStates.hpp
Normal file
38
include/Nazara/Renderer/RenderStates.hpp
Normal file
@@ -0,0 +1,38 @@
|
||||
// Copyright (C) 2013 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/Renderer/Enums.hpp>
|
||||
|
||||
struct NzRenderStates
|
||||
{
|
||||
NzRenderStates();
|
||||
NzRenderStates(const NzRenderStates& states);
|
||||
~NzRenderStates() = default;
|
||||
|
||||
NzRenderStates& operator=(const NzRenderStates& states);
|
||||
|
||||
nzBlendFunc dstBlend;
|
||||
nzBlendFunc srcBlend;
|
||||
nzFaceCulling faceCulling;
|
||||
nzFaceFilling faceFilling;
|
||||
nzRendererComparison depthFunc;
|
||||
nzRendererComparison stencilCompare;
|
||||
nzStencilOperation stencilFail;
|
||||
nzStencilOperation stencilPass;
|
||||
nzStencilOperation stencilZFail;
|
||||
nzUInt32 stencilMask;
|
||||
bool parameters[nzRendererParameter_Max+1];
|
||||
float lineWidth;
|
||||
float pointSize;
|
||||
unsigned int stencilReference;
|
||||
};
|
||||
|
||||
#include <Nazara/Renderer/RenderStates.inl>
|
||||
|
||||
#endif // NAZARA_RENDERSTATES_HPP
|
||||
44
include/Nazara/Renderer/RenderStates.inl
Normal file
44
include/Nazara/Renderer/RenderStates.inl
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2013 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 <cstring>
|
||||
#include <Nazara/Renderer/Debug.hpp>
|
||||
|
||||
inline NzRenderStates::NzRenderStates() :
|
||||
dstBlend(nzBlendFunc_Zero),
|
||||
srcBlend(nzBlendFunc_One),
|
||||
faceCulling(nzFaceCulling_Back),
|
||||
faceFilling(nzFaceFilling_Fill),
|
||||
depthFunc(nzRendererComparison_Less),
|
||||
stencilCompare(nzRendererComparison_Always),
|
||||
stencilFail(nzStencilOperation_Keep),
|
||||
stencilPass(nzStencilOperation_Keep),
|
||||
stencilZFail(nzStencilOperation_Keep),
|
||||
stencilMask(0xFFFFFFFF),
|
||||
lineWidth(1.f),
|
||||
pointSize(1.f),
|
||||
stencilReference(0)
|
||||
{
|
||||
parameters[nzRendererParameter_Blend] = false;
|
||||
parameters[nzRendererParameter_ColorWrite] = true;
|
||||
parameters[nzRendererParameter_DepthBuffer] = false;
|
||||
parameters[nzRendererParameter_DepthWrite] = true;
|
||||
parameters[nzRendererParameter_FaceCulling] = false;
|
||||
parameters[nzRendererParameter_ScissorTest] = false;
|
||||
parameters[nzRendererParameter_StencilTest] = false;
|
||||
}
|
||||
|
||||
inline NzRenderStates::NzRenderStates(const NzRenderStates& states)
|
||||
{
|
||||
std::memcpy(this, &states, sizeof(NzRenderStates));
|
||||
}
|
||||
|
||||
inline NzRenderStates& NzRenderStates::operator=(const NzRenderStates& states)
|
||||
{
|
||||
std::memcpy(this, &states, sizeof(NzRenderStates));
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#include <Nazara/Renderer/DebugOff.hpp>
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/RenderStates.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
|
||||
@@ -53,6 +54,7 @@ class NAZARA_API NzRenderer
|
||||
static unsigned int GetMaxRenderTargets();
|
||||
static unsigned int GetMaxTextureUnits();
|
||||
static float GetPointSize();
|
||||
static const NzRenderStates& GetRenderStates();
|
||||
static NzRectui GetScissorRect();
|
||||
static const NzShader* GetShader();
|
||||
static const NzRenderTarget* GetTarget();
|
||||
@@ -65,7 +67,7 @@ class NAZARA_API NzRenderer
|
||||
static bool IsEnabled(nzRendererParameter parameter);
|
||||
static bool IsInitialized();
|
||||
|
||||
static void SetBlendFunc(nzBlendFunc srcBlend, nzBlendFunc destBlend);
|
||||
static void SetBlendFunc(nzBlendFunc srcBlend, nzBlendFunc dstBlend);
|
||||
static void SetClearColor(const NzColor& color);
|
||||
static void SetClearColor(nzUInt8 r, nzUInt8 g, nzUInt8 b, nzUInt8 a = 255);
|
||||
static void SetClearDepth(double depth);
|
||||
@@ -78,6 +80,7 @@ class NAZARA_API NzRenderer
|
||||
static void SetLineWidth(float size);
|
||||
static void SetMatrix(nzMatrixType type, const NzMatrix4f& matrix);
|
||||
static void SetPointSize(float size);
|
||||
static void SetRenderStates(const NzRenderStates& states);
|
||||
static void SetScissorRect(const NzRectui& viewport);
|
||||
static void SetShader(const NzShader* shader);
|
||||
static void SetStencilCompareFunction(nzRendererComparison compareFunc);
|
||||
|
||||
Reference in New Issue
Block a user