Skip to content

Commit

Permalink
Apply clang-tidy naming fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Oct 14, 2023
1 parent 2363498 commit b3ccb09
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 121 deletions.
7 changes: 6 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ Checks: >
cppcoreguidelines-*,
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-non-const-global-variables,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-macro-usage,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-pro-type-union-access,
hicpp-*,
Expand All @@ -31,7 +34,7 @@ Checks: >
performance-*,
readability-*,
-readability-identifier-naming,
readability-identifier-naming,
-readability-const-return-type,
-readability-identifier-length,
-readability-magic-numbers,
Expand All @@ -55,6 +58,8 @@ CheckOptions:
value: camelBack
- key: readability-identifier-naming.PrivateMemberPrefix
value: _
- key: readability-identifier-naming.PrivateMemberSuffix
value: ""
- key: readability-identifier-naming.EnumCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
Expand Down
2 changes: 1 addition & 1 deletion src/app/playground/gl_extensions/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ auto main() -> int
return EXIT_FAILURE;
}

auto *window = glfwCreateWindow(1280, 720, "Window", nullptr, nullptr);
auto* window = glfwCreateWindow(1280, 720, "Window", nullptr, nullptr);
glfwHideWindow(window);
glfwMakeContextCurrent(window);

Expand Down
8 changes: 4 additions & 4 deletions src/app/sandbox3D/demo_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace {
#if defined(MOCI_API_OPENGL_LEGACY)
constexpr auto shaderPrefix = "es2";
constexpr auto ShaderPrefix = "es2";
#else
constexpr auto shaderPrefix = "gl4";
constexpr auto ShaderPrefix = "gl4";
#endif

auto skyboxVertices = std::array{
Expand Down Expand Up @@ -82,7 +82,7 @@ void DemoLayer::onAttach()
_vertices.reserve(numVertices);

auto const path
= fmt::format("src/app/sandbox3D/assets/shader/{}_general.glsl", shaderPrefix);
= fmt::format("src/app/sandbox3D/assets/shader/{}_general.glsl", ShaderPrefix);
_shader = moci::RenderFactory::makeShader(path);
_shader->bind();

Expand Down Expand Up @@ -131,7 +131,7 @@ void DemoLayer::onAttach()
}

auto const skyBoxShaderPath
= fmt::format("src/app/sandbox3D/assets/shader/{}_skybox.glsl", shaderPrefix);
= fmt::format("src/app/sandbox3D/assets/shader/{}_skybox.glsl", ShaderPrefix);
_skyboxShader = moci::RenderFactory::makeShader(skyBoxShaderPath);
_skyboxShader->bind();
_skyboxShader->setInt("u_Skybox", 0);
Expand Down
4 changes: 2 additions & 2 deletions src/app/sandboxOpenGL/assets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#include <cstdint>

#if defined(MOCI_API_OPENGL_LEGACY)
constexpr auto shaderSuffix = "es2";
constexpr auto ShaderSuffix = "es2";
#else
constexpr auto shaderSuffix = "gl4";
constexpr auto ShaderSuffix = "gl4";
#endif

namespace assets {
Expand Down
2 changes: 1 addition & 1 deletion src/app/sandboxOpenGL/opengl_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ auto imGuiToGlmVec(ImVec2 const& input) -> glm::vec2 { return {input.x, input.y}

void OpenGLLayer::onAttach()
{
auto const path = fmt::format("assets/shader/basic_{}.glsl", shaderSuffix);
auto const path = fmt::format("assets/shader/basic_{}.glsl", ShaderSuffix);
auto samplers = std::array{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
_shader = moci::RenderFactory::makeShader(path);
_shader->bind();
Expand Down
2 changes: 1 addition & 1 deletion src/moci/application/glfw/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void GlfwWindow::init(WindowSpecs props)
ignoreUnused(mods);

WindowData const& data = *(WindowData*)glfwGetWindowUserPointer(window);
auto const key = static_cast<Key>(glfwKey);
auto const key = static_cast<Key>(glfwKey);
switch (action) {
case GLFW_PRESS: {
KeyPressedEvent event(key, 0);
Expand Down
13 changes: 8 additions & 5 deletions src/moci/core/benchmark/profile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Instrumentor
class InstrumentationTimer
{
public:
explicit InstrumentationTimer(char const* name) : _name(name)
explicit InstrumentationTimer(std::string_view name) : _name(name)
{
_startTimepoint = std::chrono::steady_clock::now();
}
Expand All @@ -167,15 +167,18 @@ class InstrumentationTimer
- std::chrono::time_point_cast<std::chrono::microseconds>(_startTimepoint)
.time_since_epoch();

Instrumentor::get().writeProfile(
{_name, highResStart, elapsedTime, std::this_thread::get_id()}
);
Instrumentor::get().writeProfile({
.Name = std::string{_name},
.Start = highResStart,
.ElapsedTime = elapsedTime,
.ThreadID = std::this_thread::get_id(),
});

_stopped = true;
}

private:
char const* _name;
std::string_view _name;
std::chrono::time_point<std::chrono::steady_clock> _startTimepoint;
bool _stopped{false};
};
Expand Down
8 changes: 4 additions & 4 deletions src/moci/events/types/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ enum EventCategory
};

#define EVENT_CLASS_TYPE(type) \
static EventType getStaticType() { return EventType::type; } \
virtual EventType getEventType() const override { return getStaticType(); } \
virtual std::string_view getName() const override { return #type; }
static auto getStaticType() -> EventType { return EventType::type; } \
virtual auto getEventType() const -> EventType override { return getStaticType(); } \
virtual auto getName() const -> std::string_view override { return #type; }

#define EVENT_CLASS_CATEGORY(category) \
virtual int getCategoryFlags() const override { return category; }
virtual auto getCategoryFlags() const -> int override { return category; }

class Event
{
Expand Down
9 changes: 5 additions & 4 deletions src/moci/render/opengl/common/shader_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

#include <moci/core/logging.hpp>

enum {
GL_FRAGMENT_SHADER = 0x8B30,
GL_VERTEX_SHADER = 0x8B31
enum
{
GL_FRAGMENT_SHADER = 0x8B30,
GL_VERTEX_SHADER = 0x8B31
};

namespace moci {
Expand Down Expand Up @@ -38,7 +39,7 @@ auto ShaderParser::splitSource(std::string const& sources) -> ShaderProgramSourc
MOCI_CORE_ASSERT(eol != std::string::npos, "Syntax error");

// Start of shader type name (after "#type " keyword)
auto const begin = pos + typeTokenLength + 1;
auto const begin = pos + typeTokenLength + 1;
std::string const type = sources.substr(begin, eol - begin);
MOCI_CORE_ASSERT(
shaderTypeFromString(type) != ShaderType::Unknown,
Expand Down
40 changes: 20 additions & 20 deletions src/moci/render/opengl/gl4/frame_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@

namespace moci {

OpenGLFramebuffer::OpenGLFramebuffer(FramebufferSpecs spec) : specs_(spec) { invalidate(); }
OpenGLFramebuffer::OpenGLFramebuffer(FramebufferSpecs spec) : _specs(spec) { invalidate(); }

OpenGLFramebuffer::~OpenGLFramebuffer() { deallocate(); }

void OpenGLFramebuffer::bind()
{
glBindFramebuffer(GL_FRAMEBUFFER, renderID_);
glViewport(0, 0, specs_.width, specs_.height);
glBindFramebuffer(GL_FRAMEBUFFER, _renderID);
glViewport(0, 0, _specs.width, _specs.height);
}

void OpenGLFramebuffer::unbind() { glBindFramebuffer(GL_FRAMEBUFFER, 0); }

void OpenGLFramebuffer::resize(std::uint32_t width, std::uint32_t height)
{
specs_.width = width;
specs_.height = height;
_specs.width = width;
_specs.height = height;
invalidate();
}

void OpenGLFramebuffer::invalidate()
{
if (renderID_ != 0) {
if (_renderID != 0) {
deallocate();
}

glCreateFramebuffers(1, &renderID_);
glBindFramebuffer(GL_FRAMEBUFFER, renderID_);
glCreateFramebuffers(1, &_renderID);
glBindFramebuffer(GL_FRAMEBUFFER, _renderID);

glCreateTextures(GL_TEXTURE_2D, 1, &colorAttachment_);
glBindTexture(GL_TEXTURE_2D, colorAttachment_);
glCreateTextures(GL_TEXTURE_2D, 1, &_colorAttachment);
glBindTexture(GL_TEXTURE_2D, _colorAttachment);
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_RGBA8,
specs_.width,
specs_.height,
_specs.width,
_specs.height,
0,
GL_RGBA,
GL_UNSIGNED_BYTE,
Expand All @@ -55,18 +55,18 @@ void OpenGLFramebuffer::invalidate()
GL_FRAMEBUFFER,
GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D,
colorAttachment_,
_colorAttachment,
0
);

glCreateTextures(GL_TEXTURE_2D, 1, &depthAttachment_);
glBindTexture(GL_TEXTURE_2D, depthAttachment_);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, specs_.width, specs_.height);
glCreateTextures(GL_TEXTURE_2D, 1, &_depthAttachment);
glBindTexture(GL_TEXTURE_2D, _depthAttachment);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_DEPTH24_STENCIL8, _specs.width, _specs.height);
glFramebufferTexture2D(
GL_FRAMEBUFFER,
GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D,
depthAttachment_,
_depthAttachment,
0
);

Expand All @@ -80,9 +80,9 @@ void OpenGLFramebuffer::invalidate()

void OpenGLFramebuffer::deallocate()
{
glDeleteFramebuffers(1, &renderID_);
glDeleteTextures(1, &colorAttachment_);
glDeleteTextures(1, &depthAttachment_);
glDeleteFramebuffers(1, &_renderID);
glDeleteTextures(1, &_colorAttachment);
glDeleteTextures(1, &_depthAttachment);
}
} // namespace moci

Expand Down
12 changes: 6 additions & 6 deletions src/moci/render/opengl/gl4/frame_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ class OpenGLFramebuffer : public Framebuffer

[[nodiscard]] auto getColorAttachmentRendererId() const -> std::uint32_t override
{
return colorAttachment_;
return _colorAttachment;
}

[[nodiscard]] auto getSpecification() const -> FramebufferSpecs const& override
{
return specs_;
return _specs;
}

private:
void invalidate();
void deallocate();

std::uint32_t renderID_ = 0;
std::uint32_t colorAttachment_ = 0;
std::uint32_t depthAttachment_ = 0;
FramebufferSpecs specs_ = {};
std::uint32_t _renderID = 0;
std::uint32_t _colorAttachment = 0;
std::uint32_t _depthAttachment = 0;
FramebufferSpecs _specs = {};
};

} // namespace moci
Expand Down
10 changes: 5 additions & 5 deletions src/moci/render/opengl/gl4/renderer_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace moci {

namespace {
auto MociToOpenGLDrawMode(RenderDrawMode const mode) noexcept -> int
auto mociToOpenGlDrawMode(RenderDrawMode const mode) noexcept -> int
{

switch (mode) {
Expand Down Expand Up @@ -47,7 +47,7 @@ auto MociToOpenGLDrawMode(RenderDrawMode const mode) noexcept -> int

} // namespace

void OpenGLMessageCallback(
void openGlMessageCallback(
unsigned source,
unsigned type,
unsigned id,
Expand Down Expand Up @@ -120,7 +120,7 @@ void OpenGLRendererAPI::drawArrays(
uint32_t count
)
{
auto const glDrawMode = MociToOpenGLDrawMode(mode);
auto const glDrawMode = mociToOpenGlDrawMode(mode);
glDrawArrays(glDrawMode, first, count);
}

Expand All @@ -130,7 +130,7 @@ void OpenGLRendererAPI::drawIndexed(
void* indices
)
{
auto const glDrawMode = MociToOpenGLDrawMode(mode);
auto const glDrawMode = mociToOpenGlDrawMode(mode);
glDrawElements(glDrawMode, count, GL_UNSIGNED_INT, indices);
}

Expand All @@ -139,7 +139,7 @@ void OpenGLRendererAPI::drawIndexed(
std::shared_ptr<VertexArray> const& vertexArray
)
{
auto const glDrawMode = MociToOpenGLDrawMode(mode);
auto const glDrawMode = mociToOpenGlDrawMode(mode);
glDrawElements(
glDrawMode,
vertexArray->getIndexBuffer()->getCount(),
Expand Down
Loading

0 comments on commit b3ccb09

Please sign in to comment.