How bmaow/levikno works
Project Type and Purpose
• Levikno is a native C++ graphics library aimed at simplifying Vulkan and OpenGL usage for game and graphics application development. It exposes a single context‐based API (lvn::createContext, lvn::terminateContext) and supports multiple backends (OpenGL, Vulkan) and window APIs (GLFW).
• Rather than a server/client or full‐stack app, this is a library with examples demonstrating rendering, resource loading, and window management.
File Structure Analysis
• Top‐level:
• CMakeLists.txt, src/, include/, examples/, docs/ – indicates a library build using CMake, with public headers in include/, sources in src/, and sample apps in examples/.
• external/ – vendored third‐party libs (GLFW, GLAD, FreeType, stb, Vulkan SDK, ENet, etc.).
• src/api/ – the core abstraction layers:
• graphics/opengl and graphics/vulkan backends
• window/glfw backend
• loaders/gltf, loaders/obj
• src/levikno.cpp, lvn_renderer.cpp – glue code and entry points for context management and rendering.
• examples/ – standalone executables linking against the library to demonstrate usage.
Key Architecture Insights from README
• Two orthogonal abstraction axes:
a. Window API (currently GLFW)
b. Graphics API (OpenGL or Vulkan)
• Plugin‐style backends chosen at runtime via LvnContextCreateInfo.
• Asset loaders and utility modules provide functionality for models, shaders, audio, etc.
Main Components
A. Application Layer
• Example Executables – user code calling the public API.
B. Public API / Facade
• lvn::createContext / terminate
• Context object, command submission, swapchain management.
C. Abstraction Layers
• WindowAPI module
• GraphicsAPI module
• AssetLoader module
D. Backend Implementations
• GLFW (windowing)
• OpenGL backend
• Vulkan backend
• GLTF/OBJ loaders
E. External Dependencies
• GLFW, GLAD, Vulkan SDK, glslang, FreeType, stb_image, miniaudio, ENet, etc.
F. Platform / OS / GPU Driver
Relationships & Data Flow
• Example App → Public API → Context
• Context uses WindowAPI to create window & input callbacks → GLFW → OS/Platform
• Context uses GraphicsAPI abstraction → chosen backend (OpenGL or Vulkan) → GPU driver
• AssetLoader invoked by user code or internally to load models/shaders → uses GLTF/OBJ loader modules → std::filesystem or tinygltf
• Optional: networking via ENet, text rendering via FreeType, audio via miniaudio (shown as optional integration points).
Architectural Patterns and Design Principles
• Facade Pattern: single entry point simplifies complex Vulkan/OpenGL setup.
• Strategy/Plugin Pattern: interchangeable backends selected at runtime for windowing and graphics.
• Modular Structure: clear separation of concerns among window, graphics, loaders, and external libs.
– WindowAPI Abstraction
– GraphicsAPI Abstraction
– AssetLoader
– GLFW → OS/Platform
– OpenGL Backend → GLAD → GPU Driver
– Vulkan Backend → Vulkan SDK / glslang → GPU Driver
– GLTF Loader, OBJ Loader → std lib
f. At the bottom, show “OS / GPU Driver”.