Skip to content

Commit

Permalink
chore: fixed MSVC W3 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomezpl committed Dec 5, 2023
1 parent 3d27975 commit 026c621
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,21 @@ target_link_libraries(LepusUtility_Tests GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(LepusGfx_Tests)
gtest_discover_tests(LepusSystem_Tests)
gtest_discover_tests(LepusUtility_Tests)
gtest_discover_tests(LepusUtility_Tests)

# Warnings
if(MSVC)
target_compile_options(LepusEngine PRIVATE /W3 /WX)
target_compile_options(LepusSystem PRIVATE /W3 /WX)
target_compile_options(LepusGfx PRIVATE /W3 /WX)
target_compile_options(LepusSystem_Tests PRIVATE /W3 /WX)
target_compile_options(LepusGfx_Tests PRIVATE /W3 /WX)
target_compile_options(LepusUtility_Tests PRIVATE /W3 /WX)
else()
target_compile_options(LepusEngine PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(LepusSystem PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(LepusGfx PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(LepusSystem_Tests PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(LepusGfx_Tests PRIVATE -Wall -Wextra -Wpedantic)
target_compile_options(LepusUtility_Tests PRIVATE -Wall -Wextra -Wpedantic)
endif()
3 changes: 3 additions & 0 deletions src/lepus/engine/ILogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace lepus
virtual void LogError(char* className, char* funcName, char* message, char* funcParams = "") = 0;
virtual void LogInfo(char* className, char* funcName, char* message, char* funcParams = "") = 0;
virtual void LogWarning(char* className, char* funcName, char* message, char* funcParams = "") = 0;

/// @brief Dummy virtual destructor. Unlikely it'll ever be needed but the compiler wants one anyway.
virtual ~ILogger() {}
};
}
}
2 changes: 1 addition & 1 deletion src/lepus/gfx/GraphicsEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ m_OutputInfo = {}; \
/// @param options API options used to initialise and create the API library wrapper. These are copied, so it is recommended to create options in stack.
void InitApi(GraphicsApiOptions* options);

#undef INIT_DEFAULT()
#undef INIT_DEFAULT

enum PixelFormat
{
Expand Down
2 changes: 1 addition & 1 deletion src/lepus/gfx/GraphicsEngine/Apis/ApiGL/ApiGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void GraphicsApiGL::Draw()
glBindBuffer(GL_ARRAY_BUFFER, m_Pipeline.vbo);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_Pipeline.ibo);

glDrawElements(GL_TRIANGLES, m_CubeGeometry.IndexCount(), GL_UNSIGNED_INT, 0);
glDrawElements(GL_TRIANGLES, (GLsizei)m_CubeGeometry.IndexCount(), GL_UNSIGNED_INT, 0);
}

void GraphicsApiGL::ClearFrameBuffer(float r, float g, float b)
Expand Down
2 changes: 1 addition & 1 deletion src/lepus/gfx/GraphicsEngine/Apis/ApiGL/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace lepus
template<typename TUniformValue> class GLUniformBinding : public lepus::gfx::UniformBinding<GLint, TUniformValue>
{
public:
GLUniformBinding(size_t location) : UniformBinding<GLint, TUniformValue>(location)
GLUniformBinding(GLint location) : UniformBinding<GLint, TUniformValue>(location)
{
// TODO: No idea why, but sometimes the location won't assign correctly, so we do this terribleness...
this->m_Location = location;
Expand Down
8 changes: 4 additions & 4 deletions tests/LUtility/MathTests/MatrixTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ TEST(MathMatrixTests, MatrixMultipliedByMatrixCorrectly)
13 14 15 16
*/
for (uint8_t i = 0; i < 16; i++) { matA.set(floor((float)i / (float)4), i % 4, float(i + 1)); }
for (uint8_t i = 0; i < 16; i++) { matA.set((i - (i % 4)) / 4, i % 4, float(i + 1)); }

/* Matrix B looks like this:
Expand All @@ -26,7 +26,7 @@ TEST(MathMatrixTests, MatrixMultipliedByMatrixCorrectly)
10 11 12 13
14 15 16 17
*/
for (uint8_t i = 0; i < 16; i++) { matB.set(floor((float)i / (float)4), i % 4, float(i + 2)); }
for (uint8_t i = 0; i < 16; i++) { matB.set((i - (i % 4)) / 4, i % 4, float(i + 2)); }

/* Expected results:
100 110 120 130
Expand All @@ -44,8 +44,8 @@ TEST(MathMatrixTests, MatrixMultipliedByMatrixCorrectly)
lepus::math::Matrix4x4 actual = matA.Multiply(matB);

// Make sure the original matrices are still correct - they should not be affected by the multiplication, as it's not in-place.
for (uint8_t i = 0; i < 16; i++) { ASSERT_FLOAT_EQ(matA.get(floor((float)i / (float)4), i % 4), (float)(i + 1)); }
for (uint8_t i = 0; i < 16; i++) { ASSERT_FLOAT_EQ(matB.get(floor((float)i / (float)4), i % 4), (float)(i + 2)); }
for (uint8_t i = 0; i < 16; i++) { ASSERT_FLOAT_EQ(matA.get((i - (i % 4)) / 4, i % 4), (float)(i + 1)); }
for (uint8_t i = 0; i < 16; i++) { ASSERT_FLOAT_EQ(matB.get((i - (i % 4)) / 4, i % 4), (float)(i + 2)); }

// Check that the multiplied result is correct.
for (uint8_t r = 0; r < 4; r++)
Expand Down

0 comments on commit 026c621

Please sign in to comment.