Skip to content

Commit

Permalink
Merge branch 'main' of github.com:/NCCA/NGL
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacey committed Oct 6, 2023
2 parents 81cc2b4 + d2691db commit c285263
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down
12 changes: 8 additions & 4 deletions src/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/Shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c285263

Please sign in to comment.