Skip to content

Commit

Permalink
Clang-based modifications, tested with MSVS 2019 16.11.8 using C++ cl…
Browse files Browse the repository at this point in the history
…ang tools for Windows (12.0.0).

I updated the file versions on the previous push of source code.

The DX11Engine.h file needed the "override" modifier.

GL45Engine.cpp has "(char*)0+offset", which I modified to use reinterpret_cast.

GL45InputLayout constructor has an unused parameter, removed it.

Added braces to initialize subobjects in MarchingCubes.h.

In RootsBisection2.h, the YFunction lambda had a 'this' parameter but did not use it, removed the parameter.

WICFileIONative.cpp uses PROPBAG2 and VARIANT which clang complained about in multiple ways. I made enough changes to get the file to compile. The code probably needs to use the CCom* wrapper to encapsulate VARIANT. Better yet is for Microsoft to rewrite the Windows SDK header files to eliminate the code analysis complaints.

Cylinder3.h has a mechanism similar to Cone3.h to distinguish between finite and infinite cylinders.

I clarified a comment in AlignedBox.h about vertex extraction.
  • Loading branch information
davideberly committed Dec 21, 2021
1 parent 75cfcec commit 5b88fa7
Show file tree
Hide file tree
Showing 16 changed files with 290 additions and 303 deletions.
2 changes: 1 addition & 1 deletion GTE/Applications/GLX/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#pragma once

Expand Down
3 changes: 1 addition & 2 deletions GTE/Applications/GLX/WindowSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#include <Applications/GTApplicationsPCH.h>
#include <Applications/GLX/WindowSystem.h>
Expand All @@ -27,7 +27,6 @@ WindowSystem::~WindowSystem()

WindowSystem::WindowSystem()
:
// mDisplayName("GTEngineWindow"), /*< Unused variables */
mDisplay(nullptr)
{
// Connect to the X server.
Expand Down
3 changes: 1 addition & 2 deletions GTE/Applications/GLX/WindowSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#pragma once

Expand Down Expand Up @@ -48,7 +48,6 @@ namespace gte
// Window creation and destruction.
void CreateFrom(Window::Parameters& parameters);

// char const* mDisplayName; /*< Unused variable */
_XDisplay* mDisplay;
std::map<unsigned long, std::shared_ptr<Window>> mWindowMap;
};
Expand Down
19 changes: 7 additions & 12 deletions GTE/Applications/MSW/WICFileIONative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.7.2021.05.27
// Version: 4.7.2021.12.20

#include <Applications/GTApplicationsPCH.h>
#include <Applications/MSW/WICFileIONative.h>
Expand Down Expand Up @@ -439,15 +439,16 @@ void WICFileIONative::SaveTo(std::string const& filename, uint32_t inFormat,
throw std::runtime_error("wicEncoder->CreateNewFrame failed.");
}

// Set the options for the PNG encoder.
PROPBAG2 option{};
VARIANT varValue{};
ZeroMemory(&option, sizeof(option));
VariantInit(&varValue);

if (imageQuality == -1.0f)
{
// Set the options for the PNG encoder.
PROPBAG2 option = { 0 };
VARIANT varValue;

// Default subsampling.
option.pstrName = const_cast<LPOLESTR>(L"InterlaceOption");
VariantInit(&varValue);
varValue.vt = VT_BOOL;
varValue.boolVal = FALSE;
hr = wicPropertyBag->Write(1, &option, &varValue);
Expand All @@ -458,7 +459,6 @@ void WICFileIONative::SaveTo(std::string const& filename, uint32_t inFormat,

// Disable filtering.
option.pstrName = const_cast<LPOLESTR>(L"FilterOption");
VariantInit(&varValue);
varValue.vt = VT_UI1;
varValue.bVal = WICPngFilterNone;
hr = wicPropertyBag->Write(1, &option, &varValue);
Expand All @@ -469,13 +469,8 @@ void WICFileIONative::SaveTo(std::string const& filename, uint32_t inFormat,
}
else
{
// Set the options for the PNG encoder.
PROPBAG2 option = { 0 };
VARIANT varValue;

// Set image quality, a number in [0,1].
option.pstrName = const_cast<LPOLESTR>(L"ImageQuality");
VariantInit(&varValue);
varValue.vt = VT_R4;
varValue.fltVal = imageQuality;
hr = wicPropertyBag->Write(1, &option, &varValue);
Expand Down
6 changes: 3 additions & 3 deletions GTE/Graphics/DX11/DX11Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2020.04.12
// Version: 4.0.2021.12.20

#pragma once

Expand Down Expand Up @@ -224,14 +224,14 @@ namespace gte

// The function returns 'true' when the depth range is [0,1] (DirectX)
// or 'false' when the depth range is [-1,1] (OpenGL).
virtual bool HasDepthRange01() const
virtual bool HasDepthRange01() const override
{
return true;
}

// Append the extension of the shader file to 'name' (.hlsl for DirectX,
// .glsl for OpenGL).
virtual std::string GetShaderName(std::string const& name) const
virtual std::string GetShaderName(std::string const& name) const override
{
return name + ".hlsl";
}
Expand Down
7 changes: 3 additions & 4 deletions GTE/Graphics/GL45/GL45.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2021.11.11
// Version: 4.0.2021.12.20

#include <Graphics/GL45/GL45.h>
#include <cassert>
Expand All @@ -14,9 +14,6 @@
#include <vector>

// Support for versioning.
// int constexpr OPENGL_VERSION_NONE = 0; /*< Unused variable */
// int constexpr OPENGL_VERSION_1_0 = 10; /*< Unused variable */
int constexpr OPENGL_VERSION_1_1 = 11;
int constexpr OPENGL_VERSION_1_2 = 12;
int constexpr OPENGL_VERSION_1_3 = 13;
int constexpr OPENGL_VERSION_1_4 = 14;
Expand Down Expand Up @@ -127,6 +124,8 @@ static void ReportGLNullFunction(const char* glFunction)

#if !defined(GTE_USE_MSWINDOWS)

int constexpr OPENGL_VERSION_1_1 = 11;

// GL_VERSION_1_0

static PFNGLCULLFACEPROC sglCullFace = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions GTE/Graphics/GL45/GL45Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2021.11.11
// Version: 4.0.2021.12.20

#include <Graphics/GL45/GTGraphicsGL45PCH.h>
#include <Graphics/FontArialW400H18.h>
Expand Down Expand Up @@ -213,7 +213,7 @@ uint64_t GL45Engine::DrawPrimitive(VertexBuffer const* vbuffer, IndexBuffer cons
unsigned int offset = ibuffer->GetOffset();
if (ibuffer->IsIndexed())
{
void const* data = (char*)0 + static_cast<size_t>(indexSize) * static_cast<size_t>(offset);
void const* data = reinterpret_cast<void const*>(static_cast<size_t>(indexSize) * static_cast<size_t>(offset));
glDrawRangeElements(topology, 0, numActiveVertices - 1,
static_cast<GLsizei>(numActiveIndices), indexType, data);
}
Expand Down Expand Up @@ -1223,7 +1223,7 @@ void GL45Engine::Execute(std::shared_ptr<ComputeProgram> const& program,
auto glslProgram = std::dynamic_pointer_cast<GLSLComputeProgram>(program);
if (glslProgram && numXGroups > 0 && numYGroups > 0 && numZGroups > 0)
{
auto cshader = glslProgram->GetComputeShader();
auto const& cshader = glslProgram->GetComputeShader();
auto programHandle = glslProgram->GetProgramHandle();
if (cshader && programHandle > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion GTE/Graphics/GL45/GL45Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#pragma once

Expand Down
5 changes: 2 additions & 3 deletions GTE/Graphics/GL45/GL45InputLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#include <Graphics/GL45/GTGraphicsGL45PCH.h>
#include <Mathematics/Logger.h>
Expand All @@ -16,10 +16,9 @@ GL45InputLayout::~GL45InputLayout()
glDeleteVertexArrays(1, &mVArrayHandle);
}

GL45InputLayout::GL45InputLayout(GLuint programHandle, GLuint vbufferHandle,
GL45InputLayout::GL45InputLayout(GLuint, GLuint vbufferHandle,
VertexBuffer const* vbuffer)
:
// mProgramHandle(programHandle), /*< Unused variable */
mVBufferHandle(vbufferHandle),
mNumAttributes(0)
{
Expand Down
3 changes: 1 addition & 2 deletions GTE/Graphics/GL45/GL45InputLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#pragma once

Expand All @@ -24,7 +24,6 @@ namespace gte
void Disable();

private:
// GLuint mProgramHandle; /*< Unused variable */
GLuint mVBufferHandle;
GLuint mVArrayHandle;

Expand Down
2 changes: 1 addition & 1 deletion GTE/Graphics/GraphicsEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#pragma once

Expand Down
5 changes: 1 addition & 4 deletions GTE/Graphics/MorphController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2019.08.13
// Version: 4.0.2021.12.20

#include <Graphics/GTGraphicsPCH.h>
#include <Graphics/MorphController.h>
Expand Down Expand Up @@ -109,12 +109,9 @@ bool MorphController::Update(double applicationTime)
float const* weights0 = &mWeights[key0 * mNumTargets];
float const* weights1 = &mWeights[key1 * mNumTargets];
Vector3<float> const* vertices = mVertices.data();
// float wsum0 = 0.0f, wsum1 = 0.0f; /*< Unused variables */
for (size_t n = 0; n < mNumTargets; ++n)
{
float w = oneMinusNormTime * weights0[n] + normTime * weights1[n];
// wsum0 += weights0[n]; /*< Unused variables */
// wsum1 += weights1[n]; /*< Unused variables */
combination = vbuffer->GetData();
for (size_t m = 0; m < mNumVertices; ++m)
{
Expand Down
5 changes: 3 additions & 2 deletions GTE/Mathematics/AlignedBox.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2021.08.01
// Version: 4.0.2021.12.20

#pragma once

Expand Down Expand Up @@ -57,7 +57,8 @@ namespace gte

// Compute the vertices of the box. If index i has the bit pattern
// i = b[N-1]...b[0], then the corner at index i is vertex[i], where
// vertex[i] = min[i] whern b[d] = 0 or max[i] when b[d] = 1.
// vertex[i][d] = min[d] whern b[d] = 0 or vertex[i][d = max[d] when
// b[d] = 1.
void GetVertices(std::array<Vector<N, T>, (1 << N)>& vertex) const
{
int32_t const imax = (1 << N);
Expand Down
3 changes: 1 addition & 2 deletions GTE/Mathematics/Cylinder3.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
// https://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Version: 4.0.2021.11.11
// Version: 4.0.2021.12.20

#pragma once

#include <Mathematics/Logger.h>
#include <Mathematics/Line.h>

// The cylinder axis is a line. The origin of the cylinder is chosen to be
Expand Down
Loading

0 comments on commit 5b88fa7

Please sign in to comment.