Added a static New method to RefCounted-derived classes

Former-commit-id: efd9e68e050fb6cc7e0df7a7c222ca759c502dc5
This commit is contained in:
Lynix
2015-01-25 23:41:09 +01:00
parent 5f5be93992
commit 0db92e671d
59 changed files with 532 additions and 354 deletions

View File

@@ -26,10 +26,7 @@ m_blurPassCount(5)
m_gaussianBlurShaderFilterLocation = m_gaussianBlurShader->GetUniformLocation("Filter");
for (unsigned int i = 0; i < 2; ++i)
{
m_bloomTextures[i] = new NzTexture;
m_bloomTextures[i]->SetPersistent(false);
}
m_bloomTextures[i] = NzTexture::New();
}
NzDeferredBloomPass::~NzDeferredBloomPass() = default;

View File

@@ -14,7 +14,7 @@
namespace
{
// http://digitalerr0r.wordpress.com/2009/05/16/xna-shader-programming-tutorial-20-depth-of-field/
NzShader* BuildDepthOfFieldShader()
NzShaderRef BuildDepthOfFieldShader()
{
const char* fragmentSource =
"#version 140\n"
@@ -63,9 +63,7 @@ namespace
"}\n";
///TODO: Remplacer ça par des ShaderNode
std::unique_ptr<NzShader> shader(new NzShader);
shader->SetPersistent(false);
NzShaderRef shader = NzShader::New();
if (!shader->Create())
{
NazaraError("Failed to load create shader");
@@ -90,7 +88,7 @@ namespace
return nullptr;
}
return shader.release();
return shader;
}
}
@@ -105,10 +103,7 @@ NzDeferredDOFPass::NzDeferredDOFPass()
m_gaussianBlurShaderFilterLocation = m_gaussianBlurShader->GetUniformLocation("Filter");
for (unsigned int i = 0; i < 2; ++i)
{
m_dofTextures[i] = new NzTexture;
m_dofTextures[i]->SetPersistent(false);
}
m_dofTextures[i] = NzTexture::New();
m_bilinearSampler.SetAnisotropyLevel(1);
m_bilinearSampler.SetFilterMode(nzSamplerFilter_Bilinear);

View File

@@ -12,7 +12,7 @@
namespace
{
NzShader* BuildFogShader()
NzShaderRef BuildFogShader()
{
/*const nzUInt8 fragmentSource[] = {
#include <Nazara/Graphics/Resources/DeferredShading/Shaders/FXAA.frag.h>
@@ -84,9 +84,7 @@ namespace
"}\n";
///TODO: Remplacer ça par des ShaderNode
std::unique_ptr<NzShader> shader(new NzShader);
shader->SetPersistent(false);
NzShaderRef shader = NzShader::New();
if (!shader->Create())
{
NazaraError("Failed to load create shader");
@@ -114,7 +112,7 @@ namespace
shader->SendInteger(shader->GetUniformLocation("ColorTexture"), 0);
shader->SendInteger(shader->GetUniformLocation("GBuffer2"), 1);
return shader.release();
return shader;
}
}

View File

@@ -45,13 +45,11 @@ m_lightMeshesDrawing(false)
m_pointSampler.SetFilterMode(nzSamplerFilter_Nearest);
m_pointSampler.SetWrapMode(nzSamplerWrap_Clamp);
m_cone = new NzMesh;
m_cone->SetPersistent(false);
m_cone = NzMesh::New();
m_cone->CreateStatic();
m_coneMesh = static_cast<NzStaticMesh*>(m_cone->BuildSubMesh(NzPrimitive::Cone(1.f, 1.f, 16, NzMatrix4f::Rotate(NzEulerAnglesf(90.f, 0.f, 0.f)))));
m_sphere = new NzMesh;
m_sphere->SetPersistent(false);
m_sphere = NzMesh::New();
m_sphere->CreateStatic();
m_sphereMesh = static_cast<NzStaticMesh*>(m_sphere->BuildSubMesh(NzPrimitive::IcoSphere(1.f, 1)));
}

View File

@@ -79,13 +79,11 @@ namespace
static_assert(sizeof(RenderPassPriority)/sizeof(unsigned int) == nzRenderPassType_Max+1, "Render pass priority array is incomplete");
inline NzShader* RegisterDeferredShader(const NzString& name, const nzUInt8* fragmentSource, unsigned int fragmentSourceLength, const NzShaderStage& vertexStage, NzString* err)
inline NzShaderRef RegisterDeferredShader(const NzString& name, const nzUInt8* fragmentSource, unsigned int fragmentSourceLength, const NzShaderStage& vertexStage, NzString* err)
{
NzErrorFlags errFlags(nzErrorFlag_Silent | nzErrorFlag_ThrowExceptionDisabled);
std::unique_ptr<NzShader> shader(new NzShader);
shader->SetPersistent(false);
NzShaderRef shader = NzShader::New();
if (!shader->Create())
{
err->Set("Failed to create shader: " + NzError::GetLastError());
@@ -106,8 +104,8 @@ namespace
return nullptr;
}
NzShaderLibrary::Register(name, shader.get());
return shader.release();
NzShaderLibrary::Register(name, shader);
return shader;
}
}
@@ -115,20 +113,13 @@ NzDeferredRenderTechnique::NzDeferredRenderTechnique() :
m_renderQueue(static_cast<NzForwardRenderQueue*>(m_forwardTechnique.GetRenderQueue())),
m_GBufferSize(0U)
{
m_depthStencilBuffer = new NzRenderBuffer;
m_depthStencilBuffer->SetPersistent(false);
m_depthStencilBuffer = NzRenderBuffer::New();
for (unsigned int i = 0; i < 2; ++i)
{
m_workTextures[i] = new NzTexture;
m_workTextures[i]->SetPersistent(false);
}
m_workTextures[i] = NzTexture::New();
for (unsigned int i = 0; i < 3; ++i)
{
m_GBuffer[i] = new NzTexture;
m_GBuffer[i]->SetPersistent(false);
}
m_GBuffer[i] = NzTexture::New();
try
{

View File

@@ -24,8 +24,7 @@ namespace
{
NazaraUnused(parameters);
std::unique_ptr<NzMesh> mesh(new NzMesh);
mesh->SetPersistent(false);
NzMeshRef mesh = NzMesh::New();
if (!mesh->LoadFromStream(stream, parameters.mesh))
{
NazaraError("Failed to load model mesh");
@@ -38,12 +37,8 @@ namespace
return false;
}
// Nous ne pouvons plus avoir recours au smart pointeur à partir d'ici si nous voulons être exception-safe
NzMesh* meshPtr = mesh.get();
model->Reset();
model->SetMesh(meshPtr);
mesh.release();
model->SetMesh(mesh);
if (parameters.loadMaterials)
{
@@ -51,17 +46,12 @@ namespace
for (unsigned int i = 0; i < matCount; ++i)
{
NzString mat = meshPtr->GetMaterial(i);
NzString mat = mesh->GetMaterial(i);
if (!mat.IsEmpty())
{
std::unique_ptr<NzMaterial> material(new NzMaterial);
material->SetPersistent(false);
NzMaterialRef material = NzMaterial::New();
if (material->LoadFromFile(mat, parameters.material))
{
model->SetMaterial(i, material.get());
material.release();
}
model->SetMaterial(i, material);
else
NazaraWarning("Failed to load material #" + NzString::Number(i));
}
@@ -83,8 +73,7 @@ namespace
{
NazaraUnused(parameters);
std::unique_ptr<NzMesh> mesh(new NzMesh);
mesh->SetPersistent(false);
NzMeshRef mesh = NzMesh::New();
if (!mesh->LoadFromStream(stream, parameters.mesh))
{
NazaraError("Failed to load model mesh");
@@ -97,13 +86,8 @@ namespace
return false;
}
// Nous ne pouvons plus avoir recours au smart pointeur à partir d'ici si nous voulons être exception-safe
NzMesh* meshPtr = mesh.get();
model->Reset();
model->SetMesh(meshPtr);
mesh.release();
model->SetMesh(mesh);
if (parameters.loadMaterials)
{
@@ -111,17 +95,12 @@ namespace
for (unsigned int i = 0; i < matCount; ++i)
{
NzString mat = meshPtr->GetMaterial(i);
NzString mat = mesh->GetMaterial(i);
if (!mat.IsEmpty())
{
std::unique_ptr<NzMaterial> material(new NzMaterial);
material->SetPersistent(false);
NzMaterialRef material = NzMaterial::New();
if (material->LoadFromFile(mat, parameters.material))
{
model->SetMaterial(i, material.get());
material.release();
}
model->SetMaterial(i, material);
else
NazaraWarning("Failed to load material #" + NzString::Number(i));
}

View File

@@ -41,8 +41,7 @@ namespace
return false;
}
std::unique_ptr<NzMesh> mesh(new NzMesh);
mesh->SetPersistent(false);
NzMeshRef mesh = NzMesh::New();
if (!mesh->CreateStatic()) // Ne devrait jamais échouer
{
NazaraInternalError("Failed to create mesh");
@@ -100,14 +99,11 @@ namespace
}
// Création des buffers
std::unique_ptr<NzIndexBuffer> indexBuffer(new NzIndexBuffer(vertexCount > std::numeric_limits<nzUInt16>::max(), indices.size(), parameters.mesh.storage, nzBufferUsage_Static));
indexBuffer->SetPersistent(false);
std::unique_ptr<NzVertexBuffer> vertexBuffer(new NzVertexBuffer(NzVertexDeclaration::Get(nzVertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.mesh.storage, nzBufferUsage_Static));
vertexBuffer->SetPersistent(false);
NzIndexBufferRef indexBuffer = NzIndexBuffer::New(vertexCount > std::numeric_limits<nzUInt16>::max(), indices.size(), parameters.mesh.storage, nzBufferUsage_Static);
NzVertexBufferRef vertexBuffer = NzVertexBuffer::New(NzVertexDeclaration::Get(nzVertexLayout_XYZ_Normal_UV_Tangent), vertexCount, parameters.mesh.storage, nzBufferUsage_Static);
// Remplissage des indices
NzIndexMapper indexMapper(indexBuffer.get(), nzBufferAccess_WriteOnly);
NzIndexMapper indexMapper(indexBuffer, nzBufferAccess_WriteOnly);
for (unsigned int j = 0; j < indices.size(); ++j)
indexMapper.Set(j, indices[j]);
@@ -116,7 +112,7 @@ namespace
// Remplissage des vertices
bool hasNormals = true;
bool hasTexCoords = true;
NzBufferMapper<NzVertexBuffer> vertexMapper(vertexBuffer.get(), nzBufferAccess_WriteOnly);
NzBufferMapper<NzVertexBuffer> vertexMapper(vertexBuffer, nzBufferAccess_WriteOnly);
NzMeshVertex* meshVertices = static_cast<NzMeshVertex*>(vertexMapper.GetPointer());
for (auto& uvIt : vertices)
{
@@ -152,21 +148,18 @@ namespace
vertexMapper.Unmap();
std::unique_ptr<NzStaticMesh> subMesh(new NzStaticMesh(mesh.get()));
if (!subMesh->Create(vertexBuffer.get()))
NzStaticMeshRef subMesh = NzStaticMesh::New(mesh);
if (!subMesh->Create(vertexBuffer))
{
NazaraError("Failed to create StaticMesh");
continue;
}
vertexBuffer.release();
if (parameters.mesh.optimizeIndexBuffers)
indexBuffer->Optimize();
subMesh->SetIndexBuffer(indexBuffer.get());
indexBuffer.release();
subMesh->GenerateAABB();
subMesh->SetIndexBuffer(indexBuffer);
subMesh->SetMaterialIndex(meshes[i].material);
subMesh->SetPrimitiveMode(nzPrimitiveMode_TriangleList);
@@ -178,8 +171,7 @@ namespace
else
subMesh->GenerateNormals();
mesh->AddSubMesh(meshes[i].name + '_' + materials[meshes[i].material], subMesh.get());
subMesh.release();
mesh->AddSubMesh(meshes[i].name + '_' + materials[meshes[i].material], subMesh);
}
if (parameters.mesh.center)
@@ -196,8 +188,7 @@ namespace
mesh->SetMaterialCount(parser.GetMaterialCount());
model->SetMesh(mesh.get());
mesh.release();
model->SetMesh(mesh);
// On charge les matériaux si demandé
NzString mtlLib = parser.GetMtlLib();
@@ -209,7 +200,7 @@ namespace
NzMTLParser materialParser(file);
if (materialParser.Parse())
{
std::unordered_map<NzString, NzMaterial*> materialCache;
std::unordered_map<NzString, NzMaterialRef> materialCache;
NzString baseDir = file.GetDirectory();
for (unsigned int i = 0; i < meshCount; ++i)
{
@@ -222,9 +213,7 @@ namespace
model->SetMaterial(meshes[i].material, it->second);
else
{
std::unique_ptr<NzMaterial> material(new NzMaterial);
material->SetPersistent(false);
NzMaterialRef material = NzMaterial::New();
material->SetShader(parameters.material.shaderName);
nzUInt8 alphaValue = static_cast<nzUInt8>(mtlMat->alpha*255.f);
@@ -246,15 +235,11 @@ namespace
bool hasAlphaMap = false;;
if (parameters.material.loadAlphaMap && !mtlMat->alphaMap.IsEmpty())
{
std::unique_ptr<NzTexture> alphaMap(new NzTexture);
alphaMap->SetPersistent(false);
NzTextureRef alphaMap = NzTexture::New();
if (alphaMap->LoadFromFile(baseDir + mtlMat->alphaMap))
{
hasAlphaMap = true;
material->SetAlphaMap(alphaMap.get());
alphaMap.release();
material->SetAlphaMap(alphaMap);
}
else
NazaraWarning("Failed to load alpha map (" + mtlMat->alphaMap + ')');
@@ -262,28 +247,18 @@ namespace
if (parameters.material.loadDiffuseMap && !mtlMat->diffuseMap.IsEmpty())
{
std::unique_ptr<NzTexture> diffuseMap(new NzTexture);
diffuseMap->SetPersistent(false);
NzTextureRef diffuseMap = NzTexture::New();
if (diffuseMap->LoadFromFile(baseDir + mtlMat->diffuseMap))
{
material->SetDiffuseMap(diffuseMap.get());
diffuseMap.release();
}
material->SetDiffuseMap(diffuseMap);
else
NazaraWarning("Failed to load diffuse map (" + mtlMat->diffuseMap + ')');
}
if (parameters.material.loadSpecularMap && !mtlMat->specularMap.IsEmpty())
{
std::unique_ptr<NzTexture> specularMap(new NzTexture);
specularMap->SetPersistent(false);
NzTextureRef specularMap = NzTexture::New();
if (specularMap->LoadFromFile(baseDir + mtlMat->specularMap))
{
material->SetSpecularMap(specularMap.get());
specularMap.release();
}
material->SetSpecularMap(specularMap);
else
NazaraWarning("Failed to load specular map (" + mtlMat->specularMap + ')');
}
@@ -299,10 +274,9 @@ namespace
material->SetSrcBlend(nzBlendFunc_SrcAlpha);
}
materialCache[matName] = material.get();
materialCache[matName] = material;
model->SetMaterial(meshes[i].material, material.get());
material.release();
model->SetMaterial(meshes[i].material, material);
}
}
else

View File

@@ -22,9 +22,7 @@ namespace
{
NazaraUnused(parameters);
std::unique_ptr<NzTexture> texture(new NzTexture);
texture->SetPersistent(false);
NzTextureRef texture = NzTexture::New();
if (!texture->LoadFromStream(stream))
{
NazaraError("Failed to load diffuse map");
@@ -32,9 +30,7 @@ namespace
}
material->Reset();
material->SetDiffuseMap(texture.get());
texture.release();
material->SetDiffuseMap(texture);
material->SetShader(parameters.shaderName);
return true;

View File

@@ -409,18 +409,14 @@ void NzMaterial::Reset()
bool NzMaterial::SetAlphaMap(const NzString& texturePath)
{
std::unique_ptr<NzTexture> texture(new NzTexture);
NzTextureRef texture = NzTexture::New();
if (!texture->LoadFromFile(texturePath))
{
NazaraError("Failed to load texture from \"" + texturePath + '"');
return false;
}
texture->SetPersistent(false);
SetAlphaMap(texture.get());
texture.release();
SetAlphaMap(texture);
return true;
}
@@ -453,18 +449,14 @@ void NzMaterial::SetDiffuseColor(const NzColor& diffuse)
bool NzMaterial::SetDiffuseMap(const NzString& texturePath)
{
std::unique_ptr<NzTexture> texture(new NzTexture);
NzTextureRef texture = NzTexture::New();
if (!texture->LoadFromFile(texturePath))
{
NazaraError("Failed to load texture from \"" + texturePath + '"');
return false;
}
texture->SetPersistent(false);
SetDiffuseMap(texture.get());
texture.release();
SetDiffuseMap(texture);
return true;
}
@@ -487,18 +479,14 @@ void NzMaterial::SetDstBlend(nzBlendFunc func)
bool NzMaterial::SetEmissiveMap(const NzString& texturePath)
{
std::unique_ptr<NzTexture> texture(new NzTexture);
NzTextureRef texture = NzTexture::New();
if (!texture->LoadFromFile(texturePath))
{
NazaraError("Failed to load texture from \"" + texturePath + '"');
return false;
}
texture->SetPersistent(false);
SetEmissiveMap(texture.get());
texture.release();
SetEmissiveMap(texture);
return true;
}
@@ -521,18 +509,14 @@ void NzMaterial::SetFaceFilling(nzFaceFilling filling)
bool NzMaterial::SetHeightMap(const NzString& texturePath)
{
std::unique_ptr<NzTexture> texture(new NzTexture);
NzTextureRef texture = NzTexture::New();
if (!texture->LoadFromFile(texturePath))
{
NazaraError("Failed to load texture from \"" + texturePath + '"');
return false;
}
texture->SetPersistent(false);
SetHeightMap(texture.get());
texture.release();
SetHeightMap(texture);
return true;
}
@@ -545,18 +529,14 @@ void NzMaterial::SetHeightMap(NzTexture* map)
bool NzMaterial::SetNormalMap(const NzString& texturePath)
{
std::unique_ptr<NzTexture> texture(new NzTexture);
NzTextureRef texture = NzTexture::New();
if (!texture->LoadFromFile(texturePath))
{
NazaraError("Failed to load texture from \"" + texturePath + '"');
return false;
}
texture->SetPersistent(false);
SetNormalMap(texture.get());
texture.release();
SetNormalMap(texture);
return true;
}
@@ -601,18 +581,14 @@ void NzMaterial::SetSpecularColor(const NzColor& specular)
bool NzMaterial::SetSpecularMap(const NzString& texturePath)
{
std::unique_ptr<NzTexture> texture(new NzTexture);
NzTextureRef texture = NzTexture::New();
if (!texture->LoadFromFile(texturePath))
{
NazaraError("Failed to load texture from \"" + texturePath + '"');
return false;
}
texture->SetPersistent(false);
SetSpecularMap(texture.get());
texture.release();
SetSpecularMap(texture);
return true;
}
@@ -734,8 +710,7 @@ bool NzMaterial::Initialize()
// Basic shader
{
std::unique_ptr<NzUberShaderPreprocessor> uberShader(new NzUberShaderPreprocessor);
uberShader->SetPersistent(false);
NzUberShaderPreprocessorRef uberShader = NzUberShaderPreprocessor::New();
NzString fragmentShader;
NzString vertexShader;
@@ -753,14 +728,12 @@ bool NzMaterial::Initialize()
uberShader->SetShader(nzShaderStage_Fragment, fragmentShader, "FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING");
uberShader->SetShader(nzShaderStage_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_INSTANCING FLAG_VERTEXCOLOR TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH");
NzUberShaderLibrary::Register("Basic", uberShader.get());
uberShader.release();
NzUberShaderLibrary::Register("Basic", uberShader);
}
// PhongLighting shader
{
std::unique_ptr<NzUberShaderPreprocessor> uberShader(new NzUberShaderPreprocessor);
uberShader->SetPersistent(false);
NzUberShaderPreprocessorRef uberShader = NzUberShaderPreprocessor::New();
NzString fragmentShader;
NzString vertexShader;
@@ -794,13 +767,10 @@ bool NzMaterial::Initialize()
uberShader->SetShader(nzShaderStage_Fragment, fragmentShader, "FLAG_DEFERRED FLAG_TEXTUREOVERLAY ALPHA_MAPPING ALPHA_TEST AUTO_TEXCOORDS DIFFUSE_MAPPING EMISSIVE_MAPPING LIGHTING NORMAL_MAPPING PARALLAX_MAPPING SPECULAR_MAPPING");
uberShader->SetShader(nzShaderStage_Vertex, vertexShader, "FLAG_BILLBOARD FLAG_DEFERRED FLAG_INSTANCING FLAG_VERTEXCOLOR COMPUTE_TBNMATRIX LIGHTING PARALLAX_MAPPING TEXTURE_MAPPING TRANSFORM UNIFORM_VERTEX_DEPTH");
NzUberShaderLibrary::Register("PhongLighting", uberShader.get());
uberShader.release();
NzUberShaderLibrary::Register("PhongLighting", uberShader);
}
s_defaultMaterial = new NzMaterial;
s_defaultMaterial->SetPersistent(true);
s_defaultMaterial = NzMaterial::New();
s_defaultMaterial->Enable(nzRendererParameter_FaceCulling, false);
s_defaultMaterial->SetFaceFilling(nzFaceFilling_Line);
@@ -809,12 +779,10 @@ bool NzMaterial::Initialize()
void NzMaterial::Uninitialize()
{
s_defaultMaterial.Reset();
NzUberShaderLibrary::Unregister("PhongLighting");
NzUberShaderLibrary::Unregister("Basic");
s_defaultMaterial->SetPersistent(false, true);
s_defaultMaterial = nullptr;
}
NzMaterial* NzMaterial::s_defaultMaterial = nullptr;
NzMaterialRef NzMaterial::s_defaultMaterial = nullptr;
NzMaterialLoader::LoaderList NzMaterial::s_loaders;

View File

@@ -172,16 +172,14 @@ NzVertexBuffer* NzSkinningManager::GetBuffer(const NzSkeletalMesh* mesh, const N
MeshMap::iterator it2 = meshMap.find(mesh);
if (it2 == meshMap.end())
{
std::unique_ptr<NzVertexBuffer> vertexBuffer(new NzVertexBuffer);
vertexBuffer->SetPersistent(false);
vertexBuffer->Reset(NzVertexDeclaration::Get(nzVertexLayout_XYZ_Normal_UV_Tangent), mesh->GetVertexCount(), nzDataStorage_Hardware, nzBufferUsage_Dynamic);
NzVertexBufferRef vertexBuffer = NzVertexBuffer::New(NzVertexDeclaration::Get(nzVertexLayout_XYZ_Normal_UV_Tangent), mesh->GetVertexCount(), nzDataStorage_Hardware, nzBufferUsage_Dynamic);
BufferData data({vertexBuffer.get(), true});
BufferData data({vertexBuffer, true});
meshMap.insert(std::make_pair(mesh, std::make_pair(NzSkeletalMeshConstListener(&listener, ObjectType_SkeletalMesh, mesh), data)));
s_skinningQueue.push_back(SkinningData{mesh, skeleton, vertexBuffer.get()});
s_skinningQueue.push_back(SkinningData{mesh, skeleton, vertexBuffer});
buffer = vertexBuffer.release();
buffer = vertexBuffer;
}
else
{

View File

@@ -96,14 +96,11 @@ void NzSprite::SetColor(const NzColor& color)
void NzSprite::SetDefaultMaterial()
{
std::unique_ptr<NzMaterial> material(new NzMaterial);
NzMaterialRef material = NzMaterial::New();
material->Enable(nzRendererParameter_FaceCulling, false);
material->EnableLighting(false);
SetMaterial(material.get());
material->SetPersistent(false);
material.release();
SetMaterial(material);
}
void NzSprite::SetMaterial(NzMaterial* material, bool resizeSprite)
@@ -137,10 +134,7 @@ void NzSprite::SetTexture(NzTexture* texture, bool resizeSprite)
if (!m_material)
SetDefaultMaterial();
else if (m_material->GetReferenceCount() > 1)
{
m_material = new NzMaterial(*m_material);
m_material->SetPersistent(false);
}
m_material = NzMaterial::New(*m_material); // Copie
m_material->SetDiffuseMap(texture);
if (resizeSprite && texture && texture->IsValid())

View File

@@ -108,7 +108,7 @@ void NzTextSprite::SetColor(const NzColor& color)
void NzTextSprite::SetDefaultMaterial()
{
std::unique_ptr<NzMaterial> material(new NzMaterial);
NzMaterialRef material = NzMaterial::New();
material->Enable(nzRendererParameter_Blend, true);
material->Enable(nzRendererParameter_DepthWrite, false);
material->Enable(nzRendererParameter_FaceCulling, false);
@@ -116,10 +116,7 @@ void NzTextSprite::SetDefaultMaterial()
material->SetDstBlend(nzBlendFunc_InvSrcAlpha);
material->SetSrcBlend(nzBlendFunc_SrcAlpha);
SetMaterial(material.get());
material->SetPersistent(false);
material.release();
SetMaterial(material);
}
void NzTextSprite::SetMaterial(NzMaterial* material)