Renamed PrimitiveType to PrimitiveMode
Also renamed RENDERER_INSTANCING_MAX to RENDERER_MAX_INSTANCES Added RENDERER_SHADER_MAX_LIGHTCOUNT Former-commit-id: bc26e087dd1b55c424836e6e2fa6e1dc0f17effa
This commit is contained in:
parent
50e8ce3658
commit
cf6e2be0b0
|
|
@ -30,7 +30,7 @@
|
|||
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci
|
||||
|
||||
// Le nombre maximum d'instances pouvant être géré par le Renderer
|
||||
#define NAZARA_RENDERER_INSTANCING_MAX 8192
|
||||
#define NAZARA_RENDERER_MAX_INSTANCES 8192
|
||||
|
||||
// Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
|
||||
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0
|
||||
|
|
@ -41,4 +41,7 @@
|
|||
// Active les tests de sécurité basés sur le code (Conseillé pour le développement)
|
||||
#define NAZARA_RENDERER_SAFE 1
|
||||
|
||||
// Le nombre maximum de lumières qu'un forward shader supportera
|
||||
#define NAZARA_RENDERER_SHADER_MAX_LIGHTCOUNT 8
|
||||
|
||||
#endif // NAZARA_CONFIG_MODULENAME_HPP
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class NAZARA_API NzOpenGL
|
|||
static GLenum ElementType[nzElementType_Max+1];
|
||||
static GLenum FaceCulling[nzFaceCulling_Max+1];
|
||||
static GLenum FaceFilling[nzFaceFilling_Max+1];
|
||||
static GLenum PrimitiveType[nzPrimitiveType_Max+1];
|
||||
static GLenum PrimitiveMode[nzPrimitiveMode_Max+1];
|
||||
static GLenum RendererComparison[nzRendererComparison_Max+1];
|
||||
static GLenum RendererParameter[nzRendererParameter_Max+1];
|
||||
static GLenum SamplerWrapMode[nzSamplerWrap_Max+1];
|
||||
|
|
|
|||
|
|
@ -36,10 +36,10 @@ class NAZARA_API NzRenderer
|
|||
|
||||
static void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth);
|
||||
|
||||
static void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount);
|
||||
static void DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount);
|
||||
static void DrawIndexedPrimitives(nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
|
||||
static void DrawPrimitives(nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
|
||||
static void DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
|
||||
NAZARA_DEPRECATED("Don't use this or you will have cancer") static void DrawTexture(unsigned int unit, const NzRectf& rect, const NzVector2f& uv0, const NzVector2f& uv1, float z = 0.f);
|
||||
|
||||
static void Enable(nzRendererParameter parameter, bool enable);
|
||||
|
|
|
|||
|
|
@ -205,16 +205,16 @@ enum nzPixelFlipping
|
|||
nzPixelFlipping_Max = nzPixelFlipping_Vertically
|
||||
};
|
||||
|
||||
enum nzPrimitiveType
|
||||
enum nzPrimitiveMode
|
||||
{
|
||||
nzPrimitiveType_LineList,
|
||||
nzPrimitiveType_LineStrip,
|
||||
nzPrimitiveType_PointList,
|
||||
nzPrimitiveType_TriangleList,
|
||||
nzPrimitiveType_TriangleStrip,
|
||||
nzPrimitiveType_TriangleFan,
|
||||
nzPrimitiveMode_LineList,
|
||||
nzPrimitiveMode_LineStrip,
|
||||
nzPrimitiveMode_PointList,
|
||||
nzPrimitiveMode_TriangleList,
|
||||
nzPrimitiveMode_TriangleStrip,
|
||||
nzPrimitiveMode_TriangleFan,
|
||||
|
||||
nzPrimitiveType_Max = nzPrimitiveType_TriangleFan
|
||||
nzPrimitiveMode_Max = nzPrimitiveMode_TriangleFan
|
||||
};
|
||||
|
||||
enum nzWindowCursor
|
||||
|
|
|
|||
|
|
@ -39,17 +39,17 @@ class NAZARA_API NzSubMesh : public NzResource
|
|||
virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
|
||||
unsigned int GetMaterialIndex() const;
|
||||
const NzMesh* GetParent() const;
|
||||
nzPrimitiveType GetPrimitiveType() const;
|
||||
nzPrimitiveMode GetPrimitiveMode() const;
|
||||
unsigned int GetTriangleCount() const;
|
||||
virtual unsigned int GetVertexCount() const = 0;
|
||||
|
||||
virtual bool IsAnimated() const = 0;
|
||||
|
||||
void SetMaterialIndex(unsigned int matIndex);
|
||||
void SetPrimitiveType(nzPrimitiveType primitiveType);
|
||||
void SetPrimitiveMode(nzPrimitiveMode mode);
|
||||
|
||||
protected:
|
||||
nzPrimitiveType m_primitiveType;
|
||||
nzPrimitiveMode m_primitiveMode;
|
||||
const NzMesh* m_parent;
|
||||
unsigned int m_matIndex;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class NAZARA_API NzTriangleIterator
|
|||
void Unmap();
|
||||
|
||||
private:
|
||||
nzPrimitiveType m_primitiveType;
|
||||
nzPrimitiveMode m_primitiveMode;
|
||||
nzUInt32 m_triangleIndices[3];
|
||||
NzIndexMapper m_indexMapper;
|
||||
NzVertexMapper m_vertexMapper;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ namespace
|
|||
|
||||
subMesh->GenerateAABB();
|
||||
subMesh->SetMaterialIndex(meshes[i].material);
|
||||
subMesh->SetPrimitiveType(nzPrimitiveType_TriangleList);
|
||||
subMesh->SetPrimitiveMode(nzPrimitiveMode_TriangleList);
|
||||
|
||||
if (hasNormals && hasTexCoords)
|
||||
subMesh->GenerateTangents();
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ void NzSkyboxBackground::Draw(const NzScene* scene) const
|
|||
NzRenderer::SetTextureSampler(textureUnit, m_sampler);
|
||||
NzRenderer::SetVertexBuffer(m_vertexBuffer);
|
||||
|
||||
NzRenderer::DrawIndexedPrimitives(nzPrimitiveType_TriangleList, 0, 36);
|
||||
NzRenderer::DrawIndexedPrimitives(nzPrimitiveMode_TriangleList, 0, 36);
|
||||
|
||||
NzRenderer::SetMatrix(nzMatrixType_View, viewMatrix);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ void NzDebugDrawer::Draw(const NzCubef& cube)
|
|||
|
||||
shader->SendColor(colorLocation, primaryColor);
|
||||
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, 24);
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
|
||||
}
|
||||
|
||||
void NzDebugDrawer::Draw(const NzCubeui& cube)
|
||||
|
|
@ -223,7 +223,7 @@ void NzDebugDrawer::Draw(const NzFrustumf& frustum)
|
|||
|
||||
shader->SendColor(colorLocation, primaryColor);
|
||||
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, 24);
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
|
||||
}
|
||||
|
||||
void NzDebugDrawer::Draw(const NzOrientedCubef& orientedCube)
|
||||
|
|
@ -306,7 +306,7 @@ void NzDebugDrawer::Draw(const NzOrientedCubef& orientedCube)
|
|||
|
||||
shader->SendColor(colorLocation, primaryColor);
|
||||
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, 24);
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
|
||||
}
|
||||
|
||||
void NzDebugDrawer::Draw(const NzSkeleton* skeleton)
|
||||
|
|
@ -355,10 +355,10 @@ void NzDebugDrawer::Draw(const NzSkeleton* skeleton)
|
|||
NzRenderer::SetVertexBuffer(vertexBuffer);
|
||||
|
||||
shader->SendColor(colorLocation, primaryColor);
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, vertexCount);
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, vertexCount);
|
||||
|
||||
shader->SendColor(colorLocation, secondaryColor);
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveType_PointList, 0, vertexCount);
|
||||
NzRenderer::DrawPrimitives(nzPrimitiveMode_PointList, 0, vertexCount);
|
||||
}
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1010,14 +1010,14 @@ GLenum NzOpenGL::FaceFilling[nzFaceFilling_Max+1] =
|
|||
GL_FILL // nzFaceFilling_Fill
|
||||
};
|
||||
|
||||
GLenum NzOpenGL::PrimitiveType[nzPrimitiveType_Max+1] =
|
||||
GLenum NzOpenGL::PrimitiveMode[nzPrimitiveMode_Max+1] =
|
||||
{
|
||||
GL_LINES, // nzPrimitiveType_LineList,
|
||||
GL_LINE_STRIP, // nzPrimitiveType_LineStrip,
|
||||
GL_POINTS, // nzPrimitiveType_PointList,
|
||||
GL_TRIANGLES, // nzPrimitiveType_TriangleList,
|
||||
GL_TRIANGLE_STRIP, // nzPrimitiveType_TriangleStrip,
|
||||
GL_TRIANGLE_FAN // nzPrimitiveType_TriangleFan
|
||||
GL_LINES, // nzPrimitiveMode_LineList
|
||||
GL_LINE_STRIP, // nzPrimitiveMode_LineStrip
|
||||
GL_POINTS, // nzPrimitiveMode_PointList
|
||||
GL_TRIANGLES, // nzPrimitiveMode_TriangleList
|
||||
GL_TRIANGLE_STRIP, // nzPrimitiveMode_TriangleStrip
|
||||
GL_TRIANGLE_FAN // nzPrimitiveMode_TriangleFan
|
||||
};
|
||||
|
||||
GLenum NzOpenGL::RendererComparison[nzRendererComparison_Max+1] =
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ void NzRenderer::Clear(unsigned long flags)
|
|||
}
|
||||
}
|
||||
|
||||
void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount)
|
||||
void NzRenderer::DrawIndexedPrimitives(nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (NzContext::GetCurrent() == nullptr)
|
||||
|
|
@ -142,9 +142,9 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
|
|||
return;
|
||||
}
|
||||
|
||||
if (primitive > nzPrimitiveType_Max)
|
||||
if (mode > nzPrimitiveMode_Max)
|
||||
{
|
||||
NazaraError("Primitive type out of enum");
|
||||
NazaraError("Primitive mode out of enum");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -166,7 +166,7 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
|
|||
}
|
||||
|
||||
if (s_indexBuffer->IsSequential())
|
||||
glDrawArrays(NzOpenGL::PrimitiveType[primitive], s_indexBuffer->GetStartIndex(), s_indexBuffer->GetIndexCount());
|
||||
glDrawArrays(NzOpenGL::PrimitiveMode[mode], s_indexBuffer->GetStartIndex(), s_indexBuffer->GetIndexCount());
|
||||
else
|
||||
{
|
||||
GLenum type;
|
||||
|
|
@ -182,11 +182,11 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
|
|||
type = GL_UNSIGNED_SHORT;
|
||||
}
|
||||
|
||||
glDrawElements(NzOpenGL::PrimitiveType[primitive], indexCount, type, ptr);
|
||||
glDrawElements(NzOpenGL::PrimitiveMode[mode], indexCount, type, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount)
|
||||
void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (NzContext::GetCurrent() == nullptr)
|
||||
|
|
@ -195,9 +195,9 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
|
|||
return;
|
||||
}
|
||||
|
||||
if (primitive > nzPrimitiveType_Max)
|
||||
if (mode > nzPrimitiveMode_Max)
|
||||
{
|
||||
NazaraError("Primitive type out of enum");
|
||||
NazaraError("Primitive mode out of enum");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -221,9 +221,9 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
|
|||
return;
|
||||
}
|
||||
|
||||
if (instanceCount > NAZARA_RENDERER_INSTANCING_MAX)
|
||||
if (instanceCount > NAZARA_RENDERER_MAX_INSTANCES)
|
||||
{
|
||||
NazaraError("Instance count is over maximum instance count (" + NzString::Number(instanceCount) + " >= " + NzString::Number(NAZARA_RENDERER_INSTANCING_MAX) + ')');
|
||||
NazaraError("Instance count is over maximum instance count (" + NzString::Number(instanceCount) + " >= " NazaraStringifyMacro(NAZARA_RENDERER_MAX_INSTANCES) ")" );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -237,7 +237,7 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
|
|||
}
|
||||
|
||||
if (s_indexBuffer->IsSequential())
|
||||
glDrawArraysInstanced(NzOpenGL::PrimitiveType[primitive], s_indexBuffer->GetStartIndex(), s_indexBuffer->GetIndexCount(), instanceCount);
|
||||
glDrawArraysInstanced(NzOpenGL::PrimitiveMode[mode], s_indexBuffer->GetStartIndex(), s_indexBuffer->GetIndexCount(), instanceCount);
|
||||
else
|
||||
{
|
||||
GLenum type;
|
||||
|
|
@ -253,11 +253,11 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
|
|||
type = GL_UNSIGNED_SHORT;
|
||||
}
|
||||
|
||||
glDrawElementsInstanced(NzOpenGL::PrimitiveType[primitive], indexCount, type, ptr, instanceCount);
|
||||
glDrawElementsInstanced(NzOpenGL::PrimitiveMode[mode], indexCount, type, ptr, instanceCount);
|
||||
}
|
||||
}
|
||||
|
||||
void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount)
|
||||
void NzRenderer::DrawPrimitives(nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (NzContext::GetCurrent() == nullptr)
|
||||
|
|
@ -266,9 +266,9 @@ void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVer
|
|||
return;
|
||||
}
|
||||
|
||||
if (primitive > nzPrimitiveType_Max)
|
||||
if (mode > nzPrimitiveMode_Max)
|
||||
{
|
||||
NazaraError("Primitive type out of enum");
|
||||
NazaraError("Primitive mode out of enum");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -281,10 +281,10 @@ void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVer
|
|||
return;
|
||||
}
|
||||
|
||||
glDrawArrays(NzOpenGL::PrimitiveType[primitive], firstVertex, vertexCount);
|
||||
glDrawArrays(NzOpenGL::PrimitiveMode[mode], firstVertex, vertexCount);
|
||||
}
|
||||
|
||||
void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount)
|
||||
void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount)
|
||||
{
|
||||
#ifdef NAZARA_DEBUG
|
||||
if (NzContext::GetCurrent() == nullptr)
|
||||
|
|
@ -293,9 +293,9 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
|
|||
return;
|
||||
}
|
||||
|
||||
if (primitive > nzPrimitiveType_Max)
|
||||
if (mode > nzPrimitiveMode_Max)
|
||||
{
|
||||
NazaraError("Primitive type out of enum");
|
||||
NazaraError("Primitive mode out of enum");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -313,9 +313,9 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
|
|||
return;
|
||||
}
|
||||
|
||||
if (instanceCount > NAZARA_RENDERER_INSTANCING_MAX)
|
||||
if (instanceCount > NAZARA_RENDERER_MAX_INSTANCES)
|
||||
{
|
||||
NazaraError("Instance count is over maximum instance count (" + NzString::Number(instanceCount) + " >= " + NzString::Number(NAZARA_RENDERER_INSTANCING_MAX) + ')');
|
||||
NazaraError("Instance count is over maximum instance count (" + NzString::Number(instanceCount) + " >= " NazaraStringifyMacro(NAZARA_RENDERER_MAX_INSTANCES) ")" );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -328,7 +328,7 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
|
|||
return;
|
||||
}
|
||||
|
||||
glDrawArraysInstanced(NzOpenGL::PrimitiveType[primitive], firstVertex, vertexCount, instanceCount);
|
||||
glDrawArraysInstanced(NzOpenGL::PrimitiveMode[mode], firstVertex, vertexCount, instanceCount);
|
||||
}
|
||||
|
||||
void NzRenderer::DrawTexture(unsigned int unit, const NzRectf& rect, const NzVector2f& uv0, const NzVector2f& uv1, float z)
|
||||
|
|
@ -443,7 +443,7 @@ void NzRenderer::DrawTexture(unsigned int unit, const NzRectf& rect, const NzVec
|
|||
|
||||
shader->SendMatrix(s_matrixLocation[nzMatrixCombination_WorldViewProj], NzMatrix4f::Ortho(0.f, s_targetSize.x, 0.f, s_targetSize.y, 0.f));
|
||||
|
||||
glDrawArrays(NzOpenGL::PrimitiveType[nzPrimitiveType_TriangleStrip], 0, 4);
|
||||
glDrawArrays(NzOpenGL::PrimitiveMode[nzPrimitiveMode_TriangleStrip], 0, 4);
|
||||
|
||||
// Restauration
|
||||
Enable(nzRendererParameter_FaceCulling, faceCulling);
|
||||
|
|
@ -706,7 +706,7 @@ bool NzRenderer::Initialize()
|
|||
if (s_capabilities[nzRendererCap_Instancing])
|
||||
{
|
||||
s_instancingBuffer = new NzBuffer(nzBufferType_Vertex);
|
||||
if (!s_instancingBuffer->Create(NAZARA_RENDERER_INSTANCING_MAX, sizeof(InstancingData), nzBufferStorage_Hardware, nzBufferUsage_Dynamic))
|
||||
if (!s_instancingBuffer->Create(NAZARA_RENDERER_MAX_INSTANCES, sizeof(InstancingData), nzBufferStorage_Hardware, nzBufferUsage_Dynamic))
|
||||
{
|
||||
s_capabilities[nzRendererCap_Instancing] = false;
|
||||
|
||||
|
|
@ -1014,9 +1014,9 @@ void NzRenderer::SetInstancingData(const NzRenderer::InstancingData* instancingD
|
|||
return;
|
||||
}
|
||||
|
||||
if (instanceCount > NAZARA_RENDERER_INSTANCING_MAX)
|
||||
if (instanceCount > NAZARA_RENDERER_MAX_INSTANCES)
|
||||
{
|
||||
NazaraError("Instance count is over maximum instance count (" + NzString::Number(instanceCount) + " >= " + NzString::Number(NAZARA_RENDERER_INSTANCING_MAX) + ')');
|
||||
NazaraError("Instance count is over maximum instance count (" + NzString::Number(instanceCount) + " >= " NazaraStringifyMacro(NAZARA_RENDERER_MAX_INSTANCES) ")");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ namespace
|
|||
sourceCode += "#define LIGHT_DIRECTIONAL 0\n"
|
||||
"#define LIGHT_POINT 1\n"
|
||||
"#define LIGHT_SPOT 2\n"
|
||||
"#define MAX_LIGHTS 8\n"
|
||||
"\n";
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +70,7 @@ namespace
|
|||
{
|
||||
sourceCode += "uniform vec3 CameraPosition;\n"
|
||||
"uniform int LightCount;\n"
|
||||
"uniform Light Lights[MAX_LIGHTS];\n"
|
||||
"uniform Light Lights[" NazaraStringifyMacro(NAZARA_RENDERER_SHADER_MAX_LIGHTCOUNT) "];\n"
|
||||
"uniform vec4 MaterialAmbient;\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
NzSubMesh::NzSubMesh(const NzMesh* parent) :
|
||||
NzResource(false), // Un SubMesh n'est pas persistant par défaut
|
||||
m_primitiveType(nzPrimitiveType_TriangleList),
|
||||
m_primitiveMode(nzPrimitiveMode_TriangleList),
|
||||
m_parent(parent),
|
||||
m_matIndex(0)
|
||||
{
|
||||
|
|
@ -147,9 +147,9 @@ const NzMesh* NzSubMesh::GetParent() const
|
|||
return m_parent;
|
||||
}
|
||||
|
||||
nzPrimitiveType NzSubMesh::GetPrimitiveType() const
|
||||
nzPrimitiveMode NzSubMesh::GetPrimitiveMode() const
|
||||
{
|
||||
return m_primitiveType;
|
||||
return m_primitiveMode;
|
||||
}
|
||||
|
||||
unsigned int NzSubMesh::GetTriangleCount() const
|
||||
|
|
@ -161,24 +161,24 @@ unsigned int NzSubMesh::GetTriangleCount() const
|
|||
else
|
||||
indexCount = GetVertexCount();
|
||||
|
||||
switch (m_primitiveType)
|
||||
switch (m_primitiveMode)
|
||||
{
|
||||
case nzPrimitiveType_LineList:
|
||||
case nzPrimitiveType_LineStrip:
|
||||
case nzPrimitiveType_PointList:
|
||||
case nzPrimitiveMode_LineList:
|
||||
case nzPrimitiveMode_LineStrip:
|
||||
case nzPrimitiveMode_PointList:
|
||||
return 0;
|
||||
|
||||
case nzPrimitiveType_TriangleFan:
|
||||
case nzPrimitiveMode_TriangleFan:
|
||||
return (indexCount - 1) / 2;
|
||||
|
||||
case nzPrimitiveType_TriangleList:
|
||||
case nzPrimitiveMode_TriangleList:
|
||||
return indexCount / 3;
|
||||
|
||||
case nzPrimitiveType_TriangleStrip:
|
||||
case nzPrimitiveMode_TriangleStrip:
|
||||
return indexCount - 2;
|
||||
}
|
||||
|
||||
NazaraError("Primitive type not handled (0x" + NzString::Number(m_primitiveType, 16) + ')');
|
||||
NazaraError("Primitive mode not handled (0x" + NzString::Number(m_primitiveMode, 16) + ')');
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -187,9 +187,9 @@ unsigned int NzSubMesh::GetMaterialIndex() const
|
|||
return m_matIndex;
|
||||
}
|
||||
|
||||
void NzSubMesh::SetPrimitiveType(nzPrimitiveType primitiveType)
|
||||
void NzSubMesh::SetPrimitiveMode(nzPrimitiveMode mode)
|
||||
{
|
||||
m_primitiveType = primitiveType;
|
||||
m_primitiveMode = mode;
|
||||
}
|
||||
|
||||
void NzSubMesh::SetMaterialIndex(unsigned int matIndex)
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <Nazara/Utility/Debug.hpp>
|
||||
|
||||
NzTriangleIterator::NzTriangleIterator(NzSubMesh* subMesh, nzBufferAccess access) :
|
||||
m_primitiveType(subMesh->GetPrimitiveType()),
|
||||
m_primitiveMode(subMesh->GetPrimitiveMode()),
|
||||
m_indexMapper(subMesh->GetIndexBuffer(), nzBufferAccess_ReadOnly),
|
||||
m_vertexMapper(subMesh)
|
||||
{
|
||||
|
|
@ -33,20 +33,20 @@ bool NzTriangleIterator::Advance()
|
|||
return false;
|
||||
}
|
||||
|
||||
switch (m_primitiveType)
|
||||
switch (m_primitiveMode)
|
||||
{
|
||||
case nzPrimitiveType_TriangleFan:
|
||||
case nzPrimitiveMode_TriangleFan:
|
||||
m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++);
|
||||
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
|
||||
break;
|
||||
|
||||
case nzPrimitiveType_TriangleList:
|
||||
case nzPrimitiveMode_TriangleList:
|
||||
m_triangleIndices[0] = m_indexMapper.Get(m_currentIndex++);
|
||||
m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++);
|
||||
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
|
||||
break;
|
||||
|
||||
case nzPrimitiveType_TriangleStrip:
|
||||
case nzPrimitiveMode_TriangleStrip:
|
||||
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
|
||||
m_triangleIndices[1] = m_triangleIndices[2];
|
||||
m_triangleIndices[0] = m_triangleIndices[1];
|
||||
|
|
|
|||
Loading…
Reference in New Issue