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:
Lynix 2013-05-24 20:12:40 +02:00
parent 50e8ce3658
commit cf6e2be0b0
14 changed files with 80 additions and 78 deletions

View File

@ -30,7 +30,7 @@
/// Chaque modification d'un paramètre du module nécessite une recompilation de celui-ci /// 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 // 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) // Utilise un tracker pour repérer les éventuels leaks (Ralentit l'exécution)
#define NAZARA_RENDERER_MEMORYLEAKTRACKER 0 #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) // Active les tests de sécurité basés sur le code (Conseillé pour le développement)
#define NAZARA_RENDERER_SAFE 1 #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 #endif // NAZARA_CONFIG_MODULENAME_HPP

View File

@ -107,7 +107,7 @@ class NAZARA_API NzOpenGL
static GLenum ElementType[nzElementType_Max+1]; static GLenum ElementType[nzElementType_Max+1];
static GLenum FaceCulling[nzFaceCulling_Max+1]; static GLenum FaceCulling[nzFaceCulling_Max+1];
static GLenum FaceFilling[nzFaceFilling_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 RendererComparison[nzRendererComparison_Max+1];
static GLenum RendererParameter[nzRendererParameter_Max+1]; static GLenum RendererParameter[nzRendererParameter_Max+1];
static GLenum SamplerWrapMode[nzSamplerWrap_Max+1]; static GLenum SamplerWrapMode[nzSamplerWrap_Max+1];

View File

@ -36,10 +36,10 @@ class NAZARA_API NzRenderer
static void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth); static void Clear(unsigned long flags = nzRendererClear_Color | nzRendererClear_Depth);
static void DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount); static void DrawIndexedPrimitives(nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, unsigned int firstIndex, unsigned int indexCount); static void DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveMode mode, unsigned int firstIndex, unsigned int indexCount);
static void DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVertex, unsigned int vertexCount); static void DrawPrimitives(nzPrimitiveMode mode, unsigned int firstVertex, unsigned int vertexCount);
static void DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitiveType primitive, 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); 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); static void Enable(nzRendererParameter parameter, bool enable);

View File

@ -205,16 +205,16 @@ enum nzPixelFlipping
nzPixelFlipping_Max = nzPixelFlipping_Vertically nzPixelFlipping_Max = nzPixelFlipping_Vertically
}; };
enum nzPrimitiveType enum nzPrimitiveMode
{ {
nzPrimitiveType_LineList, nzPrimitiveMode_LineList,
nzPrimitiveType_LineStrip, nzPrimitiveMode_LineStrip,
nzPrimitiveType_PointList, nzPrimitiveMode_PointList,
nzPrimitiveType_TriangleList, nzPrimitiveMode_TriangleList,
nzPrimitiveType_TriangleStrip, nzPrimitiveMode_TriangleStrip,
nzPrimitiveType_TriangleFan, nzPrimitiveMode_TriangleFan,
nzPrimitiveType_Max = nzPrimitiveType_TriangleFan nzPrimitiveMode_Max = nzPrimitiveMode_TriangleFan
}; };
enum nzWindowCursor enum nzWindowCursor

View File

@ -39,17 +39,17 @@ class NAZARA_API NzSubMesh : public NzResource
virtual const NzIndexBuffer* GetIndexBuffer() const = 0; virtual const NzIndexBuffer* GetIndexBuffer() const = 0;
unsigned int GetMaterialIndex() const; unsigned int GetMaterialIndex() const;
const NzMesh* GetParent() const; const NzMesh* GetParent() const;
nzPrimitiveType GetPrimitiveType() const; nzPrimitiveMode GetPrimitiveMode() const;
unsigned int GetTriangleCount() const; unsigned int GetTriangleCount() const;
virtual unsigned int GetVertexCount() const = 0; virtual unsigned int GetVertexCount() const = 0;
virtual bool IsAnimated() const = 0; virtual bool IsAnimated() const = 0;
void SetMaterialIndex(unsigned int matIndex); void SetMaterialIndex(unsigned int matIndex);
void SetPrimitiveType(nzPrimitiveType primitiveType); void SetPrimitiveMode(nzPrimitiveMode mode);
protected: protected:
nzPrimitiveType m_primitiveType; nzPrimitiveMode m_primitiveMode;
const NzMesh* m_parent; const NzMesh* m_parent;
unsigned int m_matIndex; unsigned int m_matIndex;
}; };

View File

@ -37,7 +37,7 @@ class NAZARA_API NzTriangleIterator
void Unmap(); void Unmap();
private: private:
nzPrimitiveType m_primitiveType; nzPrimitiveMode m_primitiveMode;
nzUInt32 m_triangleIndices[3]; nzUInt32 m_triangleIndices[3];
NzIndexMapper m_indexMapper; NzIndexMapper m_indexMapper;
NzVertexMapper m_vertexMapper; NzVertexMapper m_vertexMapper;

View File

@ -160,7 +160,7 @@ namespace
subMesh->GenerateAABB(); subMesh->GenerateAABB();
subMesh->SetMaterialIndex(meshes[i].material); subMesh->SetMaterialIndex(meshes[i].material);
subMesh->SetPrimitiveType(nzPrimitiveType_TriangleList); subMesh->SetPrimitiveMode(nzPrimitiveMode_TriangleList);
if (hasNormals && hasTexCoords) if (hasNormals && hasTexCoords)
subMesh->GenerateTangents(); subMesh->GenerateTangents();

View File

@ -224,7 +224,7 @@ void NzSkyboxBackground::Draw(const NzScene* scene) const
NzRenderer::SetTextureSampler(textureUnit, m_sampler); NzRenderer::SetTextureSampler(textureUnit, m_sampler);
NzRenderer::SetVertexBuffer(m_vertexBuffer); NzRenderer::SetVertexBuffer(m_vertexBuffer);
NzRenderer::DrawIndexedPrimitives(nzPrimitiveType_TriangleList, 0, 36); NzRenderer::DrawIndexedPrimitives(nzPrimitiveMode_TriangleList, 0, 36);
NzRenderer::SetMatrix(nzMatrixType_View, viewMatrix); NzRenderer::SetMatrix(nzMatrixType_View, viewMatrix);
} }

View File

@ -135,7 +135,7 @@ void NzDebugDrawer::Draw(const NzCubef& cube)
shader->SendColor(colorLocation, primaryColor); shader->SendColor(colorLocation, primaryColor);
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, 24); NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
} }
void NzDebugDrawer::Draw(const NzCubeui& cube) void NzDebugDrawer::Draw(const NzCubeui& cube)
@ -223,7 +223,7 @@ void NzDebugDrawer::Draw(const NzFrustumf& frustum)
shader->SendColor(colorLocation, primaryColor); shader->SendColor(colorLocation, primaryColor);
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, 24); NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
} }
void NzDebugDrawer::Draw(const NzOrientedCubef& orientedCube) void NzDebugDrawer::Draw(const NzOrientedCubef& orientedCube)
@ -306,7 +306,7 @@ void NzDebugDrawer::Draw(const NzOrientedCubef& orientedCube)
shader->SendColor(colorLocation, primaryColor); shader->SendColor(colorLocation, primaryColor);
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, 24); NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, 24);
} }
void NzDebugDrawer::Draw(const NzSkeleton* skeleton) void NzDebugDrawer::Draw(const NzSkeleton* skeleton)
@ -355,10 +355,10 @@ void NzDebugDrawer::Draw(const NzSkeleton* skeleton)
NzRenderer::SetVertexBuffer(vertexBuffer); NzRenderer::SetVertexBuffer(vertexBuffer);
shader->SendColor(colorLocation, primaryColor); shader->SendColor(colorLocation, primaryColor);
NzRenderer::DrawPrimitives(nzPrimitiveType_LineList, 0, vertexCount); NzRenderer::DrawPrimitives(nzPrimitiveMode_LineList, 0, vertexCount);
shader->SendColor(colorLocation, secondaryColor); shader->SendColor(colorLocation, secondaryColor);
NzRenderer::DrawPrimitives(nzPrimitiveType_PointList, 0, vertexCount); NzRenderer::DrawPrimitives(nzPrimitiveMode_PointList, 0, vertexCount);
} }
} }
/* /*

View File

@ -1010,14 +1010,14 @@ GLenum NzOpenGL::FaceFilling[nzFaceFilling_Max+1] =
GL_FILL // nzFaceFilling_Fill GL_FILL // nzFaceFilling_Fill
}; };
GLenum NzOpenGL::PrimitiveType[nzPrimitiveType_Max+1] = GLenum NzOpenGL::PrimitiveMode[nzPrimitiveMode_Max+1] =
{ {
GL_LINES, // nzPrimitiveType_LineList, GL_LINES, // nzPrimitiveMode_LineList
GL_LINE_STRIP, // nzPrimitiveType_LineStrip, GL_LINE_STRIP, // nzPrimitiveMode_LineStrip
GL_POINTS, // nzPrimitiveType_PointList, GL_POINTS, // nzPrimitiveMode_PointList
GL_TRIANGLES, // nzPrimitiveType_TriangleList, GL_TRIANGLES, // nzPrimitiveMode_TriangleList
GL_TRIANGLE_STRIP, // nzPrimitiveType_TriangleStrip, GL_TRIANGLE_STRIP, // nzPrimitiveMode_TriangleStrip
GL_TRIANGLE_FAN // nzPrimitiveType_TriangleFan GL_TRIANGLE_FAN // nzPrimitiveMode_TriangleFan
}; };
GLenum NzOpenGL::RendererComparison[nzRendererComparison_Max+1] = GLenum NzOpenGL::RendererComparison[nzRendererComparison_Max+1] =

View File

@ -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 #ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr) if (NzContext::GetCurrent() == nullptr)
@ -142,9 +142,9 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
return; return;
} }
if (primitive > nzPrimitiveType_Max) if (mode > nzPrimitiveMode_Max)
{ {
NazaraError("Primitive type out of enum"); NazaraError("Primitive mode out of enum");
return; return;
} }
#endif #endif
@ -166,7 +166,7 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
} }
if (s_indexBuffer->IsSequential()) 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 else
{ {
GLenum type; GLenum type;
@ -182,11 +182,11 @@ void NzRenderer::DrawIndexedPrimitives(nzPrimitiveType primitive, unsigned int f
type = GL_UNSIGNED_SHORT; 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 #ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr) if (NzContext::GetCurrent() == nullptr)
@ -195,9 +195,9 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
return; return;
} }
if (primitive > nzPrimitiveType_Max) if (mode > nzPrimitiveMode_Max)
{ {
NazaraError("Primitive type out of enum"); NazaraError("Primitive mode out of enum");
return; return;
} }
#endif #endif
@ -221,9 +221,9 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
return; 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; return;
} }
#endif #endif
@ -237,7 +237,7 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
} }
if (s_indexBuffer->IsSequential()) 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 else
{ {
GLenum type; GLenum type;
@ -253,11 +253,11 @@ void NzRenderer::DrawIndexedPrimitivesInstanced(unsigned int instanceCount, nzPr
type = GL_UNSIGNED_SHORT; 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 #ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr) if (NzContext::GetCurrent() == nullptr)
@ -266,9 +266,9 @@ void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVer
return; return;
} }
if (primitive > nzPrimitiveType_Max) if (mode > nzPrimitiveMode_Max)
{ {
NazaraError("Primitive type out of enum"); NazaraError("Primitive mode out of enum");
return; return;
} }
#endif #endif
@ -281,10 +281,10 @@ void NzRenderer::DrawPrimitives(nzPrimitiveType primitive, unsigned int firstVer
return; 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 #ifdef NAZARA_DEBUG
if (NzContext::GetCurrent() == nullptr) if (NzContext::GetCurrent() == nullptr)
@ -293,9 +293,9 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
return; return;
} }
if (primitive > nzPrimitiveType_Max) if (mode > nzPrimitiveMode_Max)
{ {
NazaraError("Primitive type out of enum"); NazaraError("Primitive mode out of enum");
return; return;
} }
#endif #endif
@ -313,9 +313,9 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
return; 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; return;
} }
#endif #endif
@ -328,7 +328,7 @@ void NzRenderer::DrawPrimitivesInstanced(unsigned int instanceCount, nzPrimitive
return; 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) 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)); 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 // Restauration
Enable(nzRendererParameter_FaceCulling, faceCulling); Enable(nzRendererParameter_FaceCulling, faceCulling);
@ -706,7 +706,7 @@ bool NzRenderer::Initialize()
if (s_capabilities[nzRendererCap_Instancing]) if (s_capabilities[nzRendererCap_Instancing])
{ {
s_instancingBuffer = new NzBuffer(nzBufferType_Vertex); 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; s_capabilities[nzRendererCap_Instancing] = false;
@ -1014,9 +1014,9 @@ void NzRenderer::SetInstancingData(const NzRenderer::InstancingData* instancingD
return; 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; return;
} }
#endif #endif

View File

@ -44,7 +44,6 @@ namespace
sourceCode += "#define LIGHT_DIRECTIONAL 0\n" sourceCode += "#define LIGHT_DIRECTIONAL 0\n"
"#define LIGHT_POINT 1\n" "#define LIGHT_POINT 1\n"
"#define LIGHT_SPOT 2\n" "#define LIGHT_SPOT 2\n"
"#define MAX_LIGHTS 8\n"
"\n"; "\n";
} }
@ -71,7 +70,7 @@ namespace
{ {
sourceCode += "uniform vec3 CameraPosition;\n" sourceCode += "uniform vec3 CameraPosition;\n"
"uniform int LightCount;\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"; "uniform vec4 MaterialAmbient;\n";
} }

View File

@ -14,7 +14,7 @@
NzSubMesh::NzSubMesh(const NzMesh* parent) : NzSubMesh::NzSubMesh(const NzMesh* parent) :
NzResource(false), // Un SubMesh n'est pas persistant par défaut NzResource(false), // Un SubMesh n'est pas persistant par défaut
m_primitiveType(nzPrimitiveType_TriangleList), m_primitiveMode(nzPrimitiveMode_TriangleList),
m_parent(parent), m_parent(parent),
m_matIndex(0) m_matIndex(0)
{ {
@ -147,9 +147,9 @@ const NzMesh* NzSubMesh::GetParent() const
return m_parent; return m_parent;
} }
nzPrimitiveType NzSubMesh::GetPrimitiveType() const nzPrimitiveMode NzSubMesh::GetPrimitiveMode() const
{ {
return m_primitiveType; return m_primitiveMode;
} }
unsigned int NzSubMesh::GetTriangleCount() const unsigned int NzSubMesh::GetTriangleCount() const
@ -161,24 +161,24 @@ unsigned int NzSubMesh::GetTriangleCount() const
else else
indexCount = GetVertexCount(); indexCount = GetVertexCount();
switch (m_primitiveType) switch (m_primitiveMode)
{ {
case nzPrimitiveType_LineList: case nzPrimitiveMode_LineList:
case nzPrimitiveType_LineStrip: case nzPrimitiveMode_LineStrip:
case nzPrimitiveType_PointList: case nzPrimitiveMode_PointList:
return 0; return 0;
case nzPrimitiveType_TriangleFan: case nzPrimitiveMode_TriangleFan:
return (indexCount - 1) / 2; return (indexCount - 1) / 2;
case nzPrimitiveType_TriangleList: case nzPrimitiveMode_TriangleList:
return indexCount / 3; return indexCount / 3;
case nzPrimitiveType_TriangleStrip: case nzPrimitiveMode_TriangleStrip:
return indexCount - 2; 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; return 0;
} }
@ -187,9 +187,9 @@ unsigned int NzSubMesh::GetMaterialIndex() const
return m_matIndex; 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) void NzSubMesh::SetMaterialIndex(unsigned int matIndex)

View File

@ -7,7 +7,7 @@
#include <Nazara/Utility/Debug.hpp> #include <Nazara/Utility/Debug.hpp>
NzTriangleIterator::NzTriangleIterator(NzSubMesh* subMesh, nzBufferAccess access) : NzTriangleIterator::NzTriangleIterator(NzSubMesh* subMesh, nzBufferAccess access) :
m_primitiveType(subMesh->GetPrimitiveType()), m_primitiveMode(subMesh->GetPrimitiveMode()),
m_indexMapper(subMesh->GetIndexBuffer(), nzBufferAccess_ReadOnly), m_indexMapper(subMesh->GetIndexBuffer(), nzBufferAccess_ReadOnly),
m_vertexMapper(subMesh) m_vertexMapper(subMesh)
{ {
@ -33,20 +33,20 @@ bool NzTriangleIterator::Advance()
return false; return false;
} }
switch (m_primitiveType) switch (m_primitiveMode)
{ {
case nzPrimitiveType_TriangleFan: case nzPrimitiveMode_TriangleFan:
m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++); m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++);
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++); m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
break; break;
case nzPrimitiveType_TriangleList: case nzPrimitiveMode_TriangleList:
m_triangleIndices[0] = m_indexMapper.Get(m_currentIndex++); m_triangleIndices[0] = m_indexMapper.Get(m_currentIndex++);
m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++); m_triangleIndices[1] = m_indexMapper.Get(m_currentIndex++);
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++); m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
break; break;
case nzPrimitiveType_TriangleStrip: case nzPrimitiveMode_TriangleStrip:
m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++); m_triangleIndices[2] = m_indexMapper.Get(m_currentIndex++);
m_triangleIndices[1] = m_triangleIndices[2]; m_triangleIndices[1] = m_triangleIndices[2];
m_triangleIndices[0] = m_triangleIndices[1]; m_triangleIndices[0] = m_triangleIndices[1];