Added texture samplers
I hate Git branchs Former-commit-id: 6978f1489cdc841d36fbcd6f1a8e01a4adbfcb8a
This commit is contained in:
@@ -117,6 +117,32 @@ enum nzRendererParameter
|
||||
nzRendererParameter_Max = nzRendererParameter_Stencil
|
||||
};
|
||||
|
||||
enum nzSamplerFilter
|
||||
{
|
||||
nzSamplerFilter_Unknown = -1,
|
||||
|
||||
nzSamplerFilter_Bilinear,
|
||||
nzSamplerFilter_Nearest,
|
||||
nzSamplerFilter_Trilinear,
|
||||
|
||||
nzSamplerFilter_Default,
|
||||
|
||||
nzSamplerFilter_Max = nzSamplerFilter_Default
|
||||
};
|
||||
|
||||
enum nzSamplerWrap
|
||||
{
|
||||
nzSamplerWrap_Unknown = -1,
|
||||
|
||||
nzSamplerWrap_Clamp,
|
||||
nzSamplerWrap_MirroredRepeat,
|
||||
nzSamplerWrap_Repeat,
|
||||
|
||||
nzSamplerWrap_Default,
|
||||
|
||||
nzSamplerWrap_Max = nzSamplerWrap_Repeat
|
||||
};
|
||||
|
||||
enum nzShaderLanguage
|
||||
{
|
||||
nzShaderLanguage_Unknown = -1,
|
||||
@@ -150,27 +176,4 @@ enum nzStencilOperation
|
||||
nzStencilOperation_Max = nzStencilOperation_Zero
|
||||
};
|
||||
|
||||
enum nzTextureFilter
|
||||
{
|
||||
nzTextureFilter_Unknown = -1,
|
||||
|
||||
nzTextureFilter_Bilinear,
|
||||
nzTextureFilter_Nearest,
|
||||
nzTextureFilter_Trilinear,
|
||||
|
||||
nzTextureFilter_Default,
|
||||
|
||||
nzTextureFilter_Max = nzTextureFilter_Default
|
||||
};
|
||||
|
||||
enum nzTextureWrap
|
||||
{
|
||||
nzTextureWrap_Unknown = -1,
|
||||
|
||||
nzTextureWrap_Clamp,
|
||||
nzTextureWrap_Repeat,
|
||||
|
||||
nzTextureWrap_Max = nzTextureWrap_Repeat
|
||||
};
|
||||
|
||||
#endif // NAZARA_ENUMS_RENDERER_HPP
|
||||
|
||||
@@ -43,11 +43,12 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
nzBlendFunc GetDstBlend() const;
|
||||
nzFaceCulling GetFaceCulling() const;
|
||||
nzFaceFilling GetFaceFilling() const;
|
||||
nzSamplerFilter GetSamplerFilter() const;
|
||||
nzSamplerWrap GetSamplerWrap() const;
|
||||
float GetShininess() const;
|
||||
NzColor GetSpecularColor() const;
|
||||
const NzTexture* GetSpecularMap() const;
|
||||
nzBlendFunc GetSrcBlend() const;
|
||||
nzTextureFilter GetTextureFilter() const;
|
||||
nzRendererComparison GetZTestCompare() const;
|
||||
|
||||
bool IsAlphaBlendingEnabled() const;
|
||||
@@ -66,12 +67,12 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
void SetDstBlend(nzBlendFunc func);
|
||||
void SetFaceCulling(nzFaceCulling culling);
|
||||
void SetFaceFilling(nzFaceFilling filling);
|
||||
void SetSamplerFilter(nzSamplerFilter filter);
|
||||
void SetSamplerWrap(nzSamplerWrap wrapMode);
|
||||
void SetShininess(float shininess);
|
||||
void SetSpecularColor(const NzColor& specular);
|
||||
void SetSpecularMap(const NzTexture* map);
|
||||
void SetSrcBlend(nzBlendFunc func);
|
||||
void SetTextureFilter(nzTextureFilter filter);
|
||||
void SetTextureWrap(nzTextureWrap wrapMode);
|
||||
void SetZTestCompare(nzRendererComparison compareFunc);
|
||||
|
||||
static const NzMaterial* GetDefault();
|
||||
@@ -82,8 +83,8 @@ class NAZARA_API NzMaterial : public NzResource
|
||||
nzFaceCulling m_faceCulling;
|
||||
nzFaceFilling m_faceFilling;
|
||||
nzRendererComparison m_zTestCompareFunc;
|
||||
nzTextureFilter m_textureFilter;
|
||||
nzTextureWrap m_textureWrap;
|
||||
nzSamplerFilter m_samplerFilter;
|
||||
nzSamplerWrap m_samplerWrap;
|
||||
NzColor m_ambientColor;
|
||||
NzColor m_diffuseColor;
|
||||
NzColor m_specularColor;
|
||||
|
||||
@@ -86,12 +86,12 @@ class NAZARA_API NzOpenGL
|
||||
static GLenum PrimitiveType[nzPrimitiveType_Max+1];
|
||||
static GLenum RendererComparison[nzRendererComparison_Max+1];
|
||||
static GLenum RendererParameter[nzRendererParameter_Max+1];
|
||||
static GLenum SamplerWrapMode[nzSamplerWrap_Max+1];
|
||||
static GLenum ShaderType[nzShaderType_Max+1];
|
||||
static GLenum StencilOperation[nzStencilOperation_Max+1];
|
||||
static GLenum TextureTarget[nzImageType_Max+1];
|
||||
static GLenum TextureTargetBinding[nzImageType_Max+1];
|
||||
static GLenum TextureTargetProxy[nzImageType_Max+1];
|
||||
static GLenum TextureWrapMode[nzTextureWrap_Max+1];
|
||||
};
|
||||
|
||||
NAZARA_API extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include <Nazara/Math/Matrix4.hpp>
|
||||
#include <Nazara/Math/Rect.hpp>
|
||||
#include <Nazara/Renderer/Enums.hpp>
|
||||
#include <Nazara/Renderer/TextureSampler.hpp>
|
||||
#include <Nazara/Utility/Enums.hpp>
|
||||
#include <map>
|
||||
|
||||
class NzColor;
|
||||
class NzContext;
|
||||
@@ -42,7 +42,7 @@ class NAZARA_API NzRenderer
|
||||
static float GetLineWidth();
|
||||
//static NzMatrix4f GetMatrix(nzMatrixCombination combination);
|
||||
static NzMatrix4f GetMatrix(nzMatrixType type);
|
||||
static unsigned int GetMaxAnisotropyLevel();
|
||||
static nzUInt8 GetMaxAnisotropyLevel();
|
||||
static unsigned int GetMaxRenderTargets();
|
||||
static unsigned int GetMaxTextureUnits();
|
||||
static float GetPointSize();
|
||||
@@ -77,6 +77,8 @@ class NAZARA_API NzRenderer
|
||||
static void SetStencilReferenceValue(unsigned int refValue);
|
||||
static void SetStencilZFailOperation(nzStencilOperation zfailOperation);
|
||||
static bool SetTarget(NzRenderTarget* target);
|
||||
static void SetTexture(unsigned int unit, const NzTexture* texture);
|
||||
static void SetTextureSampling(unsigned int unit, const NzTextureSampler& sampler);
|
||||
static bool SetVertexBuffer(const NzVertexBuffer* vertexBuffer);
|
||||
static void SetViewport(const NzRectui& viewport);
|
||||
|
||||
|
||||
@@ -33,15 +33,13 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||
|
||||
bool EnableMipmapping(bool enable);
|
||||
|
||||
unsigned int GetAnisotropyLevel() const;
|
||||
nzUInt8 GetBytesPerPixel() const;
|
||||
unsigned int GetDepth() const;
|
||||
nzTextureFilter GetFilterMode() const;
|
||||
nzSamplerFilter GetFilterMode() const;
|
||||
nzPixelFormat GetFormat() const;
|
||||
unsigned int GetHeight() const;
|
||||
nzImageType GetType() const;
|
||||
unsigned int GetWidth() const;
|
||||
nzTextureWrap GetWrapMode() const;
|
||||
|
||||
bool HasMipmaps() const;
|
||||
|
||||
@@ -50,17 +48,14 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||
bool IsTarget() const;
|
||||
bool IsValid() const;
|
||||
|
||||
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFromImage(const NzImage& image);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams());
|
||||
bool LoadFromFile(const NzString& filePath, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromImage(const NzImage& image, bool generateMipmaps = true);
|
||||
bool LoadFromMemory(const void* data, std::size_t size, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
bool LoadFromStream(NzInputStream& stream, const NzImageParams& params = NzImageParams(), bool generateMipmaps = true);
|
||||
|
||||
bool Lock();
|
||||
|
||||
bool SetAnisotropyLevel(unsigned int anistropyLevel);
|
||||
bool SetFilterMode(nzTextureFilter filter);
|
||||
bool SetMipmapRange(nzUInt8 minLevel, nzUInt8 maxLevel);
|
||||
bool SetWrapMode(nzTextureWrap wrap);
|
||||
|
||||
bool Update(const NzImage& image, nzUInt8 level = 0);
|
||||
bool Update(const NzImage& image, const NzRectui& rect, unsigned int z = 0, nzUInt8 level = 0);
|
||||
@@ -76,8 +71,8 @@ class NAZARA_API NzTexture : public NzResource, NzNonCopyable
|
||||
void Unlock();
|
||||
|
||||
// Fonctions OpenGL
|
||||
bool Bind() const;
|
||||
unsigned int GetOpenGLID() const;
|
||||
bool Prepare() const;
|
||||
|
||||
static unsigned int GetValidSize(unsigned int size);
|
||||
static bool IsFormatSupported(nzPixelFormat format);
|
||||
|
||||
60
include/Nazara/Renderer/TextureSampler.hpp
Normal file
60
include/Nazara/Renderer/TextureSampler.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2012 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/Enums.hpp>
|
||||
|
||||
class NzTexture;
|
||||
|
||||
class NAZARA_API NzTextureSampler
|
||||
{
|
||||
friend class NzRenderer;
|
||||
|
||||
public:
|
||||
NzTextureSampler();
|
||||
NzTextureSampler(const NzTextureSampler& sampler) = default;
|
||||
|
||||
nzUInt8 GetAnisotropicLevel() const;
|
||||
nzSamplerFilter GetFilterMode() const;
|
||||
nzSamplerWrap GetWrapMode() const;
|
||||
|
||||
void SetAnisotropyLevel(nzUInt8 anisotropyLevel);
|
||||
void SetFilterMode(nzSamplerFilter filterMode);
|
||||
void SetWrapMode(nzSamplerWrap wrapMode);
|
||||
|
||||
NzTextureSampler& operator=(const NzTextureSampler& sampler) = default;
|
||||
|
||||
static nzUInt8 GetDefaultAnisotropicLevel();
|
||||
static nzSamplerFilter GetDefaultFilterMode();
|
||||
static nzSamplerWrap GetDefaultWrapMode();
|
||||
|
||||
static void SetDefaultAnisotropyLevel(nzUInt8 anisotropyLevel);
|
||||
static void SetDefaultFilterMode(nzSamplerFilter filterMode);
|
||||
static void SetDefaultWrapMode(nzSamplerWrap wrapMode);
|
||||
|
||||
private:
|
||||
void Apply(const NzTexture* texture);
|
||||
void Bind(unsigned int unit);
|
||||
bool UseMipmaps(bool mipmaps);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
nzSamplerFilter m_filterMode;
|
||||
nzSamplerWrap m_wrapMode;
|
||||
nzUInt8 m_anisotropicLevel;
|
||||
bool m_mipmaps;
|
||||
mutable unsigned int m_samplerId;
|
||||
|
||||
static nzSamplerFilter s_defaultFilterMode;
|
||||
static nzSamplerWrap s_defaultWrapMode;
|
||||
static nzUInt8 s_defaultAnisotropyLevel;
|
||||
};
|
||||
|
||||
#endif // NAZARA_TEXTURESAMPLER_HPP
|
||||
Reference in New Issue
Block a user