Improved code based on CppCheck results
None of this should change the engine's behavior, but the code is better this way. Former-commit-id: 0127769848fc1f7fc8006ee607985cfc0ead2965
This commit is contained in:
@@ -781,7 +781,7 @@ bool NzOpenGL::Initialize()
|
||||
major = version[0] - '0';
|
||||
minor = version[2] - '0';
|
||||
|
||||
if (major <= 0 || major > 9)
|
||||
if (major == 0 || major > 9)
|
||||
{
|
||||
NazaraError("Unable to retrieve OpenGL major version");
|
||||
return false;
|
||||
|
||||
@@ -1797,10 +1797,6 @@ bool NzRenderer::EnsureStateUpdate()
|
||||
|
||||
if (update)
|
||||
{
|
||||
const NzVertexDeclaration* vertexDeclaration;
|
||||
unsigned int bufferOffset;
|
||||
unsigned int stride;
|
||||
|
||||
// Pour éviter la duplication de code, on va utiliser une astuce via une boucle for
|
||||
for (unsigned int i = 0; i < (s_instancing ? 2 : 1); ++i)
|
||||
{
|
||||
@@ -1810,9 +1806,9 @@ bool NzRenderer::EnsureStateUpdate()
|
||||
NzHardwareBuffer* vertexBufferImpl = static_cast<NzHardwareBuffer*>(vertexBuffer->GetBuffer()->GetImpl());
|
||||
glBindBuffer(NzOpenGL::BufferTarget[nzBufferType_Vertex], vertexBufferImpl->GetOpenGLID());
|
||||
|
||||
bufferOffset = vertexBuffer->GetStartOffset();
|
||||
vertexDeclaration = vertexBuffer->GetVertexDeclaration();
|
||||
stride = vertexDeclaration->GetStride();
|
||||
unsigned int bufferOffset = vertexBuffer->GetStartOffset();
|
||||
const NzVertexDeclaration* vertexDeclaration = vertexBuffer->GetVertexDeclaration();
|
||||
unsigned int stride = vertexDeclaration->GetStride();
|
||||
|
||||
// On définit les bornes (une fois de plus selon l'itération)
|
||||
unsigned int start = (i == 0) ? nzVertexComponent_FirstVertexData : nzVertexComponent_FirstInstanceData;
|
||||
|
||||
@@ -249,7 +249,7 @@ NzString NzShader::GetSourceCode(nzShaderStage stage) const
|
||||
totalLength += length - 1;
|
||||
}
|
||||
|
||||
totalLength += (m_attachedShaders[stage].size()-1)*(sizeof(sep)/sizeof(char));
|
||||
totalLength += (m_attachedShaders[stage].size()-1) * (sizeof(sep)/sizeof(char));
|
||||
|
||||
NzString source(totalLength, '\0');
|
||||
|
||||
@@ -258,7 +258,7 @@ NzString NzShader::GetSourceCode(nzShaderStage stage) const
|
||||
{
|
||||
if (offset > 0)
|
||||
{
|
||||
std::memcpy(&source[offset], sep, sizeof(sep)/sizeof(char));
|
||||
std::memcpy(&source[offset], sep, sizeof(sep));
|
||||
offset += sizeof(sep)/sizeof(char);
|
||||
}
|
||||
|
||||
|
||||
@@ -963,12 +963,9 @@ bool NzTexture::Update(const nzUInt8* pixels, const NzBoxui& box, unsigned int s
|
||||
NazaraError("Invalid box");
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned int height = GetLevelSize(m_impl->height, level);
|
||||
|
||||
#if NAZARA_RENDERER_SAFE
|
||||
|
||||
unsigned int width = GetLevelSize(m_impl->width, level);
|
||||
unsigned int height = GetLevelSize(m_impl->height, level);
|
||||
unsigned int depth = (m_impl->type == nzImageType_Cubemap) ? 6 : GetLevelSize(m_impl->depth, level);
|
||||
if (box.x+box.width > width || box.y+box.height > height || box.z+box.depth > depth ||
|
||||
(m_impl->type == nzImageType_Cubemap && box.depth > 1)) // Nous n'autorisons pas de modifier plus d'une face du cubemap à la fois
|
||||
|
||||
Reference in New Issue
Block a user