From 0f5dca6efd29724256e16d2fe296843139993cc3 Mon Sep 17 00:00:00 2001 From: jmacey Date: Fri, 6 Oct 2023 11:47:25 +0100 Subject: [PATCH] removed some warnings from the stb_image_writer header, it's not been updated for 2 years so still the old download --- 3rdparty/stb_image_write.h | 18 +++++++++--------- src/Image.cpp | 5 ++--- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/3rdparty/stb_image_write.h b/3rdparty/stb_image_write.h index 6302e561..9aabd87e 100644 --- a/3rdparty/stb_image_write.h +++ b/3rdparty/stb_image_write.h @@ -537,7 +537,7 @@ static int stbi_write_bmp_core(stbi__write_context *s, int x, int y, int comp, c STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); //{0}; stbi__start_write_callbacks(&s, func, context); return stbi_write_bmp_core(&s, x, y, comp, data); } @@ -545,7 +545,7 @@ STBIWDEF int stbi_write_bmp_to_func(stbi_write_func *func, void *context, int x, #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_bmp(char const *filename, int x, int y, int comp, const void *data) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); //{0}; if(stbi__start_write_file(&s, filename)) { int r = stbi_write_bmp_core(&s, x, y, comp, data); @@ -661,7 +661,7 @@ static int stbi_write_tga_core(stbi__write_context *s, int x, int y, int comp, v STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); //{0}; stbi__start_write_callbacks(&s, func, context); return stbi_write_tga_core(&s, x, y, comp, (void *)data); } @@ -669,7 +669,7 @@ STBIWDEF int stbi_write_tga_to_func(stbi_write_func *func, void *context, int x, #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_tga(char const *filename, int x, int y, int comp, const void *data) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); //{0}; if(stbi__start_write_file(&s, filename)) { int r = stbi_write_tga_core(&s, x, y, comp, (void *)data); @@ -845,7 +845,7 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f #ifdef __STDC_LIB_EXT1__ len = sprintf_s(buffer, sizeof(buffer), "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #else - len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); + len = snprintf(buffer,128, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x); #endif s->func(s->context, buffer, len); @@ -858,14 +858,14 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp, f STBIWDEF int stbi_write_hdr_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const float *data) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); stbi__start_write_callbacks(&s, func, context); return stbi_write_hdr_core(&s, x, y, comp, (float *)data); } STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp, const float *data) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); if(stbi__start_write_file(&s, filename)) { int r = stbi_write_hdr_core(&s, x, y, comp, (float *)data); @@ -1759,7 +1759,7 @@ static int stbi_write_jpg_core(stbi__write_context *s, int width, int height, in STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, int y, int comp, const void *data, int quality) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); // {0}; stbi__start_write_callbacks(&s, func, context); return stbi_write_jpg_core(&s, x, y, comp, (void *)data, quality); } @@ -1767,7 +1767,7 @@ STBIWDEF int stbi_write_jpg_to_func(stbi_write_func *func, void *context, int x, #ifndef STBI_WRITE_NO_STDIO STBIWDEF int stbi_write_jpg(char const *filename, int x, int y, int comp, const void *data, int quality) { - stbi__write_context s = {0}; + stbi__write_context s = stbi__write_context(); if(stbi__start_write_file(&s, filename)) { int r = stbi_write_jpg_core(&s, x, y, comp, data, quality); diff --git a/src/Image.cpp b/src/Image.cpp index cf63b617..91f4cfea 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -120,8 +120,8 @@ Vec4 Image::getColour(const GLuint _x, const GLuint _y) const noexcept Vec4 Image::getColour(const Real _uvX, const Real _uvY) const noexcept { - auto xx = static_cast< GLuint >(_uvX * (m_width - 1)); - auto yy = static_cast< GLuint >(_uvY * (m_height - 1)); + auto xx = static_cast< GLuint >(static_cast(_uvX) * (m_width - 1)); + auto yy = static_cast< GLuint >(static_cast(_uvY) * (m_height - 1)); NGL_ASSERT(xx < m_width && yy < m_height) @@ -373,7 +373,6 @@ bool Image::load(std::string_view _fname,bool _flipY) noexcept int ch; stbi_set_flip_vertically_on_load(_flipY); - 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));