3DViewer
Technologies Used
Plugin Info
System Topology & Gallery
3DViewer Data and Shader Compilation Pipeline
This project was built as a practical, time-boxed learning exercise to understand bare-metal graphics programming, matrix math, and cross-platform build pipelines without relying on a monolithic engine like Unreal or Unity.
The architecture is kept intentionally simple and data-oriented. It avoids heavy Object-Oriented patterns, instead using flat C++ structs and arrays that map perfectly to how a GPU consumes data in memory.
For the backend, it uses sokol_app for windowing and sokol_gfx for rendering. The shader pipeline is written in a single GLSL file, which is intercepted during the CMake build process by sokol-shdc. This tool cross-compiles the shader into HLSL for Windows (Direct3D 11), Metal Shading Language for macOS, and standard GLSL for Linux. Camera math is handled by cglm, and 3D geometry is parsed from raw text into GPU-ready interleaved buffers using tinyobjloader.
Core Capabilities
Cross-platform native rendering (D3D11 on Windows, Metal on macOS, GL Core on Linux)
Interactive orbit camera with mouse drag panning and scroll wheel zooming
Automatic bounding-box calculation to perfectly center and frame any loaded mesh on startup
Directional lighting implemented via a custom shader pipeline calculating surface normals
Data-oriented mesh loading that flattens OBJ indices into a single interleaved GPU buffer
Architectural Implementation
01Graphics Hardware Abstraction
Utilizes Sokol as a lightweight HAL to route drawing commands to the host OS's native graphics API, avoiding the overhead and instability of wrapper APIs like Vulkan on Windows.
02Shader Cross-Compilation
Engineered a custom CMake post-build step that utilizes sokol-shdc to compile a unified GLSL file into native shader headers (HLSL, MSL, GLSL) dynamically based on the target OS.
03Data-Oriented Mesh Parsing
Uses tinyobjloader to extract raw 3D data. A custom loop intercepts the disparate position and normal indices and repacks them into a dense, contiguous C++ vector for immediate, single-buffer GPU upload.
Production Validation
- Established a clean, reusable CMake build template for future C++ graphics projects