Improved code
Former-commit-id: 33082b8f9d55c7a3b9550c788eb27fc613c08032
This commit is contained in:
parent
a1da3395cd
commit
fbc0d7404e
|
|
@ -17,25 +17,7 @@ class NzThreadImpl;
|
|||
class NAZARA_API NzThread : NzNonCopyable
|
||||
{
|
||||
public:
|
||||
class NAZARA_API Id
|
||||
{
|
||||
friend NzThread;
|
||||
|
||||
public:
|
||||
NAZARA_API friend bool operator==(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator!=(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator<(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator<=(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator>(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator>=(const Id& lhs, const Id& rhs);
|
||||
|
||||
NAZARA_API friend bool operator<<(std::ostream& o, const Id& id);
|
||||
|
||||
private:
|
||||
Id(NzThreadImpl* thread);
|
||||
|
||||
NzThreadImpl* m_id = nullptr;
|
||||
};
|
||||
class Id;
|
||||
|
||||
NzThread();
|
||||
template<typename F> NzThread(F function);
|
||||
|
|
@ -60,6 +42,26 @@ class NAZARA_API NzThread : NzNonCopyable
|
|||
NzThreadImpl* m_impl;
|
||||
};
|
||||
|
||||
class NAZARA_API NzThread::Id
|
||||
{
|
||||
friend NzThread;
|
||||
|
||||
public:
|
||||
NAZARA_API friend bool operator==(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator!=(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator<(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator<=(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator>(const Id& lhs, const Id& rhs);
|
||||
NAZARA_API friend bool operator>=(const Id& lhs, const Id& rhs);
|
||||
|
||||
NAZARA_API friend bool operator<<(std::ostream& o, const Id& id);
|
||||
|
||||
private:
|
||||
Id(NzThreadImpl* thread);
|
||||
|
||||
NzThreadImpl* m_id = nullptr;
|
||||
};
|
||||
|
||||
#include <Nazara/Core/Thread.inl>
|
||||
|
||||
#endif // NAZARA_THREAD_HPP
|
||||
|
|
|
|||
|
|
@ -18,51 +18,6 @@
|
|||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
/*********************************NzThread::Id********************************/
|
||||
|
||||
bool operator==(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id == rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator!=(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id != rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator<(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id < rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator<=(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id <= rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator>(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id > rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator>=(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id >= rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator<<(std::ostream& o, const NzThread::Id& id)
|
||||
{
|
||||
o << id.m_id;
|
||||
return o;
|
||||
}
|
||||
|
||||
NzThread::Id::Id(NzThreadImpl* thread) :
|
||||
m_id(thread)
|
||||
{
|
||||
}
|
||||
|
||||
/***********************************NzThread**********************************/
|
||||
|
||||
NzThread::NzThread() :
|
||||
m_impl(nullptr)
|
||||
{
|
||||
|
|
@ -147,3 +102,46 @@ void NzThread::CreateImpl(NzFunctor* functor)
|
|||
{
|
||||
m_impl = new NzThreadImpl(functor);
|
||||
}
|
||||
|
||||
/*********************************NzThread::Id********************************/
|
||||
|
||||
bool operator==(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id == rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator!=(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id != rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator<(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id < rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator<=(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id <= rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator>(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id > rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator>=(const NzThread::Id& lhs, const NzThread::Id& rhs)
|
||||
{
|
||||
return lhs.m_id >= rhs.m_id;
|
||||
}
|
||||
|
||||
bool operator<<(std::ostream& o, const NzThread::Id& id)
|
||||
{
|
||||
o << id.m_id;
|
||||
return o;
|
||||
}
|
||||
|
||||
NzThread::Id::Id(NzThreadImpl* thread) :
|
||||
m_id(thread)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,6 +242,7 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
|
|||
{
|
||||
GLenum type;
|
||||
const nzUInt8* ptr = reinterpret_cast<const nzUInt8*>(s_indexBuffer->GetPointer());
|
||||
|
||||
if (s_indexBuffer->HasLargeIndices())
|
||||
{
|
||||
ptr += firstIndex*sizeof(nzUInt32);
|
||||
|
|
|
|||
|
|
@ -292,7 +292,6 @@ namespace
|
|||
sourceCode += "float intensity = light.r*0.3 + light.g*0.59 + light.b*0.11;\n"
|
||||
"vec3 emission = vec3(" + textureLookupKW + "(MaterialEmissiveMap, vTexCoord));\n"
|
||||
+ fragmentColorKW + " = vec4(mix(lighting, emission, clamp(1.0 - 3.0*intensity, 0.0, 1.0)), alpha);\n";
|
||||
///NOTE: Pour un shader avec un coût réduit avec une qualité moyenne, il est possible de remplacer "length(light)" par "dot(light, light)"
|
||||
}
|
||||
else
|
||||
sourceCode += fragmentColorKW + " = vec4(lighting, alpha);\n";
|
||||
|
|
|
|||
Loading…
Reference in New Issue