From 315a2ebb1a4e379d52a9502f8f40d1e68b42e86d Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 8 May 2022 23:57:41 +0200 Subject: [PATCH] Make the code compile --- src/quadtree.cpp | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/quadtree.cpp b/src/quadtree.cpp index 3876ce8..24917dd 100644 --- a/src/quadtree.cpp +++ b/src/quadtree.cpp @@ -1,5 +1,17 @@ #include "../includes/quadtree.hpp" +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + Uint32 r_mask = 0xff000000; + Uint32 g_mask = 0x00ff0000; + Uint32 b_mask = 0x0000ff00; + Uint32 a_mask = 0x000000ff; +#else + Uint32 r_mask = 0x000000ff; + Uint32 g_mask = 0x0000ff00; + Uint32 b_mask = 0x00ff0000; + Uint32 a_mask = 0xff000000; +#endif + QuadTree::QuadTree(SDL_Surface * image, short niveau_p): niveau(niveau_p), couleur(calculeCouleur(image)), dimensions(image->w, image->h), nord_ouest(nullptr), nord_est(nullptr), sud_ouest(nullptr), sud_est(nullptr) { if(!verificationEgalitee(image)) { @@ -46,9 +58,15 @@ SDL_Surface * QuadTree::image(short niveau_p) { return nouvelle_image; } -SDL_Color QuadTree::calculeCouleur(SDL_Surface *) { /* return SDL_Color(); */ } +SDL_Color QuadTree::calculeCouleur(SDL_Surface *) { + // Temporaire + return SDL_Color(); +} -bool QuadTree::verificationEgalitee(SDL_Surface *) { /* return true; */ } +bool QuadTree::verificationEgalitee(SDL_Surface *) { + // Temporaire + return true; +} std::array QuadTree::coupeEnQuatre(SDL_Surface * s) { // Coordonnées des extrémités de chaque quadrant @@ -58,20 +76,6 @@ std::array QuadTree::coupeEnQuatre(SDL_Surface * s) { coordonnes_quadrants[2] = {s->w / 2, 0 , s->w , s->h / 2}; coordonnes_quadrants[3] = {s->w / 2, s->h / 2, s->w , s->h}; - // Masque dépend de l'ordre des octets de la machine - Uint32 r_mask, g_mask, b_mask, a_mask; - if(SDL_BYTEORDER == SDL_BIG_ENDIAN) { - r_mask = 0xff000000; - g_mask = 0x00ff0000; - b_mask = 0x0000ff00; - a_mask = 0x000000ff; - } else { - r_mask = 0x000000ff; - g_mask = 0x0000ff00; - b_mask = 0x00ff0000; - a_mask = 0xff000000; - } - std::array resultat; for(Uint32 i = 0; i < 4; ++i) { // Création d'une nouvelle surface