Skip to content

Commit c51c428

Browse files
committed
hello_xr: clang-tidy
1 parent 817bdab commit c51c428

9 files changed

Lines changed: 179 additions & 113 deletions

src/tests/hello_xr/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ inline std::string Fmt(const char* fmt, ...) {
8585

8686
// The equivalent of C++17 std::size. A helper to get the dimension for an array.
8787
template <typename T, size_t Size>
88-
constexpr size_t ArraySize(const T (&)[Size]) noexcept {
88+
constexpr size_t ArraySize(const T (&/*unused*/)[Size]) noexcept {
8989
return Size;
9090
}
9191

src/tests/hello_xr/graphicsplugin_factory.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include <utility>
2+
13
#include "pch.h"
24
#include "common.h"
35
#include "options.h"
@@ -32,34 +34,36 @@ using GraphicsPluginFactory = std::function<std::shared_ptr<IGraphicsPlugin>(con
3234
std::map<std::string, GraphicsPluginFactory, IgnoreCaseStringLess> graphicsPluginMap = {
3335
// #ifdef XR_USE_GRAPHICS_API_OPENGL_ES
3436
// { "OpenGLES", [](const std::shared_ptr<Options>& options, std::shared_ptr<IPlatformPlugin> platformPlugin) {
35-
// return CreateGraphicsPlugin_OpenGLES(options, platformPlugin); } },
37+
// return CreateGraphicsPlugin_OpenGLES(options, std::move(platformPlugin)); } },
3638
// #endif
3739
#ifdef XR_USE_GRAPHICS_API_OPENGL
3840
{"OpenGL",
3941
[](const std::shared_ptr<Options>& options, std::shared_ptr<IPlatformPlugin> platformPlugin) {
40-
return CreateGraphicsPlugin_OpenGL(options, platformPlugin);
42+
return CreateGraphicsPlugin_OpenGL(options, std::move(platformPlugin));
4143
}},
4244
#endif
4345
#ifdef XR_USE_GRAPHICS_API_VULKAN
4446
{"Vulkan",
4547
[](const std::shared_ptr<Options>& options, std::shared_ptr<IPlatformPlugin> platformPlugin) {
46-
return CreateGraphicsPlugin_Vulkan(options, platformPlugin);
48+
return CreateGraphicsPlugin_Vulkan(options, std::move(platformPlugin));
4749
}},
4850
#endif
4951
#ifdef XR_USE_GRAPHICS_API_D3D11
50-
{"D3D11", [](const std::shared_ptr<Options>& options,
51-
std::shared_ptr<IPlatformPlugin> platformPlugin) { return CreateGraphicsPlugin_D3D11(options, platformPlugin); }},
52+
{"D3D11",
53+
[](const std::shared_ptr<Options>& options, std::shared_ptr<IPlatformPlugin> platformPlugin) {
54+
return CreateGraphicsPlugin_D3D11(options, std::move(platformPlugin));
55+
}},
5256
#endif
5357
// #ifdef XR_USE_GRAPHICS_API_D3D12
5458
// { "D3D12", [](const std::shared_ptr<Options>& options, std::shared_ptr<IPlatformPlugin> platformPlugin) {
55-
// return CreateGraphicsPlugin_D3D12(options, platformPlugin); } },
59+
// return CreateGraphicsPlugin_D3D12(options, std::move(platformPlugin)); } },
5660
// #endif
5761
};
5862
} // namespace
5963

6064
std::shared_ptr<IGraphicsPlugin> CreateGraphicsPlugin(const std::shared_ptr<Options>& options,
6165
std::shared_ptr<IPlatformPlugin> platformPlugin) {
62-
if (options->GraphicsPlugin.size() == 0) {
66+
if (options->GraphicsPlugin.empty()) {
6367
throw std::invalid_argument("No graphics API specified");
6468
}
6569

@@ -68,5 +72,5 @@ std::shared_ptr<IGraphicsPlugin> CreateGraphicsPlugin(const std::shared_ptr<Opti
6872
throw std::invalid_argument(Fmt("Unsupported graphics API '%s'", options->GraphicsPlugin.c_str()));
6973
}
7074

71-
return apiIt->second(options, platformPlugin);
75+
return apiIt->second(options, std::move(platformPlugin));
7276
}

src/tests/hello_xr/graphicsplugin_opengl.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static const char* FragmentShaderGlsl = R"_(
3939
)_";
4040

4141
struct OpenGLGraphicsPlugin : public IGraphicsPlugin {
42-
OpenGLGraphicsPlugin(const std::shared_ptr<Options>&, std::shared_ptr<IPlatformPlugin>){};
42+
OpenGLGraphicsPlugin(const std::shared_ptr<Options>& /*unused*/, const std::shared_ptr<IPlatformPlugin> /*unused*/&){};
4343

4444
OpenGLGraphicsPlugin(const OpenGLGraphicsPlugin&) = delete;
4545
OpenGLGraphicsPlugin& operator=(const OpenGLGraphicsPlugin&) = delete;
@@ -101,7 +101,8 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin {
101101
THROW("Unable to create GL context");
102102
}
103103

104-
GLint major = 0, minor = 0;
104+
GLint major = 0;
105+
GLint minor = 0;
105106
glGetIntegerv(GL_MAJOR_VERSION, &major);
106107
glGetIntegerv(GL_MINOR_VERSION, &minor);
107108

@@ -179,7 +180,7 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin {
179180
glEnableVertexAttribArray(m_vertexAttribColor);
180181
glBindBuffer(GL_ARRAY_BUFFER, m_cubeVertexBuffer);
181182
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_cubeIndexBuffer);
182-
glVertexAttribPointer(m_vertexAttribCoords, 3, GL_FLOAT, GL_FALSE, sizeof(Geometry::Vertex), 0);
183+
glVertexAttribPointer(m_vertexAttribCoords, 3, GL_FLOAT, GL_FALSE, sizeof(Geometry::Vertex), nullptr);
183184
glVertexAttribPointer(m_vertexAttribColor, 3, GL_FLOAT, GL_FALSE, sizeof(Geometry::Vertex),
184185
reinterpret_cast<const void*>(sizeof(XrVector3f)));
185186
}
@@ -253,7 +254,8 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin {
253254

254255
// This back-buffer has no cooresponding depth-stencil texture, so create one with matching dimensions.
255256

256-
GLint width, height;
257+
GLint width;
258+
GLint height;
257259
glBindTexture(GL_TEXTURE_2D, colorTexture);
258260
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);
259261
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height);
@@ -328,7 +330,7 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin {
328330
glUniformMatrix4fv(m_modelViewProjectionUniformLocation, 1, GL_FALSE, reinterpret_cast<const GLfloat*>(&mvp));
329331

330332
// Draw the cube.
331-
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(ArraySize(Geometry::c_cubeIndices)), GL_UNSIGNED_SHORT, 0);
333+
glDrawElements(GL_TRIANGLES, static_cast<GLsizei>(ArraySize(Geometry::c_cubeIndices)), GL_UNSIGNED_SHORT, nullptr);
332334
}
333335

334336
glBindVertexArray(0);
@@ -337,7 +339,9 @@ struct OpenGLGraphicsPlugin : public IGraphicsPlugin {
337339

338340
// Swap our window every other eye for RenderDoc
339341
static int everyOther = 0;
340-
if (everyOther++ & 1) ksGpuWindow_SwapBuffers(&window);
342+
if ((everyOther++ & 1) != 0) {
343+
ksGpuWindow_SwapBuffers(&window);
344+
}
341345
}
342346

343347
private:

0 commit comments

Comments
 (0)