From 0d74df29c80172cef5f6751a920957d56aa9a847 Mon Sep 17 00:00:00 2001 From: Bhavye Mathur Date: Wed, 3 Jan 2024 16:43:53 +0530 Subject: [PATCH] Fixed misc Windows warnings Signed-off-by: Bhavye Mathur --- CMakeLists.txt | 7 ++- src/goopylib/core/BufferLayout.cpp | 1 + src/goopylib/shader/Shader.h | 74 ++++++++++++++--------------- src/goopylib/texture/Bitmap.h | 14 +++--- src/goopylib/texture/Texture2D.h | 16 +++---- src/goopylib/texture/TextureAtlas.h | 8 ++-- vendor/glad/glad.h | 6 +-- 7 files changed, 63 insertions(+), 63 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9345cbfa..aa68663e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,12 +21,11 @@ set(CMAKE_CXX_STANDARD 17) find_package(OpenGL REQUIRED) -# needed to silence errors in IDE -find_package(PythonInterp REQUIRED) -find_package(PythonLibs REQUIRED) if(POLICY CMP0148) cmake_policy(SET CMP0148 OLD) endif() +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) include_directories(${PYTHON_INCLUDE_DIRS}) @@ -43,7 +42,7 @@ if (WIN32) set(WINDOWS_SOURCES vendor/glad/glad.c) if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - set(CMAKE_CXX_FLAGS "-wd4068") + set(CMAKE_CXX_FLAGS "-wd4068 /EHsc") if (MSVC_TOOLSET_VERSION EQUAL 110) set(GOOPYLIB_PLATFORM_NAME vc2012) diff --git a/src/goopylib/core/BufferLayout.cpp b/src/goopylib/core/BufferLayout.cpp index b8f8d707..f95a001f 100644 --- a/src/goopylib/core/BufferLayout.cpp +++ b/src/goopylib/core/BufferLayout.cpp @@ -107,6 +107,7 @@ namespace gp { case ShaderDataType::Bool: return 1; case ShaderDataType::None: + default: GP_CORE_ERROR("Unrecognised Shader Type"); return 0; } diff --git a/src/goopylib/shader/Shader.h b/src/goopylib/shader/Shader.h index 8de6ad6f..2911b2d3 100644 --- a/src/goopylib/shader/Shader.h +++ b/src/goopylib/shader/Shader.h @@ -14,95 +14,95 @@ namespace gp { friend class Renderer; public: - Shader(const char *vertexShaderSource, const char *fragmentShaderSource); + GPAPI Shader(const char *vertexShaderSource, const char *fragmentShaderSource); GPAPI Shader (const Shader&) = delete; ~Shader(); - void setUniformBlock(const Ref &uniform, const char *name, uint32_t binding) const; + GPAPI void setUniformBlock(const Ref &uniform, const char *name, uint32_t binding) const; template - void set(const char *name, T &&... args) { + GPAPI void set(const char *name, T &&... args) { bind(); _setUniform(_getLocation(name), std::forward < T > (args)...); } - static Ref load(const char *vertexShaderPath, const char *fragmentShaderPath) { + GPAPI static Ref load(const char *vertexShaderPath, const char *fragmentShaderPath) { return Ref(new Shader(readFile(vertexShaderPath).c_str(), readFile(fragmentShaderPath).c_str())); } private: - void bind() const; + GPAPI void bind() const; - static void unbind(); + GPAPI static void unbind(); private: uint32_t m_RendererID = 0; std::unordered_map m_Uniforms; - int32_t _getLocation(const char *name); + [[nodiscard]] GPAPI int32_t _getLocation(const char *name); - void _setUniform(int32_t location, float value) const; + GPAPI void _setUniform(int32_t location, float value) const; - void _setUniform(int32_t location, float v1, float v2) const; + GPAPI void _setUniform(int32_t location, float v1, float v2) const; - void _setUniform(int32_t location, float v1, float v2, float v3) const; + GPAPI void _setUniform(int32_t location, float v1, float v2, float v3) const; - void _setUniform(int32_t location, float v1, float v2, float v3, float v4) const; + GPAPI void _setUniform(int32_t location, float v1, float v2, float v3, float v4) const; - void _setUniform(int32_t location, double value) const; + GPAPI void _setUniform(int32_t location, double value) const; - void _setUniform(int32_t location, double v1, double v2) const; + GPAPI void _setUniform(int32_t location, double v1, double v2) const; - void _setUniform(int32_t location, double v1, double v2, double v3) const; + GPAPI void _setUniform(int32_t location, double v1, double v2, double v3) const; - void _setUniform(int32_t location, double v1, double v2, double v3, double v4) const; + GPAPI void _setUniform(int32_t location, double v1, double v2, double v3, double v4) const; - void _setUniform(int32_t location, int32_t value) const; + GPAPI void _setUniform(int32_t location, int32_t value) const; - void _setUniform(int32_t location, int32_t v1, int32_t v2) const; + GPAPI void _setUniform(int32_t location, int32_t v1, int32_t v2) const; - void _setUniform(int32_t location, int32_t v1, int32_t v2, int32_t v3) const; + GPAPI void _setUniform(int32_t location, int32_t v1, int32_t v2, int32_t v3) const; - void _setUniform(int32_t location, int32_t v1, int32_t v2, int32_t v3, int32_t v4) const; + GPAPI void _setUniform(int32_t location, int32_t v1, int32_t v2, int32_t v3, int32_t v4) const; - void _setUniform(int32_t location, uint32_t value) const; + GPAPI void _setUniform(int32_t location, uint32_t value) const; - void _setUniform(int32_t location, uint32_t v1, uint32_t v2) const; + GPAPI void _setUniform(int32_t location, uint32_t v1, uint32_t v2) const; - void _setUniform(int32_t location, uint32_t v1, uint32_t v2, uint32_t v3) const; + GPAPI void _setUniform(int32_t location, uint32_t v1, uint32_t v2, uint32_t v3) const; - void _setUniform(int32_t location, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4) const; + GPAPI void _setUniform(int32_t location, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4) const; - void _setUniform(int32_t location, const glm::mat2 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat2 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat3 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat3 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat4 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat4 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat2x3 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat2x3 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat3x2 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat3x2 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat2x4 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat2x4 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat4x2 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat4x2 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat3x4 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat3x4 &value, bool transpose = false) const; - void _setUniform(int32_t location, const glm::mat4x3 &value, bool transpose = false) const; + GPAPI void _setUniform(int32_t location, const glm::mat4x3 &value, bool transpose = false) const; - void _setUniform(int32_t location, int32_t count, float *value) const; + GPAPI void _setUniform(int32_t location, int32_t count, float *value) const; - void _setUniform(int32_t location, int32_t count, double *value) const; + GPAPI void _setUniform(int32_t location, int32_t count, double *value) const; - void _setUniform(int32_t location, int32_t count, uint32_t *value) const; + GPAPI void _setUniform(int32_t location, int32_t count, uint32_t *value) const; - void _setUniform(int32_t location, int32_t count, int32_t *value) const; + GPAPI void _setUniform(int32_t location, int32_t count, int32_t *value) const; - int32_t _getUniform(const char *name) const; + [[nodiscard]] GPAPI int32_t _getUniform(const char *name) const; }; } diff --git a/src/goopylib/texture/Bitmap.h b/src/goopylib/texture/Bitmap.h index 96343031..c6b7df31 100644 --- a/src/goopylib/texture/Bitmap.h +++ b/src/goopylib/texture/Bitmap.h @@ -13,13 +13,13 @@ namespace gp { GPAPI ~Bitmap(); - GPAPI uint32_t getWidth() const; + [[nodiscard]] GPAPI uint32_t getWidth() const; - GPAPI uint32_t getHeight() const; + [[nodiscard]] GPAPI uint32_t getHeight() const; - GPAPI uint32_t getChannels() const; + [[nodiscard]] GPAPI uint32_t getChannels() const; - GPAPI uint8_t* getData() const; + [[nodiscard]] GPAPI uint8_t* getData() const; GPAPI void saveBitmap(const std::string& filepath) const; @@ -31,10 +31,10 @@ namespace gp { bool m_IsImage = false; uint8_t *m_Data = nullptr; - Bitmap() = default; + GPAPI Bitmap() = default; - Bitmap(uint32_t width, uint32_t height, uint32_t channels, uint8_t *data); + GPAPI Bitmap(uint32_t width, uint32_t height, uint32_t channels, uint8_t *data); - Bitmap(const char* filepath); + GPAPI Bitmap(const char* filepath); }; } diff --git a/src/goopylib/texture/Texture2D.h b/src/goopylib/texture/Texture2D.h index 9faa9533..b254797e 100644 --- a/src/goopylib/texture/Texture2D.h +++ b/src/goopylib/texture/Texture2D.h @@ -12,7 +12,9 @@ namespace gp { friend class TextureAtlas; public: - ~Texture2D(); + GPAPI Texture2D (const Texture2D&) = delete; + + GPAPI ~Texture2D(); GPAPI void bind(uint32_t slot) const; @@ -28,7 +30,7 @@ namespace gp { GPAPI static void init(); - GPAPI static int32_t getTextureSlots(); + [[nodiscard]] GPAPI static int32_t getTextureSlots(); private: uint32_t m_Width = 0; @@ -39,14 +41,12 @@ namespace gp { static int32_t s_TextureSlots; - Texture2D(uint32_t width, uint32_t height, uint32_t channels, uint8_t *data = nullptr); + GPAPI Texture2D(uint32_t width, uint32_t height, uint32_t channels, uint8_t *data = nullptr); - Texture2D(const Bitmap& bitmap); - - GPAPI Texture2D (const Texture2D&) = delete; + GPAPI Texture2D(const Bitmap& bitmap); - uint32_t _getDataFormat() const; + [[nodiscard]] GPAPI uint32_t _getDataFormat() const; - int32_t _getInternalFormat() const; + [[nodiscard]] GPAPI int32_t _getInternalFormat() const; }; } diff --git a/src/goopylib/texture/TextureAtlas.h b/src/goopylib/texture/TextureAtlas.h index d3f18408..1f876739 100644 --- a/src/goopylib/texture/TextureAtlas.h +++ b/src/goopylib/texture/TextureAtlas.h @@ -35,13 +35,13 @@ namespace gp { bool allowRotation = true, const packing::SortingFunction &sorting = packing::sortByShortSide(true)); - GPAPI std::vector> createTextureAtlas() const; + [[nodiscard]] GPAPI std::vector> createTextureAtlas() const; GPAPI static void init(); - GPAPI static int32_t getWidth(); + [[nodiscard]] GPAPI static int32_t getWidth(); - GPAPI static int32_t getHeight(); + [[nodiscard]] GPAPI static int32_t getHeight(); private: packing::shelf::ShelfPackingAlgorithm *m_PackingAlgorithm; @@ -50,6 +50,6 @@ namespace gp { static int32_t s_Width; static int32_t s_Height; - TextureAtlas(packing::shelf::ShelfPackingAlgorithm *packingAlgorithm = nullptr); + GPAPI TextureAtlas(packing::shelf::ShelfPackingAlgorithm *packingAlgorithm = nullptr); }; } diff --git a/vendor/glad/glad.h b/vendor/glad/glad.h index be9d10ff..572e1690 100755 --- a/vendor/glad/glad.h +++ b/vendor/glad/glad.h @@ -32,9 +32,9 @@ #define APIENTRY __stdcall #endif -#ifndef APIENTRY -#define APIENTRY -#endif +//#ifndef APIENTRY +//#define APIENTRY +//#endif #ifndef APIENTRYP #define APIENTRYP APIENTRY * #endif