Blog
Win32 C++ pixel playground template
A tiny Win32 starter that cross-compiles from Linux with MinGW-w64 + Meson, opens a window, and pushes pixels through a software framebuffer.
13-11-2022
Blog
A tiny Win32 starter that cross-compiles from Linux with MinGW-w64 + Meson, opens a window, and pushes pixels through a software framebuffer.
13-11-2022
I wanted a zero-dependency starting point for Win32 experiments: open a window, draw pixels in software, and measure each frame without pulling in a game engine or DirectX. The template now ships with a Meson-only workflow that cross-compiles on Linux (MinGW-w64) and runs under Wine.
WinMain registers a window class, creates a window titled “TESTING,” and wires a minimal WinProc that handles paint events.VirtualAlloc reserves a 32-bit buffer sized to the client area. DrawPixel and ClearScreen write directly into that memory, and StretchDIBits blits it to the window.QueryPerformanceFrequency/Counter capture microsecond-resolution timings each loop so you can profile any work you add (unused helpers were trimmed to avoid warnings).user32, gdi32, and kernel32, with C++20 enabled and a WIN32 subsystem binary so no console pops up.cross/windows-mingw64.txt defines MinGW-w64 binaries and Wine as the exe wrapper. VS Code tasks/launch entries let you hit F5 to build and run under Wine.x + y) across the client area to prove the pixel path works.Install prerequisites (Debian/Ubuntu example):
sudo apt-get install mingw-w64 ninja-build meson wine64
Meson + Ninja:
meson setup build-mingw --cross-file cross/windows-mingw64.txt --buildtype=release
ninja -C build-mingw
wine build-mingw/cpp_playground.exe
From VS Code: press F5 and choose Run with Wine (Meson); the default build task runs meson:build-mingw and launches the resulting binary via Wine.
A window appears, the client area is cleared to dark gray, and a color gradient is drawn via the software framebuffer each frame. WinProc also paints a simple "Hello Team" text on WM_PAINT, giving a spot to extend message handling for input or UI.
StretchDIBits.