Skip to content

Latest commit

 

History

154 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KKE on Direct2D

KKE is a Windows 2D rendering engine built around a Direct2D / DirectWrite / WIC backend. The current implementation centers on kke::D2dEngine and supports shapes, text, textures, layers, offscreen canvases, and effects through one API surface.

Quick Showcase

engine().draw(
	mountainTexture(),
	{{180.0f, 90.0f}, {1100.0f, 650.0f}},
	{0.95f, kke::TextureInterpolation::Linear}
);

kke::RoundedRect blurRect({{400.0f, 200.0f}, {600.0f, 400.0f}}, 20.0f);
engine().renderEffect(kke::BlurEffect(30.0f), blurRect);

kke::StrokeAppearance blurRectStrokeStyle{0.5f};
engine().renderEffect(
	blurRect,
	kke::EffectSourceAppearance{},
	kke::ShadowEffect{
		.color = {0.0f, 0.0f, 0.0f, 0.3f},
		.mode = kke::ShadowMode::OuterShadowOnly
	}
);
engine().draw(blurRect, kke::SolidColorBrush({1.0f, 1.0f, 1.0f, 0.6f}), blurRectStrokeStyle);
engine().fill(blurRect, kke::SolidColorBrush({1.0f, 1.0f, 1.0f, 0.2f}));

kke::Text title{
	L"KKE Renderer",
	{425.0f, 280.0f},
	{"Space Grotesk", 24.0f, kke::FontWeight::BOLD}
};
engine().renderEffect(
	title,
	kke::EffectSourceAppearance{},
	kke::ShadowEffect{
		.color = {0.0f, 0.0f, 0.0f, 0.3f},
		.mode = kke::ShadowMode::OuterShadowOnly
	}
);
engine().fill(title, kke::SolidColorBrush({1.0f, 1.0f, 1.0f, 1.0f}));

showcase

Features

  • C++20
  • Windows / Direct2D / DirectWrite / WIC
  • kke::D2dEngine based API
  • Shape rendering: fill, draw
  • Text rendering and font upload
  • Text size measurement
  • Texture upload and rendering
  • Layer rendering: pushLayer
  • Explicit offscreen canvas recording: beginCanvas, endCanvas, finishCanvas
  • Effect rendering: renderEffect
  • Included demos: blur, shadow, text, texture, canvas, layer, transform

Project Layout

  • src/kke/engine/Engine.hh: public engine interface
  • src/kke/engine/Sources.hh: variant-based source types used by the API
  • src/kke/engine/d2d: Direct2D backend implementation
  • src/kke/geometry: geometry and primitive types
  • src/kke/appearance: brushes, text, transforms, effects, and other draw parameters
  • test: non-interactive unit tests
  • example/render_tests: interactive Windows rendering test application
  • example/overlay: injectable Direct3D 11 overlay example using Kiero and MinHook
  • benchmarks: focused rendering microbenchmarks

Build

A minimal CMake flow looks like this:

cmake -S . -B build
cmake --build build --config Debug

This produces the kke static library, unit-test executables, and benchmark executables. Configure with KKE_BUILD_EXAMPLES=ON to also build kke_render_tests and the overlay example.

When kke is consumed as a subproject through FetchContent or add_subdirectory, tests, benchmarks, and examples are not built by default.

CMake Package Usage

After installing the library, consumers can use find_package:

find_package(kke CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE kke::kke)

Usage Docs

The docs are organized by usage domain instead of backend internals:

Notes

  • kke::D2dEngine adds beginDraw and endDraw on top of kke::Engine to define the Direct2D frame boundary.
  • In the current tests, simple shapes such as kke::Rect and kke::Ellipse are passed directly to fill and draw without manually wrapping them in kke::Geometry.

About

Windows 2D rendering engine built on Direct2D, DirectWrite, and WIC.

Topics

Resources

Stars

12 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages