From 558025dfa74102b47f81f3b007c55ead9222a499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Leclaire-Fournier?= Date: Wed, 7 Feb 2024 18:54:53 -0500 Subject: [PATCH] Petites optimisations --- GPA675Lab1GOL/GOLTeamH.cpp | 8 +++++--- GPA675Lab1GOL/GOLTeamH.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/GPA675Lab1GOL/GOLTeamH.cpp b/GPA675Lab1GOL/GOLTeamH.cpp index ad343fc..21376c5 100644 --- a/GPA675Lab1GOL/GOLTeamH.cpp +++ b/GPA675Lab1GOL/GOLTeamH.cpp @@ -518,11 +518,13 @@ void GOLTeamH::updateImage(uint32_t* buffer, size_t buffer_size) const // Pointeur qui se promène en mémoire. auto* ptrGrid{ reinterpret_cast(mData.data()) }; + // Clear tout + memset(buffer, 0, sizeof(uint32_t) * buffer_size); + // On itère sur chaque éléments du tableau et on associe la couleur. while (s_ptr < e_ptr) { - *s_ptr &= 0; // Clear - *s_ptr |= MAX_ALPHA << 24; // Alpha = 255 - *s_ptr |= mColorEncoded >> (32 * (*ptrGrid)); + // Alpha = 255 + *s_ptr |= mColorEncoded >> (32 * (*ptrGrid)) | MAX_ALPHA; s_ptr++; ptrGrid++; diff --git a/GPA675Lab1GOL/GOLTeamH.h b/GPA675Lab1GOL/GOLTeamH.h index 338287c..99297ee 100644 --- a/GPA675Lab1GOL/GOLTeamH.h +++ b/GPA675Lab1GOL/GOLTeamH.h @@ -24,7 +24,7 @@ // Elle se base sur l'utilisation de la classe GridTeamH afin de gérer les mouvement dans la grid // - - - - - - - - - - - - - - - - - - - - - - - -constexpr unsigned char MAX_ALPHA = 255; +constexpr uint32_t MAX_ALPHA = 255 << 24; class GOLTeamH : public GOL {