removed trailing whitespace

This commit is contained in:
Noel Berry 2020-08-28 21:11:43 -07:00
parent e70d7a11a0
commit e1d2e3066e
16 changed files with 106 additions and 106 deletions

View File

@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/public>
PRIVATE

View File

@ -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

View File

@ -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;

View File

@ -5,7 +5,7 @@
#include <blah/filesystem.h>
#include <blah/log.h>
#include <blah/time.h>
#include <blah/containers/list.h>
#include <blah/containers/stacklist.h>
#include <blah/containers/str.h>

View File

@ -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

View File

@ -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]);
}

View File

@ -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); }

View File

@ -158,7 +158,7 @@ void Aseprite::Parse(Stream& stream)
if (old_chunk_count == 0xFFFF)
chunks = new_chunk_count;
else
else
chunks = old_chunk_count;
}

View File

@ -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

View File

@ -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];
};

View File

@ -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));
}

View File

@ -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)

View File

@ -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);

View File

@ -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));

View File

@ -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;
}

View File

@ -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;
}
}