Commit Graph

4 Commits

Author SHA1 Message Date
portersky 5ec8cfc735 feat: add gfx pipeline abstraction with render targets
Add cbt/gfx layer (pipeline + render_target) inspired by Sokol but
C++-friendly with RAII and pipeline_desc. Supports building full
graphics pipelines (VS/IA/raster/PS/OM), render-to-texture (FBO),
and post-processing steps (scene -> RT -> fullscreen quad with
sampler + vignette).

- Depth/state/viewport/texture cleanup for reliable scene switching.
- Updated cube/sphere to demonstrate (sphere uses RT+post).
- Vulkan backend easy via PIMPL in impl (same public API).
- Fixed depth test, viewport restore, and state leakage on switch.

Followed coding conventions (snake_case, trailing returns, east const,
include order, no ; after ns/class, etc.).
2026-05-06 00:43:00 +02:00
portersky a4ef4adfc7 feat: add window resize support
Added width/height tracking to the window class via a GLFW
resize callback. The callback stores the current size and
forwards it to a user-provided std::function.

Added context::set_size() to update the GL viewport when
the window is resized.

Changed scene::render() to accept (int width, int height)
parameters so scenes can compute the correct aspect ratio
for their projection matrix instead of hardcoding 1280/720.

Fixed parameter shadowing in resize_callback_impl
(glfw_window instead of window).
2026-05-06 00:06:59 +02:00
portersky 91fe3c6e8c style: color-code sphere faces to visualize seams
Each of the 6 cube-to-sphere faces now has a distinct color
(red, green, blue, yellow, magenta, cyan) passed via a
vertex color attribute. The fragment shader multiplies
lighting by this color instead of a uniform blue.

This makes the cube-face seams clearly visible when
inspecting the mapped sphere.
2026-05-06 00:01:17 +02:00
portersky 78d0515e8b feat: add sphere scene with fixed cube-to-sphere mapping
Added scenes/sphere.{hpp,cpp} using the cube-to-sphere
approach from nrz.cpp, but with corrected math: vertices
are simply normalized to project onto the unit sphere
(the original used a broken formula with p=50.0 as an
exponent).

The sphere uses indexed geometry with position, normal,
and UV attributes, plus a simple diffuse lighting shader.

Press 1/2 to switch between cube and sphere scenes.
Updated .gitignore to exclude generated PNG screenshots.
2026-05-05 23:54:48 +02:00