From e1d2e3066e01fc760fb0872e7877a848107a7ebe Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Fri, 28 Aug 2020 21:11:43 -0700 Subject: [PATCH] removed trailing whitespace --- CMakeLists.txt | 4 +- README.md | 4 +- private/blah/internal/platform_sdl2.cpp | 2 +- public/blah.h | 2 +- public/blah/containers/str.cpp | 14 +++---- public/blah/drawing/batch.cpp | 52 ++++++++++++------------- public/blah/graphics/graphics.h | 4 +- public/blah/images/aseprite.cpp | 2 +- public/blah/images/font.cpp | 8 ++-- public/blah/input/input.h | 2 +- public/blah/math/color.cpp | 22 +++++------ public/blah/math/mat3x2.cpp | 2 +- public/blah/math/point.cpp | 24 ++++++------ public/blah/math/rect.cpp | 52 ++++++++++++------------- public/blah/math/rectI.cpp | 12 +++--- public/blah/time.cpp | 6 +-- 16 files changed, 106 insertions(+), 106 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 744b09d..32c2e09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ add_library(blah public/blah/input/virtual_button.h public/blah/input/virtual_axis.cpp public/blah/input/virtual_axis.h - + public/blah/containers/list.h public/blah/containers/stacklist.h public/blah/containers/str.cpp @@ -103,7 +103,7 @@ add_library(blah private/blah/internal/platform_sdl2.cpp ) -target_include_directories(blah +target_include_directories(blah PUBLIC $ PRIVATE diff --git a/README.md b/README.md index a19e7a8..f3036da 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ a small C++ game framework for 2D games. this will likely see breaking changes. -#### prerequisites +#### prerequisites - A C++17 compiler and CMake - Only an SDL2 `platform` [is done](https://github.com/NoelFB/blah/blob/master/private/blah/internal/platform_sdl2.cpp). CMake will need to find SDL2 via `SDL2_INCLUDE_DIRS` and `SDL2_LIBRARIES` - Only an OpenGL `graphics` [is done](https://github.com/NoelFB/blah/blob/master/private/blah/internal/graphics_opengl.cpp), so it currently requires OpenGL. - + #### notes - There are probably lots of small bugs as this is highly untested. Best used as a learning resource for now. - There's a custom "vector" class which is called List and Stacklist which may later be replaced with std::vector diff --git a/private/blah/internal/platform_sdl2.cpp b/private/blah/internal/platform_sdl2.cpp index f4f7284..90c0c95 100644 --- a/private/blah/internal/platform_sdl2.cpp +++ b/private/blah/internal/platform_sdl2.cpp @@ -409,7 +409,7 @@ void Platform::get_draw_size(int* width, int* height) float Platform::get_content_scale() { // TODO: - // This is incorrect! but for some reason the scale + // This is incorrect! but for some reason the scale // is HUGE if I use the Display DPI on macOS :/ #if __APPLE__ return 2.0f; diff --git a/public/blah.h b/public/blah.h index 761685e..8a581ff 100644 --- a/public/blah.h +++ b/public/blah.h @@ -5,7 +5,7 @@ #include #include #include - + #include #include #include diff --git a/public/blah/containers/str.cpp b/public/blah/containers/str.cpp index 0358fac..9a0d975 100644 --- a/public/blah/containers/str.cpp +++ b/public/blah/containers/str.cpp @@ -15,14 +15,14 @@ const uint32_t UTF8_SURROGATE_OFFSET = 0x10000u - (UTF8_LEAD_SURROGATE_MIN << 10 char Str::empty_buffer[1] = { '\0' }; -bool Str::operator==(const Str& rhs) const -{ - return strcmp(cstr(), rhs.cstr()) == 0; +bool Str::operator==(const Str& rhs) const +{ + return strcmp(cstr(), rhs.cstr()) == 0; } -bool Str::operator!=(const Str& rhs) const -{ - return strcmp(cstr(), rhs.cstr()) != 0; +bool Str::operator!=(const Str& rhs) const +{ + return strcmp(cstr(), rhs.cstr()) != 0; } bool Str::operator==(const char* rhs) const @@ -43,7 +43,7 @@ void Str::reserve(int size) if (m_capacity <= 0) m_capacity = 16; - while (m_capacity < buffer_length) + while (m_capacity < buffer_length) m_capacity *= 2; // expand from local buffer diff --git a/public/blah/drawing/batch.cpp b/public/blah/drawing/batch.cpp index 5e8c27d..1401d1c 100644 --- a/public/blah/drawing/batch.cpp +++ b/public/blah/drawing/batch.cpp @@ -388,8 +388,8 @@ void Batch::bezier_line(const Vec2& from, const Vec2& b, const Vec2& c, const Ve void Batch::tri(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, Color color) { PUSH_TRIANGLE( - pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, - 0, 0, 0, 0, 0, 0, + pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, + 0, 0, 0, 0, 0, 0, color, color, color, 0, 0, 255); } @@ -397,8 +397,8 @@ void Batch::tri(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, Color colo void Batch::tri(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, Color col0, Color col1, Color col2) { PUSH_TRIANGLE( - pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, - 0, 0, 0, 0, 0, 0, + pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, + 0, 0, 0, 0, 0, 0, col0, col1, col2, 0, 0, 255); } @@ -406,18 +406,18 @@ void Batch::tri(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, Color col0 void Batch::tri(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, const Vec2& tex0, const Vec2& tex1, const Vec2& tex2, Color color) { PUSH_TRIANGLE( - pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, - tex0.x, tex0.y, tex1.x, tex1.y, tex2.x, tex2.y, - color, color, color, + pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, + tex0.x, tex0.y, tex1.x, tex1.y, tex2.x, tex2.y, + color, color, color, m_tex_mult, m_tex_wash, 0); } void Batch::tri(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, const Vec2& tex0, const Vec2& tex1, const Vec2& tex2, Color col0, Color col1, Color col2) { PUSH_TRIANGLE( - pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, - tex0.x, tex0.y, tex1.x, tex1.y, tex2.x, tex2.y, - col0, col1, col2, + pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, + tex0.x, tex0.y, tex1.x, tex1.y, tex2.x, tex2.y, + col0, col1, col2, m_tex_mult, m_tex_wash, 0); } @@ -633,7 +633,7 @@ void Batch::circle_line(const Vec2 center, float radius, float t, int steps, Col void Batch::quad(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, const Vec2& pos3, Color color) { PUSH_QUAD( - pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, + pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, 0, 0, 0, 0, 0, 0, 0, 0, color, color, color, color, 0, 0, 255); @@ -642,7 +642,7 @@ void Batch::quad(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, const Vec void Batch::quad(const Vec2& pos0, const Vec2& pos1, const Vec2& pos2, const Vec2& pos3, Color col0, Color col1, Color col2, Color col3) { PUSH_QUAD( - pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, + pos0.x, pos0.y, pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y, 0, 0, 0, 0, 0, 0, 0, 0, col0, col1, col2, col3, 0, 0, 255); @@ -699,9 +699,9 @@ void Batch::tex(const Subtexture& sub, const Vec2& pos, Color color) if (!sub.texture || !sub.texture->is_valid()) { PUSH_QUAD( - pos.x + sub.draw_coords[0].x, pos.y + sub.draw_coords[0].y, - pos.x + sub.draw_coords[1].x, pos.y + sub.draw_coords[1].y, - pos.x + sub.draw_coords[2].x, pos.y + sub.draw_coords[2].y, + pos.x + sub.draw_coords[0].x, pos.y + sub.draw_coords[0].y, + pos.x + sub.draw_coords[1].x, pos.y + sub.draw_coords[1].y, + pos.x + sub.draw_coords[2].x, pos.y + sub.draw_coords[2].y, pos.x + sub.draw_coords[3].x, pos.y + sub.draw_coords[3].y, 0, 0, 0, 0, 0, 0, 0, 0, color, color, color, color, @@ -716,9 +716,9 @@ void Batch::tex(const Subtexture& sub, const Vec2& pos, Color color) pos.x + sub.draw_coords[1].x, pos.y + sub.draw_coords[1].y, pos.x + sub.draw_coords[2].x, pos.y + sub.draw_coords[2].y, pos.x + sub.draw_coords[3].x, pos.y + sub.draw_coords[3].y, - sub.tex_coords[0].x, sub.tex_coords[0].y, - sub.tex_coords[1].x, sub.tex_coords[1].y, - sub.tex_coords[2].x, sub.tex_coords[2].y, + sub.tex_coords[0].x, sub.tex_coords[0].y, + sub.tex_coords[1].x, sub.tex_coords[1].y, + sub.tex_coords[2].x, sub.tex_coords[2].y, sub.tex_coords[3].x, sub.tex_coords[3].y, color, color, color, color, m_tex_mult, m_tex_wash, 0); @@ -732,9 +732,9 @@ void Batch::tex(const Subtexture& sub, const Vec2& pos, const Vec2& origin, cons if (!sub.texture || !sub.texture->is_valid()) { PUSH_QUAD( - sub.draw_coords[0].x, sub.draw_coords[0].y, - sub.draw_coords[1].x, sub.draw_coords[1].y, - sub.draw_coords[2].x, sub.draw_coords[2].y, + sub.draw_coords[0].x, sub.draw_coords[0].y, + sub.draw_coords[1].x, sub.draw_coords[1].y, + sub.draw_coords[2].x, sub.draw_coords[2].y, sub.draw_coords[3].x, sub.draw_coords[3].y, 0, 0, 0, 0, 0, 0, 0, 0, color, color, color, color, @@ -749,9 +749,9 @@ void Batch::tex(const Subtexture& sub, const Vec2& pos, const Vec2& origin, cons sub.draw_coords[1].x, sub.draw_coords[1].y, sub.draw_coords[2].x, sub.draw_coords[2].y, sub.draw_coords[3].x, sub.draw_coords[3].y, - sub.tex_coords[0].x, sub.tex_coords[0].y, - sub.tex_coords[1].x, sub.tex_coords[1].y, - sub.tex_coords[2].x, sub.tex_coords[2].y, + sub.tex_coords[0].x, sub.tex_coords[0].y, + sub.tex_coords[1].x, sub.tex_coords[1].y, + sub.tex_coords[2].x, sub.tex_coords[2].y, sub.tex_coords[3].x, sub.tex_coords[3].y, color, color, color, color, m_tex_mult, m_tex_wash, 0); @@ -807,7 +807,7 @@ void Batch::str(const SpriteFont& font, const String& text, const Vec2& pos, Tex } // TODO: - // This doesn't parse Unicode! + // This doesn't parse Unicode! // It will assume it's a 1-byte ASCII char which is incorrect auto ch = font[text[i]]; @@ -818,7 +818,7 @@ void Batch::str(const SpriteFont& font, const String& text, const Vec2& pos, Tex if (i > 0 && text[i - 1] != '\n') { // TODO: - // This doesn't parse Unicode! + // This doesn't parse Unicode! at.x += font.get_kerning(text[i], text[i - 1]); } diff --git a/public/blah/graphics/graphics.h b/public/blah/graphics/graphics.h index 3555a05..a08344f 100644 --- a/public/blah/graphics/graphics.h +++ b/public/blah/graphics/graphics.h @@ -166,10 +166,10 @@ namespace Blah rgba = blendColor; } - inline bool operator==(const BlendMode& rhs) const { + inline bool operator==(const BlendMode& rhs) const { return colorOp == rhs.colorOp && colorSrc == rhs.colorSrc && colorDst == rhs.colorDst && alphaOp == rhs.alphaOp && alphaSrc == rhs.alphaSrc && alphaDst == rhs.alphaDst && - mask == rhs.mask && rgba == rhs.rgba; + mask == rhs.mask && rgba == rhs.rgba; } inline bool operator!=(const BlendMode& rhs) const { return !(*this == rhs); } diff --git a/public/blah/images/aseprite.cpp b/public/blah/images/aseprite.cpp index 20c5b6d..4e278e0 100644 --- a/public/blah/images/aseprite.cpp +++ b/public/blah/images/aseprite.cpp @@ -158,7 +158,7 @@ void Aseprite::Parse(Stream& stream) if (old_chunk_count == 0xFFFF) chunks = new_chunk_count; - else + else chunks = old_chunk_count; } diff --git a/public/blah/images/font.cpp b/public/blah/images/font.cpp index a947d81..8c8e7c9 100644 --- a/public/blah/images/font.cpp +++ b/public/blah/images/font.cpp @@ -14,10 +14,10 @@ String GetName(stbtt_fontinfo* font, int nameId) int length = 0; // get the name - const uint16_t* ptr = (const uint16_t*)stbtt_GetFontNameStr(font, &length, - STBTT_PLATFORM_ID_MICROSOFT, - STBTT_MS_EID_UNICODE_BMP, - STBTT_MS_LANG_ENGLISH, + const uint16_t* ptr = (const uint16_t*)stbtt_GetFontNameStr(font, &length, + STBTT_PLATFORM_ID_MICROSOFT, + STBTT_MS_EID_UNICODE_BMP, + STBTT_MS_LANG_ENGLISH, nameId); // we want the size in wide chars diff --git a/public/blah/input/input.h b/public/blah/input/input.h index 6ddd1fa..1d99f85 100644 --- a/public/blah/input/input.h +++ b/public/blah/input/input.h @@ -295,7 +295,7 @@ namespace Blah // Timestamp, in milliseconds, since each button was last pressed uint64_t button_timestamp[Input::max_controller_buttons]; - // Timestamp, in milliseconds, since each axis last had a value set + // Timestamp, in milliseconds, since each axis last had a value set uint64_t axis_timestamp[Input::max_controller_axis]; }; diff --git a/public/blah/math/color.cpp b/public/blah/math/color.cpp index 22923a9..0344ace 100644 --- a/public/blah/math/color.cpp +++ b/public/blah/math/color.cpp @@ -6,7 +6,7 @@ using namespace Blah; char const hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; #define LT_HEX_VALUE(n) ((n >= '0' && n <= '9') ? (n - '0') : ((n >= 'A' && n <= 'F') ? (10 + n - 'A') : ((n >= 'a' && n <= 'f') ? (10 + n - 'a') : 0))) -Color::Color() +Color::Color() : r(0), g(0), b(0), a(0) {} Color::Color(int rgb) : @@ -15,16 +15,16 @@ Color::Color(int rgb) : b((uint8_t)(rgb & 0x0000FF)), a(255) {} -Color::Color(int rgb, float alpha) : +Color::Color(int rgb, float alpha) : r((int)(((uint8_t)((rgb & 0xFF0000) >> 16)) * alpha)), g((int)(((uint8_t)((rgb & 0x00FF00) >> 8)) * alpha)), b((int)(((uint8_t)(rgb & 0x0000FF)) * alpha)), a((int)(255 * alpha)) {} -Color::Color(uint8_t r, uint8_t g, uint8_t b) +Color::Color(uint8_t r, uint8_t g, uint8_t b) : r(r), g(g), b(b), a(255) {} -Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) +Color::Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a) : r(r), g(g), b(b), a(a) {} Color::Color(const char* value) : r(0), g(0), b(0), a(255) @@ -59,10 +59,10 @@ void Color::premultiply() uint32_t Color::to_rgba() const { - return - ((uint32_t)r << 24) | - ((uint32_t)g << 16) | - ((uint32_t)b << 8) | + return + ((uint32_t)r << 24) | + ((uint32_t)g << 16) | + ((uint32_t)b << 8) | (uint32_t)a; } @@ -130,9 +130,9 @@ Color Color::lerp(Color a, Color b, float amount) Color Color::operator*(float multiply) const { return Color( - (int)(r * multiply), - (int)(g * multiply), - (int)(b * multiply), + (int)(r * multiply), + (int)(g * multiply), + (int)(b * multiply), (int)(a * multiply)); } diff --git a/public/blah/math/mat3x2.cpp b/public/blah/math/mat3x2.cpp index a9a0a1b..e67016e 100644 --- a/public/blah/math/mat3x2.cpp +++ b/public/blah/math/mat3x2.cpp @@ -5,7 +5,7 @@ using namespace Blah; -Mat3x2::Mat3x2() +Mat3x2::Mat3x2() : m11(0), m12(0), m21(0), m22(0), m31(0), m32(0) {} Mat3x2::Mat3x2(float m11, float m12, float m21, float m22, float m31, float m32) diff --git a/public/blah/math/point.cpp b/public/blah/math/point.cpp index f0e9a99..a2484e1 100644 --- a/public/blah/math/point.cpp +++ b/public/blah/math/point.cpp @@ -4,15 +4,15 @@ using namespace Blah; -Point::Point() -{ - x = y = 0; +Point::Point() +{ + x = y = 0; } -Point::Point(int px, int py) -{ - x = px; - y = py; +Point::Point(int px, int py) +{ + x = px; + y = py; } Point Point::operator +(const Point rhs) const { return Point(x + rhs.x, y + rhs.y); } @@ -31,14 +31,14 @@ Point& Point::operator *=(int rhs) { x *= rhs; y *= rhs; return *this; } bool Point::operator ==(const Point& rhs) { return x == rhs.x && y == rhs.y; } bool Point::operator !=(const Point& rhs) { return x != rhs.x || y != rhs.y; } -float Point::length() const -{ +float Point::length() const +{ return sqrtf((float)(x * x + y * y)); } -int Point::length_squared() const -{ - return x * x + y * y; +int Point::length_squared() const +{ + return x * x + y * y; } const Point Point::unitX = Point(1, 0); diff --git a/public/blah/math/rect.cpp b/public/blah/math/rect.cpp index 1a2a293..b778e95 100644 --- a/public/blah/math/rect.cpp +++ b/public/blah/math/rect.cpp @@ -7,17 +7,17 @@ using namespace Blah; -Rect::Rect() -{ - x = y = w = h = 0; +Rect::Rect() +{ + x = y = w = h = 0; }; -Rect::Rect(float rx, float ry, float rw, float rh) -{ - x = rx; - y = ry; - w = rw; - h = rh; +Rect::Rect(float rx, float ry, float rw, float rh) +{ + x = rx; + y = ry; + w = rw; + h = rh; } Rect::Rect(Vec2 pos, Vec2 size) @@ -28,30 +28,30 @@ Rect::Rect(Vec2 pos, Vec2 size) h = size.y; } -Rect::Rect(RectI r) -{ - x = (float)r.x; +Rect::Rect(RectI r) +{ + x = (float)r.x; y = (float)r.y; w = (float)r.w; h = (float)r.h; } Rect Rect::scale(float s) -{ - x = (x * s); - y = (y * s); - w = (w * s); - h = (h * s); - return *this; +{ + x = (x * s); + y = (y * s); + w = (w * s); + h = (h * s); + return *this; } -Rect Rect::scale(float sx, float sy) -{ - x = (x * sx); - y = (y * sy); - w = (w * sx); - h = (h * sy); - return *this; +Rect Rect::scale(float sx, float sy) +{ + x = (x * sx); + y = (y * sy); + w = (w * sx); + h = (h * sy); + return *this; } Line Rect::left_line() const { return Line(left(), top(), left(), bottom()); } @@ -67,7 +67,7 @@ Rect& Rect::operator-=(const Vec2& rhs) { x -= rhs.x; y -= rhs.y; return *this; Rect Rect::transform(const Rect& rect, const Mat3x2& matrix) { return Rect( - (rect.x * matrix.m11) + (rect.y * matrix.m21) + matrix.m31, + (rect.x * matrix.m11) + (rect.y * matrix.m21) + matrix.m31, (rect.x * matrix.m12) + (rect.y * matrix.m22) + matrix.m32, (rect.w * matrix.m11) + (rect.h * matrix.m21), (rect.w * matrix.m12) + (rect.h * matrix.m22)); diff --git a/public/blah/math/rectI.cpp b/public/blah/math/rectI.cpp index 9d01452..18c2456 100644 --- a/public/blah/math/rectI.cpp +++ b/public/blah/math/rectI.cpp @@ -12,17 +12,17 @@ RectI::RectI() RectI::RectI(int rx, int ry, int rw, int rh) { - x = rx; - y = ry; - w = rw; + x = rx; + y = ry; + w = rw; h = rh; } RectI::RectI(Point pos, Point size) { - x = pos.x; - y = pos.y; - w = size.x; + x = pos.x; + y = pos.y; + w = size.x; h = size.y; } diff --git a/public/blah/time.cpp b/public/blah/time.cpp index f4bd8e4..d3f5128 100644 --- a/public/blah/time.cpp +++ b/public/blah/time.cpp @@ -5,9 +5,9 @@ using namespace Blah; namespace { - float modf(float x, float m) - { - return x - (int)(x / m) * m; + float modf(float x, float m) + { + return x - (int)(x / m) * m; } }