Files | |
| main.cpp | |
This example loads the PLG mesh supplied with --filename, then lights and rasterizes it through the CPU-side MXVK math pipeline. When no filename is supplied, it displays the bundled data/sphere.plg. Software rasterization defaults to a 1280x720 framebuffer, which is stretched to fill the Vulkan window.
Use --framebuffer WidthxHeight to select the internal software-rendering resolution independently of the window size. The default is 1280x720:
Run the bundled sphere from the repository root:
Render only the model's depth-tested triangle edges, without filling or texturing its faces:
Benchmark the CPU geometry pipeline over 60 frames:
The reported time covers matrix setup, vertex transformation, face lighting and culling, and triangle rasterization. It excludes framebuffer clearing, texture upload, sprite drawing, and presentation. Benchmark mode exits after the result is printed. To keep shared scalar rasterization from hiding math backend differences, benchmark mode uses a 320x180 software framebuffer unless --framebuffer is explicitly supplied. Use --framebuffer 1280x720 for an end-to-end comparison at the normal rendering resolution.
For a heavier comparison, the generated models/plg/heavy_sphere.plg contains 32,514 vertices and 65,024 triangles:
Load another PLG file:
Map a PNG texture using the model's PLG texture coordinates:
Texture coordinates clamp to the image edges by default, which is suitable for cube faces and texture atlases. Add --repeat for horizontally wrapped models such as spheres:
When --texture is omitted, the loader uses its UV-based color gradient. PNG textures automatically receive a complete mip chain. The software rasterizer selects and blends mip levels from the projected texture footprint to reduce shimmering and moiré on small or oblique triangles. Pass --disable-mipmap to skip mip generation and always sample the full-resolution texture. Use --mip-bias <value> to adjust automatic selection: negative values select sharper levels and positive values select softer levels. For example:
Texture coordinates use perspective-correct interpolation of u/z, v/z, and 1/z by default, preventing texture swimming across triangle diagonals. Pass --nowarpfix to disable the correction and use affine screen-space interpolation: