Use the wgpu namespace and object notation
mainWebGPU-C++ wraps the C API into a wgpu namespace and converts procedural functions into object-oriented methods. This makes the API more idiomatic for C++.
- Namespaces: Instead of
WGPUInstance, usewgpu::Instance. - Object Notation: Functions that take an object as their first argument are exposed as methods of that object. For example,
wgpuDeviceCreateBuffer(device, ...)becomesdevice.createBuffer(...). - References: Descriptors are passed by reference (
const Descriptor&) rather than by pointer (const Descriptor*).
// C++ style usage
wgpu::InstanceDescriptor desc = {};
wgpu::Instance instance = wgpu::createInstance(desc);
// Object notation example
auto buffer = device.createBuffer(bufferDescriptor);