From d2691db0bfe5983edd83615e2e8fc58030809005 Mon Sep 17 00:00:00 2001
From: jmacey <jmacey@bournemouth.ac.uk>
Date: Wed, 4 Oct 2023 12:13:52 +0100
Subject: [PATCH] updated image class

---
 CMakeLists.txt |  2 +-
 src/Image.cpp  | 12 ++++++++----
 src/Shader.cpp |  1 +
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2707f163..6da53765 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 # -------------------------------------------------------------------------------------------
 # as much as possible I will use best practice as outlined in the book "Profession cmake"
 # -------------------------------------------------------------------------------------------
-cmake_minimum_required(VERSION 3.12)
+cmake_minimum_required(VERSION 3.20.0)
 
 if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
    set(CMAKE_TOOLCHAIN_FILE $ENV{CMAKE_TOOLCHAIN_FILE})
diff --git a/src/Image.cpp b/src/Image.cpp
index 48d202be..8303050a 100644
--- a/src/Image.cpp
+++ b/src/Image.cpp
@@ -374,17 +374,21 @@ bool Image::load(std::string_view _fname,bool _flipY) noexcept
   stbi_set_flip_vertically_on_load(_flipY);
 
   
-  if(unsigned char *img = stbi_load(fname, &w, &h, &ch, 0); img != nullptr)
+  if(const unsigned char *img = stbi_load(fname, &w, &h, &ch, 0); img != nullptr)
   {
     NGLMessage::addMessage(fmt::format("loaded {} Width {} Height {} Channels {}", fname, w, h, ch));
     m_width = w;
     m_height = h;
     m_channels = ch;
     if(m_channels == 3)
-      m_format = GL_RGB;
+    {
+        m_format = GL_RGB;
+    }
     else if(m_channels == 4)
-      m_format = GL_RGBA;
-    m_data.reset(new unsigned char[m_width * m_height * m_channels]);
+    {
+        m_format = GL_RGBA;
+    }
+    m_data=std::make_unique< unsigned char []>(m_width * m_height * m_channels);
     memcpy(m_data.get(), img, m_width * m_height * m_channels);
   }
   else
diff --git a/src/Shader.cpp b/src/Shader.cpp
index 4b91303c..498f05cc 100644
--- a/src/Shader.cpp
+++ b/src/Shader.cpp
@@ -97,6 +97,7 @@ Shader::~Shader()
   // Note this needs to be with cerr as NGLMessage crashes here
   std::cerr << fmt::format("removing shader {0} \n", m_name); 
   glDeleteShader(m_shaderHandle);
+
 }
 
 bool Shader::compile() noexcept