How janiorca/tinywin works
Project type and purpose
• This is a pair of minimal Win32 applications written in Rust using no_std, designed to demonstrate:
• miniwin: raw Win32 window creation and message loop
• miniwinGL: same plus OpenGL context setup, shader pipeline, and quad rendering
• Primary goal: produce tiny executables (4K intro style) without Rust’s standard library, leveraging Windows API and optionally OpenGL.
File structure
• Top–level
• LICENSE, README.md
• miniwin/
– Cargo.toml, xargo.toml → custom build toolchain for no_std
– src/main.rs → entry point, Win32 API bindings via extern “system”
• miniwinGL/
– Cargo.toml, xargo.toml
– src/main.rs → window + GL context init + render loop
– src/gl.rs → raw OpenGL FFI bindings (wgl*, gl*)
– src/gl_util.rs → helper functions for shader compilation, program linking
– readme.md → build instructions
• tools/
– crinkler.exe → binary packer/compressor for final binary size reduction
README for additional insights
• miniwin: “very small but functional Win32 apps in Rust using no_std”
• miniwinGL: “expanded version… modern OpenGL rendering context and draws a quad with vertex + fragment shader”
• Emphasis on manual API calls, minimal runtime, extreme binary size optimization.
a. Main components
1) Rust no_std runtime (miniwin and miniwinGL crates)
2) Win32 API subsystem (user32.dll, kernel32.dll calls)
3) Window management (RegisterClassEx, CreateWindowEx, message loop)
4) In miniwinGL only: OpenGL subsystem (wgl interface for context creation + core gl functions)
5) Shader loader/manager (vertex & fragment shaders)
6) Tools (Crinkler compressor for post-build optimization)
b. Relationships and interactions
• Application entry (main.rs) calls into no_std runtime stubs → invokes Win32 API to register window class → creates window → enters message loop
• In miniwinGL, after window creation, hand off to wglCreateContext → make current → call gl_util to compile/link shaders → GPU pipeline draws geometry → swap buffers via wglSwapLayerBuffers or SwapBuffers
• Crinkler acts externally after build, compresses final .exe
c. Architectural patterns and design principles
• Minimal layering: direct FFI boundary between Rust code and native OS/GPU libraries
• Separation of concerns: window setup vs. OpenGL context vs. shader utilities
• No dynamic allocation from standard library—static buffers and stack usage only
• Build-time toolchain (xargo) for custom target and no_std environment
d. Key technologies/frameworks
• Rust (no_std, custom panic handler)
• Xargo for building Rust core library only
• Windows API (user32.dll, gdi32.dll, kernel32.dll)
• WGL / OpenGL (core profile)
• Crinkler for binary packing
Detail without overcomplicating
• Module (main.rs, gl.rs, gl_util.rs) as its own component.
• Do not omit the build-time chain (xargo → Cargo → Crinkler).
• runtime vs. build‐time
• OS boundary vs. Rust code boundary
• window management vs. rendering pipeline