From dd0158bcb389a5687c16ae8075574db5b7dd1954 Mon Sep 17 00:00:00 2001 From: TotallyNotElite <1yourexperiment@protonmail.com> Date: Tue, 4 Dec 2018 16:32:56 +0100 Subject: [PATCH] format --- .clang-format | 2 ++ include/glez/color.hpp | 4 ++-- include/glez/detail/font.hpp | 2 +- include/glez/detail/program.hpp | 2 +- include/glez/detail/record.hpp | 6 ++++-- include/glez/detail/render.hpp | 2 +- include/glez/detail/texture.hpp | 2 +- include/glez/draw.hpp | 13 +++++++----- include/glez/font.hpp | 2 +- include/glez/glez.hpp | 2 +- include/glez/picopng/picopng.hpp | 4 +++- include/glez/record.hpp | 2 +- include/glez/texture.hpp | 2 +- src/detail/font.cpp | 2 +- src/detail/program.cpp | 2 +- src/detail/record.cpp | 27 ++++++++++++++---------- src/detail/render.cpp | 2 +- src/detail/texture.cpp | 6 +++--- src/draw.cpp | 35 +++++++++++++++++++------------- src/font.cpp | 2 +- src/glez.cpp | 2 +- 21 files changed, 72 insertions(+), 51 deletions(-) mode change 100644 => 100755 .clang-format diff --git a/.clang-format b/.clang-format old mode 100644 new mode 100755 index 3e55846..751603a --- a/.clang-format +++ b/.clang-format @@ -10,6 +10,7 @@ AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: 'false' AllowShortLoopsOnASingleLine: 'false' BreakBeforeBraces: Allman +ColumnLimit: 0 ConstructorInitializerAllOnOneLineOrOnePerLine: 'false' Cpp11BracedListStyle: 'false' IndentCaseLabels: 'false' @@ -31,4 +32,5 @@ Standard: Auto TabWidth: '4' UseTab: Never + ... diff --git a/include/glez/color.hpp b/include/glez/color.hpp index c68af0c..9963249 100644 --- a/include/glez/color.hpp +++ b/include/glez/color.hpp @@ -35,5 +35,5 @@ constexpr rgba black(0, 0, 0); constexpr rgba red(255, 0, 0); constexpr rgba green(0, 255, 0); constexpr rgba blue(0, 0, 255); -} -} \ No newline at end of file +} // namespace color +} // namespace glez \ No newline at end of file diff --git a/include/glez/detail/font.hpp b/include/glez/detail/font.hpp index 94b6755..baa786a 100644 --- a/include/glez/detail/font.hpp +++ b/include/glez/detail/font.hpp @@ -29,4 +29,4 @@ void shutdown(); unsigned create(); font &get(unsigned handle); -} \ No newline at end of file +} // namespace glez::detail::font \ No newline at end of file diff --git a/include/glez/detail/program.hpp b/include/glez/detail/program.hpp index fca246f..b1328ee 100644 --- a/include/glez/detail/program.hpp +++ b/include/glez/detail/program.hpp @@ -29,4 +29,4 @@ void begin(); void end(); extern vertex_buffer_t *buffer; -}; \ No newline at end of file +}; // namespace glez::detail::program \ No newline at end of file diff --git a/include/glez/detail/record.hpp b/include/glez/detail/record.hpp index ed3fbac..4332511 100644 --- a/include/glez/detail/record.hpp +++ b/include/glez/detail/record.hpp @@ -32,11 +32,13 @@ public: ~RecordedCommands(); void reset(); - void store(glez::detail::render::vertex *vertices, size_t vcount, uint32_t *indices, size_t icount); + void store(glez::detail::render::vertex *vertices, size_t vcount, + uint32_t *indices, size_t icount); void bindTexture(glez::detail::texture::texture *tx); void bindFont(ftgl::texture_font_t *font); void render(); void end(); + protected: void cutSegment(); @@ -48,4 +50,4 @@ protected: extern RecordedCommands *currentRecord; extern bool isReplaying; -} \ No newline at end of file +} // namespace glez::detail::record \ No newline at end of file diff --git a/include/glez/detail/render.hpp b/include/glez/detail/render.hpp index 93a7daa..68b0575 100644 --- a/include/glez/detail/render.hpp +++ b/include/glez/detail/render.hpp @@ -23,4 +23,4 @@ void begin(); void end(); void bind(GLuint texture); -} \ No newline at end of file +} // namespace glez::detail::render \ No newline at end of file diff --git a/include/glez/detail/texture.hpp b/include/glez/detail/texture.hpp index a9c5eff..da4b82f 100644 --- a/include/glez/detail/texture.hpp +++ b/include/glez/detail/texture.hpp @@ -33,4 +33,4 @@ void shutdown(); unsigned create(); texture &get(unsigned handle); -} \ No newline at end of file +} // namespace glez::detail::texture \ No newline at end of file diff --git a/include/glez/draw.hpp b/include/glez/draw.hpp index 8e69b15..08fa88a 100644 --- a/include/glez/draw.hpp +++ b/include/glez/draw.hpp @@ -15,13 +15,16 @@ namespace glez::draw void line(float x, float y, float dx, float dy, rgba color, float thickness); void rect(float x, float y, float w, float h, rgba color); -void rect_outline(float x, float y, float w, float h, rgba color, float thickness); -void rect_textured(float x, float y, float w, float h, rgba color, texture &texture, - float tx, float ty, float tw, float th, float angle); -void circle(float x, float y, float radius, rgba color, float thickness, int steps); +void rect_outline(float x, float y, float w, float h, rgba color, + float thickness); +void rect_textured(float x, float y, float w, float h, rgba color, + texture &texture, float tx, float ty, float tw, float th, + float angle); +void circle(float x, float y, float radius, rgba color, float thickness, + int steps); void string(float x, float y, const std::string &string, font &font, rgba color, float *width, float *height); void outlined_string(float x, float y, const std::string &string, font &font, rgba color, rgba outline, float *width, float *height); -} \ No newline at end of file +} // namespace glez::draw \ No newline at end of file diff --git a/include/glez/font.hpp b/include/glez/font.hpp index ec0e4bc..751146d 100644 --- a/include/glez/font.hpp +++ b/include/glez/font.hpp @@ -42,4 +42,4 @@ protected: unsigned handle{ std::numeric_limits::max() }; }; -} \ No newline at end of file +} // namespace glez \ No newline at end of file diff --git a/include/glez/glez.hpp b/include/glez/glez.hpp index a07b7df..a6fcce3 100644 --- a/include/glez/glez.hpp +++ b/include/glez/glez.hpp @@ -16,4 +16,4 @@ void resize(int width, int height); void begin(); void end(); -}; \ No newline at end of file +}; // namespace glez \ No newline at end of file diff --git a/include/glez/picopng/picopng.hpp b/include/glez/picopng/picopng.hpp index 888b5c8..1464929 100644 --- a/include/glez/picopng/picopng.hpp +++ b/include/glez/picopng/picopng.hpp @@ -1,3 +1,5 @@ #pragma once #include -int decodePNG(unsigned char* &out_image, int& image_width, int& image_height, const unsigned char* in_png, size_t in_size, bool convert_to_rgba32 = true); +int decodePNG(unsigned char *&out_image, int &image_width, int &image_height, + const unsigned char *in_png, size_t in_size, + bool convert_to_rgba32 = true); diff --git a/include/glez/record.hpp b/include/glez/record.hpp index 8b9b569..a12212b 100644 --- a/include/glez/record.hpp +++ b/include/glez/record.hpp @@ -25,4 +25,4 @@ public: detail::record::RecordedCommands *commands{ nullptr }; }; -} \ No newline at end of file +} // namespace glez::record \ No newline at end of file diff --git a/include/glez/texture.hpp b/include/glez/texture.hpp index 5763e5e..6ebf4a6 100644 --- a/include/glez/texture.hpp +++ b/include/glez/texture.hpp @@ -57,4 +57,4 @@ protected: unsigned handle{ std::numeric_limits::max() }; }; -} \ No newline at end of file +} // namespace glez \ No newline at end of file diff --git a/src/detail/font.cpp b/src/detail/font.cpp index 5d950c6..728baca 100644 --- a/src/detail/font.cpp +++ b/src/detail/font.cpp @@ -93,4 +93,4 @@ font &get(unsigned handle) { return (*cache)[handle]; } -} +} // namespace glez::detail::font diff --git a/src/detail/program.cpp b/src/detail/program.cpp index 23f2e5b..224626d 100644 --- a/src/detail/program.cpp +++ b/src/detail/program.cpp @@ -153,4 +153,4 @@ void end() glUseProgram(0); } -} \ No newline at end of file +} // namespace glez::detail::program \ No newline at end of file diff --git a/src/detail/record.cpp b/src/detail/record.cpp index 5219675..cf21e2c 100644 --- a/src/detail/record.cpp +++ b/src/detail/record.cpp @@ -14,7 +14,7 @@ void RecordedCommands::render() { isReplaying = true; vertex_buffer_render_setup(vertex_buffer, GL_TRIANGLES); - for (const auto& i: segments) + for (const auto &i : segments) { if (i.texture) { @@ -31,32 +31,37 @@ void RecordedCommands::render() if (i.font->atlas->dirty) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, + GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, + GL_NEAREST); glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, i.font->atlas->width, i.font->atlas->height, 0, GL_RED, GL_UNSIGNED_BYTE, i.font->atlas->data); i.font->atlas->dirty = 0; } } - glDrawElements(GL_TRIANGLES, i.size, GL_UNSIGNED_INT, (void *)(i.start * 4)); + glDrawElements(GL_TRIANGLES, i.size, GL_UNSIGNED_INT, + (void *) (i.start * 4)); } vertex_buffer_render_finish(vertex_buffer); isReplaying = false; } -void -RecordedCommands::store(glez::detail::render::vertex *vertices, size_t vcount, - uint32_t *indices, size_t icount) +void RecordedCommands::store(glez::detail::render::vertex *vertices, + size_t vcount, uint32_t *indices, size_t icount) { vertex_buffer_push_back(vertex_buffer, vertices, vcount, indices, icount); } RecordedCommands::RecordedCommands() { - vertex_buffer = vertex_buffer_new("vertex:2f,tex_coord:2f,color:4f,drawmode:1i"); + vertex_buffer = + vertex_buffer_new("vertex:2f,tex_coord:2f,color:4f,drawmode:1i"); } RecordedCommands::~RecordedCommands() @@ -106,7 +111,7 @@ void RecordedCommands::end() RecordedCommands *currentRecord{ nullptr }; bool isReplaying{ false }; -} +} // namespace glez::detail::record glez::record::Record::Record() { diff --git a/src/detail/render.cpp b/src/detail/render.cpp index fd5844c..45bb95a 100644 --- a/src/detail/render.cpp +++ b/src/detail/render.cpp @@ -68,4 +68,4 @@ void bind(GLuint texture) glBindTexture(GL_TEXTURE_2D, texture); } } -} \ No newline at end of file +} // namespace glez::detail::render \ No newline at end of file diff --git a/src/detail/texture.cpp b/src/detail/texture.cpp index b70147e..313f11d 100644 --- a/src/detail/texture.cpp +++ b/src/detail/texture.cpp @@ -73,9 +73,9 @@ bool texture::load(const std::string &path) printf("Error loading texture, error code %i\n", error); return false; } - init = true; - bound = false; - id = 0; + init = true; + bound = false; + id = 0; return true; } diff --git a/src/draw.cpp b/src/draw.cpp index 9b9bc9f..a1758ca 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -110,10 +110,11 @@ void internal_draw_string(float x, float y, const std::string &string, size_y = glyph->height; if (glez::detail::record::currentRecord) - glez::detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6); + glez::detail::record::currentRecord->store(vertices, 4, + indices::rectangle, 6); else vertex_buffer_push_back(glez::detail::program::buffer, vertices, 4, - indices::rectangle, 6); + indices::rectangle, 6); } if (width) @@ -169,10 +170,11 @@ void line(float x, float y, float dx, float dy, rgba color, float thickness) vertices[0].position = { ex + nx - px, ey + ny - py }; if (detail::record::currentRecord) - detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6); + detail::record::currentRecord->store(vertices, 4, indices::rectangle, + 6); else ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4, - indices::rectangle, 6); + indices::rectangle, 6); } void rect(float x, float y, float w, float h, rgba color) @@ -191,13 +193,15 @@ void rect(float x, float y, float w, float h, rgba color) vertices[3].position = { x + w, y }; if (detail::record::currentRecord) - detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6); + detail::record::currentRecord->store(vertices, 4, indices::rectangle, + 6); else ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4, - indices::rectangle, 6); + indices::rectangle, 6); } -void rect_outline(float x, float y, float w, float h, rgba color, float thickness) +void rect_outline(float x, float y, float w, float h, rgba color, + float thickness) { rect(x, y, w, 1, color); rect(x, y, 1, h, color); @@ -205,7 +209,8 @@ void rect_outline(float x, float y, float w, float h, rgba color, float thicknes rect(x, y + h - 1, w, 1, color); } -void circle(float x, float y, float radius, rgba color, float thickness, int steps) +void circle(float x, float y, float radius, rgba color, float thickness, + int steps) { float px = 0; float py = 0; @@ -249,12 +254,13 @@ void outlined_string(float x, float y, const std::string &string, font &font, internal_draw_string(x, y, string, fnt, color, width, height); } -void rect_textured(float x, float y, float w, float h, rgba color, texture &texture, - float tx, float ty, float tw, float th, float angle) +void rect_textured(float x, float y, float w, float h, rgba color, + texture &texture, float tx, float ty, float tw, float th, + float angle) { if (!texture.isLoaded()) texture.load(); - + if (!texture.canLoad()) return; @@ -305,9 +311,10 @@ void rect_textured(float x, float y, float w, float h, rgba color, texture &text vertices[3].uv = { s1, t0 }; if (detail::record::currentRecord) - detail::record::currentRecord->store(vertices, 4, indices::rectangle, 6); + detail::record::currentRecord->store(vertices, 4, indices::rectangle, + 6); else ftgl::vertex_buffer_push_back(detail::program::buffer, vertices, 4, - indices::rectangle, 6); -} + indices::rectangle, 6); } +} // namespace glez::draw diff --git a/src/font.cpp b/src/font.cpp index 4ce850d..05da048 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -38,4 +38,4 @@ void font::stringSize(const std::string &string, float *width, float *height) auto &font = detail::font::get(handle); font.stringSize(string, width, height); } -} \ No newline at end of file +} // namespace glez \ No newline at end of file diff --git a/src/glez.cpp b/src/glez.cpp index a26af83..7863213 100644 --- a/src/glez.cpp +++ b/src/glez.cpp @@ -45,4 +45,4 @@ void preInit() detail::font::init(); detail::texture::init(); } -} \ No newline at end of file +} // namespace glez \ No newline at end of file