Fix GLEW clang-tidy issues

This commit is contained in:
Dan Paulat 2025-07-10 23:27:24 -05:00
parent 331b2d855f
commit a6f8547455
15 changed files with 176 additions and 95 deletions

View file

@ -30,8 +30,8 @@ static const std::string logPrefix_ = "scwx::qt::gl::draw::draw_item";
class DrawItem::Impl
{
public:
explicit Impl() {}
~Impl() {}
explicit Impl() = default;
~Impl() = default;
};
DrawItem::DrawItem() : p(std::make_unique<Impl>()) {}

View file

@ -186,6 +186,10 @@ void GeoIcons::Initialize()
glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, 0u, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aLatLong
glVertexAttribPointer(0,
2,
@ -261,6 +265,10 @@ void GeoIcons::Initialize()
reinterpret_cast<void*>(3 * sizeof(GLint)));
glEnableVertexAttribArray(7);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -857,10 +865,11 @@ void GeoIcons::Impl::Update(bool textureAtlasChanged)
// Buffer texture data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * textureBuffer_.size(),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * textureBuffer_.size()),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
lastTextureAtlasChanged_ = false;
}
@ -870,17 +879,19 @@ void GeoIcons::Impl::Update(bool textureAtlasChanged)
{
// Buffer vertex data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * currentIconBuffer_.size(),
currentIconBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * currentIconBuffer_.size()),
currentIconBuffer_.data(),
GL_DYNAMIC_DRAW);
// Buffer threshold data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[2]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLint) * currentIntegerBuffer_.size(),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLint) * currentIntegerBuffer_.size()),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
numVertices_ =
static_cast<GLsizei>(currentIconBuffer_.size() / kPointsPerVertex);

View file

@ -175,6 +175,10 @@ void GeoLines::Initialize()
nullptr,
GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aLatLong
glVertexAttribPointer(0,
2,
@ -238,6 +242,10 @@ void GeoLines::Initialize()
reinterpret_cast<void*>(3 * sizeof(GLint)));
glEnableVertexAttribArray(7);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -667,17 +675,19 @@ void GeoLines::Impl::Update()
{
// Buffer lines data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * currentLinesBuffer_.size(),
currentLinesBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * currentLinesBuffer_.size()),
currentLinesBuffer_.data(),
GL_DYNAMIC_DRAW);
// Buffer threshold data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLint) * currentIntegerBuffer_.size(),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLint) * currentIntegerBuffer_.size()),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
}
dirty_ = false;

View file

@ -140,6 +140,10 @@ void Icons::Initialize()
glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, 0u, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aVertex
glVertexAttribPointer(0,
2,
@ -197,6 +201,10 @@ void Icons::Initialize()
static_cast<void*>(0));
glEnableVertexAttribArray(2);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -689,10 +697,11 @@ void Icons::Impl::Update(bool textureAtlasChanged)
// Buffer texture data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * textureBuffer_.size(),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * textureBuffer_.size()),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
lastTextureAtlasChanged_ = false;
}
@ -702,10 +711,11 @@ void Icons::Impl::Update(bool textureAtlasChanged)
{
// Buffer vertex data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * currentIconBuffer_.size(),
currentIconBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * currentIconBuffer_.size()),
currentIconBuffer_.data(),
GL_DYNAMIC_DRAW);
numVertices_ =
static_cast<GLsizei>(currentIconBuffer_.size() / kPointsPerVertex);

View file

@ -63,14 +63,12 @@ class LinkedVectors::Impl
{
public:
explicit Impl(std::shared_ptr<GlContext> context) :
context_ {context}, geoLines_ {std::make_shared<GeoLines>(context)}
geoLines_ {std::make_shared<GeoLines>(context)}
{
}
~Impl() {}
std::shared_ptr<GlContext> context_;
bool borderEnabled_ {true};
bool visible_ {true};

View file

@ -182,6 +182,10 @@ void PlacefileIcons::Initialize()
glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, 0u, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aLatLong
glVertexAttribPointer(0,
2,
@ -252,6 +256,10 @@ void PlacefileIcons::Initialize()
// aDisplayed
glVertexAttribI1i(7, 1);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -649,10 +657,11 @@ void PlacefileIcons::Impl::Update(bool textureAtlasChanged)
// Buffer texture data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * textureBuffer_.size(),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * textureBuffer_.size()),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
}
// If buffers need updating
@ -660,17 +669,19 @@ void PlacefileIcons::Impl::Update(bool textureAtlasChanged)
{
// Buffer vertex data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * currentIconBuffer_.size(),
currentIconBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * currentIconBuffer_.size()),
currentIconBuffer_.data(),
GL_DYNAMIC_DRAW);
// Buffer threshold data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[2]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLint) * currentIntegerBuffer_.size(),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLint) * currentIntegerBuffer_.size()),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
numVertices_ =
static_cast<GLsizei>(currentIconBuffer_.size() / kPointsPerVertex);

View file

@ -160,6 +160,10 @@ void PlacefileImages::Initialize()
glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, 0u, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aLatLong
glVertexAttribPointer(0,
2,
@ -221,6 +225,10 @@ void PlacefileImages::Initialize()
// aDisplayed
glVertexAttribI1i(7, 1);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -446,10 +454,11 @@ void PlacefileImages::Impl::Update(bool textureAtlasChanged)
// Buffer texture data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * textureBuffer_.size(),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * textureBuffer_.size()),
textureBuffer_.data(),
GL_DYNAMIC_DRAW);
}
// If buffers need updating
@ -457,17 +466,19 @@ void PlacefileImages::Impl::Update(bool textureAtlasChanged)
{
// Buffer vertex data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * currentImageBuffer_.size(),
currentImageBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * currentImageBuffer_.size()),
currentImageBuffer_.data(),
GL_DYNAMIC_DRAW);
// Buffer threshold data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[2]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLint) * currentIntegerBuffer_.size(),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLint) * currentIntegerBuffer_.size()),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
numVertices_ =
static_cast<GLsizei>(currentImageBuffer_.size() / kPointsPerVertex);

View file

@ -148,6 +148,10 @@ void PlacefileLines::Initialize()
glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, 0u, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aLatLong
glVertexAttribPointer(0,
2,
@ -206,6 +210,10 @@ void PlacefileLines::Initialize()
// aDisplayed
glVertexAttribI1i(7, 1);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -470,17 +478,19 @@ void PlacefileLines::Impl::Update()
{
// Buffer lines data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * currentLinesBuffer_.size(),
currentLinesBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(float) * currentLinesBuffer_.size()),
currentLinesBuffer_.data(),
GL_DYNAMIC_DRAW);
// Buffer threshold data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLint) * currentIntegerBuffer_.size(),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLint) * currentIntegerBuffer_.size()),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
}
dirty_ = false;

View file

@ -173,6 +173,10 @@ void PlacefilePolygons::Initialize()
glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, 0u, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aScreenCoord
glVertexAttribPointer(0,
2,
@ -219,6 +223,10 @@ void PlacefilePolygons::Initialize()
reinterpret_cast<void*>(1 * sizeof(GLint)));
glEnableVertexAttribArray(4);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -316,17 +324,19 @@ void PlacefilePolygons::Impl::Update()
// Buffer vertex data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLfloat) * currentBuffer_.size(),
currentBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLfloat) * currentBuffer_.size()),
currentBuffer_.data(),
GL_DYNAMIC_DRAW);
// Buffer threshold data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLint) * currentIntegerBuffer_.size(),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLint) * currentIntegerBuffer_.size()),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
numVertices_ =
static_cast<GLsizei>(currentBuffer_.size() / kPointsPerVertex);

View file

@ -25,9 +25,8 @@ static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
class PlacefileText::Impl
{
public:
explicit Impl(const std::shared_ptr<GlContext>& context,
const std::string& placefileName) :
context_ {context}, placefileName_ {placefileName}
explicit Impl(const std::string& placefileName) :
placefileName_ {placefileName}
{
}
@ -43,8 +42,6 @@ public:
float x,
float y);
std::shared_ptr<GlContext> context_;
std::string placefileName_;
bool thresholded_ {false};
@ -70,9 +67,8 @@ public:
std::vector<std::shared_ptr<types::ImGuiFont>> newFonts_ {};
};
PlacefileText::PlacefileText(const std::shared_ptr<GlContext>& context,
const std::string& placefileName) :
DrawItem(), p(std::make_unique<Impl>(context, placefileName))
PlacefileText::PlacefileText(const std::string& placefileName) :
DrawItem(), p(std::make_unique<Impl>(placefileName))
{
}
PlacefileText::~PlacefileText() = default;

View file

@ -19,8 +19,7 @@ namespace draw
class PlacefileText : public DrawItem
{
public:
explicit PlacefileText(const std::shared_ptr<GlContext>& context,
const std::string& placefileName);
explicit PlacefileText(const std::string& placefileName);
~PlacefileText();
PlacefileText(const PlacefileText&) = delete;

View file

@ -117,6 +117,10 @@ void PlacefileTriangles::Initialize()
glBindBuffer(GL_ARRAY_BUFFER, p->vbo_[0]);
glBufferData(GL_ARRAY_BUFFER, 0u, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(modernize-use-nullptr)
// NOLINTBEGIN(performance-no-int-to-ptr)
// NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers)
// aScreenCoord
glVertexAttribPointer(0,
2,
@ -163,6 +167,10 @@ void PlacefileTriangles::Initialize()
reinterpret_cast<void*>(1 * sizeof(GLint)));
glEnableVertexAttribArray(4);
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers)
// NOLINTEND(performance-no-int-to-ptr)
// NOLINTEND(modernize-use-nullptr)
p->dirty_ = true;
}
@ -318,17 +326,19 @@ void PlacefileTriangles::Impl::Update()
// Buffer vertex data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[0]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLfloat) * currentBuffer_.size(),
currentBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLfloat) * currentBuffer_.size()),
currentBuffer_.data(),
GL_DYNAMIC_DRAW);
// Buffer threshold data
glBindBuffer(GL_ARRAY_BUFFER, vbo_[1]);
glBufferData(GL_ARRAY_BUFFER,
sizeof(GLint) * currentIntegerBuffer_.size(),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
glBufferData(
GL_ARRAY_BUFFER,
static_cast<GLsizeiptr>(sizeof(GLint) * currentIntegerBuffer_.size()),
currentIntegerBuffer_.data(),
GL_DYNAMIC_DRAW);
numVertices_ =
static_cast<GLsizei>(currentBuffer_.size() / kPointsPerVertex);

View file

@ -101,6 +101,8 @@ void Rectangle::Initialize()
glBufferData(
GL_ARRAY_BUFFER, sizeof(float) * BUFFER_LENGTH, nullptr, GL_DYNAMIC_DRAW);
// NOLINTBEGIN(performance-no-int-to-ptr)
glVertexAttribPointer(0,
3,
GL_FLOAT,
@ -117,6 +119,8 @@ void Rectangle::Initialize()
reinterpret_cast<void*>(3 * sizeof(float)));
glEnableVertexAttribArray(1);
// NOLINTEND(performance-no-int-to-ptr)
p->dirty_ = true;
}
@ -134,12 +138,14 @@ void Rectangle::Render(const QMapLibre::CustomLayerRenderParameters& params)
if (p->fillColor_.has_value())
{
// Draw fill
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
glDrawArrays(GL_TRIANGLES, 24, 6);
}
if (p->borderWidth_ > 0.0f)
{
// Draw border
// NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers)
glDrawArrays(GL_TRIANGLES, 0, 24);
}
}
@ -283,7 +289,7 @@ void Rectangle::Impl::Update()
glBufferData(GL_ARRAY_BUFFER,
sizeof(float) * BUFFER_LENGTH,
buffer,
static_cast<const void*>(buffer),
GL_DYNAMIC_DRAW);
dirty_ = false;

View file

@ -60,7 +60,7 @@ void GlContext::Impl::InitializeGL()
return;
}
GLenum error = glewInit();
const GLenum error = glewInit();
if (error != GLEW_OK)
{
logger_->error("glewInit failed: {}",