Skip to content

Commit

Permalink
WIP 7
Browse files Browse the repository at this point in the history
  • Loading branch information
stepulak committed Oct 20, 2020
1 parent a4d3df1 commit 63ccedd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

COMPILER="g++"
CFLAGS="-std=c++17 -c"
CFLAGS="-std=c++17 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -pedantic -c"
LFLAGS="-lSDL2 -lSDL2_image"
DIRECTORY="src/"
CPP_FILES="*.cpp"
Expand Down
2 changes: 1 addition & 1 deletion src/BitmapFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

BitmapFont::BitmapFont(SDL_Renderer* rend, const std::string& path, int charWidth, const std::string& alphabet)
: m_renderer(rend)
, m_bitmapCharWidth(charWidth)
, m_bitmap(Utils::LoadTexture(rend, path, nullptr, &m_bitmapHeight))
, m_bitmapCharWidth(charWidth)
{
if (charWidth <= 0) {
throw std::runtime_error("charWidth must be positive!");
Expand Down
4 changes: 2 additions & 2 deletions src/BitmapFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ class BitmapFont {
static constexpr auto VISIBLE_ALPHABET_SIZE = VISIBLE_ALPHABET_END - VISIBLE_ALPHABET_START + 1u;

std::array<int, VISIBLE_ALPHABET_SIZE> m_alphabet;
SDL_Renderer* m_renderer;
SDL_Texture* m_bitmap;
// int due to SDL2
int m_bitmapHeight;
int m_bitmapCharWidth;
SDL_Texture* m_bitmap;
SDL_Renderer* m_renderer;

bool InsideVisibleAlphabet(char c) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/RasterGridRunnable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ std::string RasterGridRunnable::GetAppInfo() const
size_t pointIndex = 1u;
for (const auto& p : m_points) {
const auto point = (p / static_cast<float>(m_pointSize)).ToPoint();
ss << "POINT" << pointIndex << ": [" << p.x << ", " << p.y << "]\n";
ss << "POINT" << pointIndex << ": [" << point.x << ", " << point.y << "]\n";
pointIndex++;
}

Expand Down
24 changes: 8 additions & 16 deletions src/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,30 +119,22 @@ void DrawRectangle(SDL_Renderer* rend, const SDL_Rect& r, int borderThickness, b
{
const auto borderExpand = !borderInside ? borderThickness : 0;
SDL_Rect borders[4] = {
{
r.x - borderExpand,
{ r.x - borderExpand,
r.y - borderExpand,
r.w + borderExpand * 2,
borderThickness
},
{
r.x - borderExpand,
borderThickness },
{ r.x - borderExpand,
r.y + r.h - borderThickness + borderExpand,
r.w + borderExpand * 2,
borderThickness
},
{
r.x - borderExpand,
borderThickness },
{ r.x - borderExpand,
r.y,
borderThickness,
r.h
},
{
r.x + r.w - borderThickness + borderExpand,
r.h },
{ r.x + r.w - borderThickness + borderExpand,
r.y,
borderThickness,
r.h
}
r.h }
};

SDL_RenderFillRects(rend, borders, 4);
Expand Down

0 comments on commit 63ccedd

Please sign in to comment.