From 56b5466f014d9f7c3662544713bd53670cd8e32f Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Wed, 23 Aug 2017 20:33:34 +0100 Subject: Applied modernize rules and fixed build. Applied clang-tidy modernize rules and fixed the CMakeLists.txt file so that it also linked against the SDL2 library. --- src/sprite.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/sprite.cpp') diff --git a/src/sprite.cpp b/src/sprite.cpp index e3d74982..4cdd2ecf 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -14,7 +14,7 @@ namespace yage { -Sprite::Sprite() {} +Sprite::Sprite() = default; Sprite::~Sprite() { if (vbo_id_ != 0) glDeleteBuffers(1, &vbo_id_); @@ -50,7 +50,7 @@ void Sprite::init(float x, float y, float width, float height, vertex_data[5].setPosition(x + width, y); vertex_data[5].setUv(1.f, 0.f); - for (int i = 0; i < 6; ++i) vertex_data[i].setColor(255, 0, 255, 255); + for (auto & i : vertex_data) i.setColor(255, 0, 255, 255); vertex_data[1].setColor(0, 255, 255, 255); vertex_data[4].setColor(255, 0, 0, 255); -- cgit From 5403490b941f7c031bf1aafdb91b1098f69edbf2 Mon Sep 17 00:00:00 2001 From: Yann Herklotz Date: Thu, 24 Aug 2017 00:21:07 +0100 Subject: Running clang-format over everything. Edited formatting and ran it over all the files. --- src/sprite.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'src/sprite.cpp') diff --git a/src/sprite.cpp b/src/sprite.cpp index 4cdd2ecf..92dd584c 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -12,23 +12,30 @@ #include -namespace yage { +namespace yage +{ Sprite::Sprite() = default; -Sprite::~Sprite() { - if (vbo_id_ != 0) glDeleteBuffers(1, &vbo_id_); +Sprite::~Sprite() +{ + if (vbo_id_ != 0) { + glDeleteBuffers(1, &vbo_id_); + } } void Sprite::init(float x, float y, float width, float height, - const std::string& texture_path) { + const std::string &texture_path) +{ x_ = x; y_ = y; width_ = width; height_ = height; texture_ = ResourceManager::getTexture(texture_path); - if (vbo_id_ == 0) glGenBuffers(1, &vbo_id_); + if (vbo_id_ == 0) { + glGenBuffers(1, &vbo_id_); + } Vertex vertex_data[6]; @@ -50,7 +57,9 @@ void Sprite::init(float x, float y, float width, float height, vertex_data[5].setPosition(x + width, y); vertex_data[5].setUv(1.f, 0.f); - for (auto & i : vertex_data) i.setColor(255, 0, 255, 255); + for (auto &i : vertex_data) { + i.setColor(255, 0, 255, 255); + } vertex_data[1].setColor(0, 255, 255, 255); vertex_data[4].setColor(255, 0, 0, 255); @@ -61,7 +70,8 @@ void Sprite::init(float x, float y, float width, float height, glBindBuffer(GL_ARRAY_BUFFER, 0); } -void Sprite::draw() { +void Sprite::draw() +{ glBindTexture(GL_TEXTURE_2D, texture_.id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id_); @@ -70,11 +80,11 @@ void Sprite::draw() { glEnableVertexAttribArray(2); glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), - (void*)offsetof(Vertex, position)); + (void *)offsetof(Vertex, position)); glVertexAttribPointer(1, 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(Vertex), - (void*)offsetof(Vertex, color)); + (void *)offsetof(Vertex, color)); glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), - (void*)offsetof(Vertex, uv)); + (void *)offsetof(Vertex, uv)); glDrawArrays(GL_TRIANGLES, 0, 6); glDisableVertexAttribArray(2); @@ -84,4 +94,4 @@ void Sprite::draw() { glBindBuffer(GL_ARRAY_BUFFER, 0); } -} // yage +} // yage -- cgit