Kumo

A hand-rolled game engine.

git clone https://git.sentomk.me/Kumo.git
commit 4232b4e96fecd20e965fe6f3f78f5358e4b3d47b
parent b32be4d3db015625cf81f17edfe8d290d21be80f
Author: sentomk <sentomk@proton.me>
Date:   Tue, 13 Oct 2026 20:48:39 +0800

refactor: reduce main to a hello world

The demo picture and its self-check moved into tests/e2e and tests/unit, where
they are checked automatically, so main no longer needs to draw anything. It
stays a placeholder until the window and the game loop arrive.

Diffstat:
Msrc/main.cpp | 84++-----------------------------------------------------------------------------
1 file changed, 2 insertions(+), 82 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp @@ -1,83 +1,3 @@ -#include <cinttypes> -#include <cstdio> +#include <iostream> -#include "render/frame_buffer.h" -#include "render/raster.h" - -namespace { - -using kumo::Color; -using kumo::FrameBuffer; -using kumo::Point; - -/// @brief Splits the rectangle with corners (x0, y0) and (x1, y1) into two -/// triangles and checks that each of its pixels is drawn exactly once. -/// -/// The diagonal runs through pixel centers, which is the case the top-left -/// rule exists for. The second triangle is given in the opposite winding, to -/// check that the orientation is normalized. -bool check_split_rect(int x0, int y0, int x1, int y1) { - const Color kOn = 0xFFFFFFFF; - FrameBuffer first(64, 64); - FrameBuffer second(64, 64); - const Point tl = kumo::pixel_point(x0, y0); - const Point tr = kumo::pixel_point(x1, y0); - const Point br = kumo::pixel_point(x1, y1); - const Point bl = kumo::pixel_point(x0, y1); - kumo::fill_triangle(first, tl, tr, br, kOn); - kumo::fill_triangle(second, tl, bl, br, kOn); - - for (int y = 0; y < 64; ++y) { - for (int x = 0; x < 64; ++x) { - const int drawn = (first.at(x, y) != 0) + (second.at(x, y) != 0); - const bool inside = x >= x0 && x < x1 && y >= y0 && y < y1; - if (drawn != (inside ? 1 : 0)) return false; - } - } - return true; -} - -} // namespace - -int main() { - if (!check_split_rect(8, 8, 48, 48) || !check_split_rect(5, 11, 42, 34) || - !check_split_rect(0, 0, 64, 64)) { - std::printf("shared edge check: FAILED\n"); - return 1; - } - std::printf("shared edge check: ok\n"); - - FrameBuffer frame(640, 360); - kumo::clear(frame, kumo::make_color(24, 26, 38)); - - kumo::fill_rect(frame, 40, 40, 200, 120, kumo::make_color(230, 140, 50)); - - // A triangle whose corners are not on pixel boundaries: the values are in - // sixteenths of a pixel. - kumo::fill_triangle(frame, {1004, 700}, {2520, 893}, {1810, 2155}, - kumo::make_color(60, 190, 180)); - - // A square cut into two triangles that share the diagonal. - const Point tl = kumo::pixel_point(380, 60); - const Point tr = kumo::pixel_point(560, 60); - const Point br = kumo::pixel_point(560, 240); - const Point bl = kumo::pixel_point(380, 240); - kumo::fill_triangle(frame, tl, tr, br, kumo::make_color(200, 80, 120)); - kumo::fill_triangle(frame, tl, br, bl, kumo::make_color(120, 90, 210)); - - // A fan of lines from one point, reaching past the edge of the buffer. - const Color white = kumo::make_color(240, 240, 240); - for (int i = 0; i <= 8; ++i) { - kumo::draw_line(frame, 320, 300, i * 90 - 40, 170, white); - } - - const uint64_t hash = kumo::hash_pixels(frame); - std::printf("frame hash: %016" PRIx64 "\n", hash); - - if (!kumo::write_tga(frame, "build/frame.tga")) { - std::printf("could not write build/frame.tga\n"); - return 1; - } - std::printf("wrote build/frame.tga\n"); - return 0; -} +int main() { std::cout << "Hello from Kumo..." << '\n'; }