Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ modernization. Allow compiling for newer compilers. #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/base/String.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ std::string& String::trim(std::string& string)
std::string& String::ltrim(std::string& string)
{
string.erase(string.begin(),
std::find_if(string.begin(), string.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
std::find_if(string.begin(), string.end(), std::not1(std::function<int(int)>(std::isspace))));
return string;
}

std::string& String::rtrim(std::string& string)
{
string.erase(std::find_if(string.rbegin(), string.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(),
string.erase(std::find_if(string.rbegin(), string.rend(), std::not1(std::function<int(int)>(std::isspace))).base(),
string.end());
return string;
}
Expand All @@ -59,7 +59,7 @@ bool String::startsWith(const std::string& string, const std::string& prefix)
result = false;

} else {
for (unsigned int i = 0; i < prefix.size(); ++i) {
for (size_t i = 0; i < prefix.size(); ++i) {
if (string[i] != prefix[i]) {
result = false;
break;
Expand All @@ -78,9 +78,9 @@ bool String::endsWith(const std::string& string, const std::string& sufix)
result = false;

} else {
unsigned int offset = string.size() - sufix.size();
size_t offset = string.size() - sufix.size();

for (unsigned int i = 0; i < sufix.size(); ++i) {
for (size_t i = 0; i < sufix.size(); ++i) {
if (string[i + offset] != sufix[i]) {
result = false;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/base/vkx/QueueManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ std::vector<vk::DeviceQueueCreateInfo> QueueManager::createInfos(const vk::Insta
}

if (queueFamilyProperties[queueFamilyIndex].queueFlags & vk::QueueFlagBits::eGraphics) {
queueCreateInfos.push_back({{}, queueFamilyIndex, priorities.size(), priorities.data()});
queueCreateInfos.push_back({{}, queueFamilyIndex, static_cast<uint32_t>(priorities.size()), priorities.data()});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tests/common/TerrainLoD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace {
uint32_t indexOf(const tests::common::Heightmap& heightmap, std::size_t x, std::size_t y)
{
return heightmap.getSize().x * y + x;
return static_cast<uint32_t>(heightmap.getSize().x * y + x);
}

std::size_t pushQuadIndices(const tests::common::Heightmap& heightmap,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test1/gl/MultithreadedBallsSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void MultithreadedBallsSceneTest::initVBO()

void MultithreadedBallsSceneTest::initVAO()
{
vao_.setDrawCount(vertices().size());
vao_.setDrawCount(static_cast<GLsizei>(vertices().size()));
vao_.setDrawTarget(base::gl::VertexArray::DrawTarget::Triangles);

vao_.bind();
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test1/gl/SimpleBallsSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void SimpleBallsSceneTest::initVBO()

void SimpleBallsSceneTest::initVAO()
{
vao_.setDrawCount(vertices().size());
vao_.setDrawCount(static_cast<GLsizei>(vertices().size()));
vao_.setDrawTarget(base::gl::VertexArray::DrawTarget::Triangles);

vao_.bind();
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test2/gl/TerrainSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void TerrainSceneTest::run()
_program["MVP"] = currentMVP();
{
auto renderChunk = [](std::size_t count, std::ptrdiff_t offset) {
glDrawElements(GL_TRIANGLES, count, GL_UNSIGNED_INT, (const GLvoid*)offset);
glDrawElements(GL_TRIANGLES, static_cast<uint32_t>(count), GL_UNSIGNED_INT, (const GLvoid*)offset);
};
terrain().executeLoD(currentPosition(), renderChunk);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test2/vk/MultithreadedTerrainSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void MultithreadedTerrainSceneTest::prepareSecondaryCommandBuffer(std::size_t th
{
auto indexSize = sizeof(terrain().indices().front());
auto renderChunk = [&cmdBuffer, indexSize](std::size_t count, std::ptrdiff_t offset) {
cmdBuffer.drawIndexed(count, 1, offset / indexSize, 0, 0);
cmdBuffer.drawIndexed(static_cast<uint32_t>(count), 1, static_cast<uint32_t>(offset / indexSize), 0, 0);
};
// TODO: think on how to extend this beyond 4-threads
terrain().executeLoD(currentPosition(), renderChunk, threadIndex);
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test2/vk/TerrainSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void TerrainSceneTest::prepareCommandBuffer(std::size_t frameIndex) const
{
auto indexSize = sizeof(terrain().indices().front());
auto renderChunk = [&cmdBuffer, indexSize](std::size_t count, std::ptrdiff_t offset) {
cmdBuffer.drawIndexed(count, 1, offset / indexSize, 0, 0);
cmdBuffer.drawIndexed(static_cast<uint32_t>(count), 1, static_cast<uint32_t>(offset / indexSize), 0, 0);
};
terrain().executeLoD(currentPosition(), renderChunk);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test3/gl/ShadowMappingSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ void ShadowMappingSceneTest::initVBO(const common::RenderObject& renderObject, G
void ShadowMappingSceneTest::initVAO(const common::RenderObject& renderObject, GLRenderObject& glRenderObject)
{
glRenderObject.vao.setDrawTarget(base::gl::VertexArray::DrawTarget::Triangles);
glRenderObject.vao.setDrawCount(renderObject.vertices.size());
glRenderObject.vao.setDrawCount(static_cast<GLsizei>(renderObject.vertices.size()));

glRenderObject.vao.bind();
glRenderObject.vao.attachVBO(&glRenderObject.vbo);
Expand Down
4 changes: 2 additions & 2 deletions src/tests/test3/vk/MultithreadedShadowMappingSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ void MultithreadedShadowMappingSceneTest::prepareSecondaryCommandBuffer(std::siz
cmdBuffer.pushConstants(pass.pipelineLayout, vk::ShaderStageFlagBits::eVertex, 0, sizeof(MVP), &MVP);

cmdBuffer.bindVertexBuffers(0, {{renderObject.vbo.buffer}}, {{0}});
cmdBuffer.draw(renderObject.drawCount, 1, 0, 0);
cmdBuffer.draw(static_cast<uint32_t>(renderObject.drawCount), 1, 0, 0);
}

cmdBuffer.end();
Expand Down Expand Up @@ -770,7 +770,7 @@ void MultithreadedShadowMappingSceneTest::prepareSecondaryCommandBuffer(std::siz
&matrices);

cmdBuffer.bindVertexBuffers(0, {{renderObject.vbo.buffer}}, {{0}});
cmdBuffer.draw(renderObject.drawCount, 1, 0, 0);
cmdBuffer.draw(static_cast<uint32_t>(renderObject.drawCount), 1, 0, 0);
}

cmdBuffer.end();
Expand Down
4 changes: 2 additions & 2 deletions src/tests/test3/vk/ShadowMappingSceneTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void ShadowMappingSceneTest::prepareCommandBuffer(std::size_t frameIndex) const
cmdBuffer.pushConstants(pass.pipelineLayout, vk::ShaderStageFlagBits::eVertex, 0, sizeof(MVP), &MVP);

cmdBuffer.bindVertexBuffers(0, {{renderObject.vbo.buffer}}, {{0}});
cmdBuffer.draw(renderObject.drawCount, 1, 0, 0);
cmdBuffer.draw(static_cast<uint32_t>(renderObject.drawCount), 1, 0, 0);
}

cmdBuffer.endRenderPass();
Expand Down Expand Up @@ -759,7 +759,7 @@ void ShadowMappingSceneTest::prepareCommandBuffer(std::size_t frameIndex) const
&matrices);

cmdBuffer.bindVertexBuffers(0, {{renderObject.vbo.buffer}}, {{0}});
cmdBuffer.draw(renderObject.drawCount, 1, 0, 0);
cmdBuffer.draw(static_cast<uint32_t>(renderObject.drawCount), 1, 0, 0);
}

cmdBuffer.endRenderPass();
Expand Down
2 changes: 1 addition & 1 deletion src/tests/test4/gl/InitializationTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void InitializationTest::initVBO()

void InitializationTest::initVAO()
{
vao_.setDrawCount(vertices().size());
vao_.setDrawCount(static_cast<GLsizei>(vertices().size()));
vao_.setDrawTarget(base::gl::VertexArray::DrawTarget::Triangles);

vao_.bind();
Expand Down