Compare commits
12 Commits
f068939e35
...
194d7bb135
Author | SHA1 | Date |
---|---|---|
Simon Bruder | 194d7bb135 | |
Simon Bruder | ec7fe4ea6d | |
Simon Bruder | bd651ee6db | |
Simon Bruder | ca84db9089 | |
Simon Bruder | 58806ba093 | |
Simon Bruder | c41d0cb09b | |
Simon Bruder | 1bd2d3a2a5 | |
Simon Bruder | f46e54a156 | |
Simon Bruder | 34ef7609bf | |
Simon Bruder | f52bb96d91 | |
Simon Bruder | 7dacccdbd0 | |
Simon Bruder | c263958d3b |
77
flake.nix
77
flake.nix
|
@ -6,58 +6,67 @@
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
|
outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
pkgs = import nixpkgs { inherit system; };
|
pkgs = import nixpkgs { inherit system; };
|
||||||
mkNocheck = drv: drv.overrideAttrs (o: {
|
mkNocheck = drv: drv.overrideAttrs (o: {
|
||||||
doCheck = false;
|
doCheck = false;
|
||||||
checkInputs = [ ];
|
checkInputs = [ ];
|
||||||
});
|
});
|
||||||
|
mkClang = drv: drv.override (o: {
|
||||||
|
stdenv = pkgs.clangStdenv;
|
||||||
|
});
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages = rec {
|
packages = lib.foldAttrs lib.const { }
|
||||||
u01 = pkgs.callPackage
|
(lib.flatten (lib.mapAttrsToList
|
||||||
({ stdenv, catch2_3, cmake }: stdenv.mkDerivation {
|
(name: v: {
|
||||||
name = "ecg-u01";
|
"${name}" = v;
|
||||||
|
"${name}-nocheck" = mkNocheck v;
|
||||||
src = ./u01;
|
"${name}-clang" = mkClang v;
|
||||||
|
"${name}-nocheck-clang" = mkClang (mkNocheck v);
|
||||||
nativeBuildInputs = [ cmake ];
|
|
||||||
checkInputs = [ catch2_3 ];
|
|
||||||
|
|
||||||
doCheck = true;
|
|
||||||
})
|
})
|
||||||
{ };
|
rec {
|
||||||
|
u01 = pkgs.callPackage
|
||||||
|
({ stdenv, catch2_3, cmake }: stdenv.mkDerivation {
|
||||||
|
name = "ecg-u01";
|
||||||
|
|
||||||
u02 = pkgs.callPackage
|
src = ./u01;
|
||||||
({ stdenv, catch2_3, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
|
|
||||||
name = "ecg-u02";
|
|
||||||
|
|
||||||
src = ./u02;
|
nativeBuildInputs = [ cmake ];
|
||||||
|
checkInputs = [ catch2_3 ];
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ];
|
doCheck = true;
|
||||||
buildInputs = [ freeglut libGL libGLU ];
|
})
|
||||||
checkInputs = [ catch2_3 ];
|
{ };
|
||||||
|
|
||||||
doCheck = true;
|
u02 = pkgs.callPackage
|
||||||
})
|
({ stdenv, catch2_3, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
|
||||||
{ };
|
name = "ecg-u02";
|
||||||
|
|
||||||
u03 = pkgs.callPackage
|
src = ./u02;
|
||||||
({ stdenv, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
|
|
||||||
name = "ecg-u03";
|
|
||||||
|
|
||||||
src = ./u03;
|
nativeBuildInputs = [ cmake ];
|
||||||
|
buildInputs = [ freeglut libGL libGLU ];
|
||||||
|
checkInputs = [ catch2_3 ];
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ];
|
doCheck = true;
|
||||||
buildInputs = [ freeglut libGL libGLU ];
|
})
|
||||||
})
|
{ };
|
||||||
{ };
|
|
||||||
|
|
||||||
u01-nocheck = mkNocheck u01;
|
u03 = pkgs.callPackage
|
||||||
u02-nocheck = mkNocheck u02;
|
({ stdenv, cmake, freeglut, libGL, libGLU }: stdenv.mkDerivation {
|
||||||
};
|
name = "ecg-u03";
|
||||||
|
|
||||||
|
src = ./u03;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ cmake ];
|
||||||
|
buildInputs = [ freeglut libGL libGLU ];
|
||||||
|
})
|
||||||
|
{ };
|
||||||
|
}));
|
||||||
|
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
nativeBuildInputs = with pkgs; [ catch2_3 cmake freeglut libGL libGLU reuse ];
|
nativeBuildInputs = with pkgs; [ catch2_3 clang cmake freeglut libGL libGLU reuse ];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,16 @@
|
||||||
cmake_minimum_required(VERSION 3.20)
|
cmake_minimum_required(VERSION 3.20)
|
||||||
project(ecg_tree)
|
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_library(tree node.cpp)
|
||||||
add_executable(main main.cpp)
|
add_executable(main main.cpp)
|
||||||
target_link_libraries(main tree)
|
target_link_libraries(main tree)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "node.h"
|
#include "node.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main() {
|
||||||
node *t = create_complete_tree(2, 4);
|
node *t = create_complete_tree(2, 4);
|
||||||
std::cout << *t;
|
std::cout << *t;
|
||||||
delete t;
|
delete t;
|
||||||
|
|
|
@ -56,7 +56,7 @@ void star_tool::draw(int x0, int y0, int x1, int y1) {
|
||||||
const std::vector<std::pair<float, float>> points =
|
const std::vector<std::pair<float, float>> points =
|
||||||
star(spikes, radius_factor * r, r, x0, y0, angle);
|
star(spikes, radius_factor * r, r, x0, y0, angle);
|
||||||
|
|
||||||
for (int i = 1; i <= points.size(); i++) {
|
for (size_t i = 1; i <= points.size(); i++) {
|
||||||
blt->draw(round(points[i - 1].first), round(points[i - 1].second),
|
blt->draw(round(points[i - 1].first), round(points[i - 1].second),
|
||||||
round(points[i % points.size()].first),
|
round(points[i % points.size()].first),
|
||||||
round(points[i % points.size()].second));
|
round(points[i % points.size()].second));
|
||||||
|
|
|
@ -41,24 +41,26 @@ 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() { draw(10, 10, 90, 30, 30, 90); }
|
||||||
|
|
||||||
void sweep_line_tool::draw(int _x, int _y) { draw(); }
|
void sweep_line_tool::draw(int, int) { draw(); }
|
||||||
|
|
||||||
void sweep_line_tool::draw(int x0, int y0, int x1, int y1, int x2, int y2) {
|
void sweep_line_tool::draw(int x0, int y0, int x1, int y1, int x2, int y2) {
|
||||||
// Terminology:
|
/*
|
||||||
//
|
* Terminology:
|
||||||
// (x0, y0)
|
*
|
||||||
// +
|
* (x0, y0)
|
||||||
// | \
|
* +
|
||||||
// | \ m_1
|
* | \
|
||||||
// |first\
|
* | \ m_1
|
||||||
// | pass \
|
* |first\
|
||||||
// m_shared |---------+ (x1, y1)
|
* | pass \
|
||||||
// |second /
|
* m_shared |---------+ (x1, y1)
|
||||||
// |pass /
|
* |second /
|
||||||
// | / m_2
|
* |pass /
|
||||||
// | /
|
* | / m_2
|
||||||
// +
|
* | /
|
||||||
// (x2, y2)
|
* +
|
||||||
|
* (x2, y2)
|
||||||
|
*/
|
||||||
|
|
||||||
// Sort triangle points (in place) so that y0 < y1 < y2
|
// Sort triangle points (in place) so that y0 < y1 < y2
|
||||||
sort_triangle_points(x0, y0, x1, y1, x2, y2);
|
sort_triangle_points(x0, y0, x1, y1, x2, y2);
|
||||||
|
|
|
@ -128,6 +128,7 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
|
||||||
const int tool_idx = GENERATE(0, 1);
|
const int tool_idx = GENERATE(0, 1);
|
||||||
switch (tool_idx) {
|
switch (tool_idx) {
|
||||||
case 0:
|
case 0:
|
||||||
|
default: // required to make static compiler warnings happy
|
||||||
tool = tool_bresenham;
|
tool = tool_bresenham;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -192,7 +193,6 @@ TEST_CASE("Bresenham/DDA line tool (prop: for every row/column, only one pixel "
|
||||||
|
|
||||||
TEST_CASE("Fill (recursive and non recursive) test shape") {
|
TEST_CASE("Fill (recursive and non recursive) test shape") {
|
||||||
canvas_buffer *canvas = new canvas_buffer(100, 100);
|
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);
|
recursive_fill_tool *tool_fill_recursive = new recursive_fill_tool(*canvas);
|
||||||
non_recursive_fill_tool *tool_fill_non_recursive =
|
non_recursive_fill_tool *tool_fill_non_recursive =
|
||||||
new non_recursive_fill_tool(*canvas);
|
new non_recursive_fill_tool(*canvas);
|
||||||
|
@ -201,6 +201,7 @@ TEST_CASE("Fill (recursive and non recursive) test shape") {
|
||||||
const int tool_fill_idx = GENERATE(0, 1);
|
const int tool_fill_idx = GENERATE(0, 1);
|
||||||
switch (tool_fill_idx) {
|
switch (tool_fill_idx) {
|
||||||
case 0:
|
case 0:
|
||||||
|
default: // required to make static compiler warnings happy
|
||||||
tool_fill = tool_fill_recursive;
|
tool_fill = tool_fill_recursive;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
|
|
@ -427,7 +427,7 @@ void BMP_GetPixelRGB( BMP* bmp, UINT x, UINT y, UCHAR* r, UCHAR* g, UCHAR* b )
|
||||||
UINT bytes_per_row;
|
UINT bytes_per_row;
|
||||||
UCHAR bytes_per_pixel;
|
UCHAR bytes_per_pixel;
|
||||||
|
|
||||||
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
|
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
|
||||||
{
|
{
|
||||||
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
|
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;
|
UINT bytes_per_row;
|
||||||
UCHAR bytes_per_pixel;
|
UCHAR bytes_per_pixel;
|
||||||
|
|
||||||
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
|
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
|
||||||
{
|
{
|
||||||
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
|
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ void BMP_GetPixelIndex( BMP* bmp, UINT x, UINT y, UCHAR* val )
|
||||||
UCHAR* pixel;
|
UCHAR* pixel;
|
||||||
UINT bytes_per_row;
|
UINT bytes_per_row;
|
||||||
|
|
||||||
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
|
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
|
||||||
{
|
{
|
||||||
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
|
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
@ -539,7 +539,7 @@ void BMP_SetPixelIndex( BMP* bmp, UINT x, UINT y, UCHAR val )
|
||||||
UCHAR* pixel;
|
UCHAR* pixel;
|
||||||
UINT bytes_per_row;
|
UINT bytes_per_row;
|
||||||
|
|
||||||
if ( bmp == NULL || x < 0 || x >= bmp->Header.Width || y < 0 || y >= bmp->Header.Height )
|
if ( bmp == NULL || x >= bmp->Header.Width || y >= bmp->Header.Height )
|
||||||
{
|
{
|
||||||
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
|
BMP_LAST_ERROR_CODE = BMP_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue