Compare commits

..

No commits in common. "194d7bb13509630a65f155e3ec12ae97a290f96c" and "f068939e3557d0cc808b954a493a1993eb4e95f1" have entirely different histories.

7 changed files with 57 additions and 79 deletions

View File

@ -6,67 +6,58 @@
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
let
inherit (nixpkgs) lib;
pkgs = import nixpkgs { inherit system; };
mkNocheck = drv: drv.overrideAttrs (o: {
doCheck = false;
checkInputs = [ ];
});
mkClang = drv: drv.override (o: {
stdenv = pkgs.clangStdenv;
});
in
{
packages = lib.foldAttrs lib.const { }
(lib.flatten (lib.mapAttrsToList
(name: v: {
"${name}" = v;
"${name}-nocheck" = mkNocheck v;
"${name}-clang" = mkClang v;
"${name}-nocheck-clang" = mkClang (mkNocheck v);
packages = rec {
u01 = pkgs.callPackage
({ stdenv, catch2_3, cmake }: stdenv.mkDerivation {
name = "ecg-u01";
src = ./u01;
nativeBuildInputs = [ cmake ];
checkInputs = [ catch2_3 ];
doCheck = true;
})
rec {
u01 = pkgs.callPackage
({ stdenv, catch2_3, cmake }: stdenv.mkDerivation {
name = "ecg-u01";
{ };
src = ./u01;
u02 = pkgs.callPackage
({ stdenv, catch2_3, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
name = "ecg-u02";
nativeBuildInputs = [ cmake ];
checkInputs = [ catch2_3 ];
src = ./u02;
doCheck = true;
})
{ };
nativeBuildInputs = [ cmake ];
buildInputs = [ freeglut libGL libGLU ];
checkInputs = [ catch2_3 ];
u02 = pkgs.callPackage
({ stdenv, catch2_3, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
name = "ecg-u02";
doCheck = true;
})
{ };
src = ./u02;
u03 = pkgs.callPackage
({ stdenv, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
name = "ecg-u03";
nativeBuildInputs = [ cmake ];
buildInputs = [ freeglut libGL libGLU ];
checkInputs = [ catch2_3 ];
src = ./u03;
doCheck = true;
})
{ };
nativeBuildInputs = [ cmake ];
buildInputs = [ freeglut libGL libGLU ];
})
{ };
u03 = pkgs.callPackage
({ stdenv, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
name = "ecg-u03";
src = ./u03;
nativeBuildInputs = [ cmake ];
buildInputs = [ freeglut libGL libGLU ];
})
{ };
}));
u01-nocheck = mkNocheck u01;
u02-nocheck = mkNocheck u02;
};
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ catch2_3 clang cmake freeglut libGL libGLU reuse ];
nativeBuildInputs = with pkgs; [ catch2_3 cmake freeglut libGL libGLU reuse ];
};
});
}

View File

@ -2,16 +2,6 @@
cmake_minimum_required(VERSION 3.20)
project(ecg_tree)
set(CMAKE_CXX_STANDARD 17)
# Disable compiler specific extensions
# On GNU this has the effect of passing -std=c++11 instead of -std=gnu++11
set(CMAKE_CXX_EXTENSIONS no)
# Enable all compiler warnings (and make them errors) on GNU/Clang platforms
if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|Clang)$")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wpedantic -Werror")
endif()
add_library(tree node.cpp)
add_executable(main main.cpp)
target_link_libraries(main tree)

View File

@ -3,7 +3,7 @@
#include "node.h"
int main() {
int main(int argc, char **argv) {
node *t = create_complete_tree(2, 4);
std::cout << *t;
delete t;

View File

@ -56,7 +56,7 @@ void star_tool::draw(int x0, int y0, int x1, int y1) {
const std::vector<std::pair<float, float>> points =
star(spikes, radius_factor * r, r, x0, y0, angle);
for (size_t i = 1; i <= points.size(); i++) {
for (int i = 1; i <= points.size(); i++) {
blt->draw(round(points[i - 1].first), round(points[i - 1].second),
round(points[i % points.size()].first),
round(points[i % points.size()].second));

View File

@ -41,26 +41,24 @@ void sweep_line_tool::draw_interval(int b1, int b2, int y) {
void sweep_line_tool::draw() { draw(10, 10, 90, 30, 30, 90); }
void sweep_line_tool::draw(int, int) { draw(); }
void sweep_line_tool::draw(int _x, int _y) { draw(); }
void sweep_line_tool::draw(int x0, int y0, int x1, int y1, int x2, int y2) {
/*
* Terminology:
*
* (x0, y0)
* +
* | \
* | \ m_1
* |first\
* | pass \
* m_shared |---------+ (x1, y1)
* |second /
* |pass /
* | / m_2
* | /
* +
* (x2, y2)
*/
// Terminology:
//
// (x0, y0)
// +
// | \
// | \ m_1
// |first\
// | pass \
// m_shared |---------+ (x1, y1)
// |second /
// |pass /
// | / m_2
// | /
// +
// (x2, y2)
// Sort triangle points (in place) so that y0 < y1 < y2
sort_triangle_points(x0, y0, x1, y1, x2, y2);

View File

@ -128,7 +128,6 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
const int tool_idx = GENERATE(0, 1);
switch (tool_idx) {
case 0:
default: // required to make static compiler warnings happy
tool = tool_bresenham;
break;
case 1:
@ -193,6 +192,7 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
TEST_CASE("Fill (recursive and non recursive) test shape") {
canvas_buffer *canvas = new canvas_buffer(100, 100);
bresenham_line_tool *tool_line = new bresenham_line_tool(*canvas);
recursive_fill_tool *tool_fill_recursive = new recursive_fill_tool(*canvas);
non_recursive_fill_tool *tool_fill_non_recursive =
new non_recursive_fill_tool(*canvas);
@ -201,7 +201,6 @@ TEST_CASE("Fill (recursive and non recursive) test shape") {
const int tool_fill_idx = GENERATE(0, 1);
switch (tool_fill_idx) {
case 0:
default: // required to make static compiler warnings happy
tool_fill = tool_fill_recursive;
break;
case 1:

View File

@ -427,7 +427,7 @@ void BMP_GetPixelRGB( BMP* bmp, UINT x, UINT y, UCHAR* r, UCHAR* g, UCHAR* b )
UINT bytes_per_row;
UCHAR bytes_per_pixel;
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}
@ -467,7 +467,7 @@ void BMP_SetPixelRGB( BMP* bmp, UINT x, UINT y, UCHAR r, UCHAR g, UCHAR b )
UINT bytes_per_row;
UCHAR bytes_per_pixel;
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}
@ -505,7 +505,7 @@ void BMP_GetPixelIndex( BMP* bmp, UINT x, UINT y, UCHAR* val )
UCHAR* pixel;
UINT bytes_per_row;
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}
@ -539,7 +539,7 @@ void BMP_SetPixelIndex( BMP* bmp, UINT x, UINT y, UCHAR val )
UCHAR* pixel;
UINT bytes_per_row;
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
{
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
}