#Mangaging wgpu "State"

4 messages · Page 1 of 1 (latest)

lime steppe
#

So I'm following this wgpu tutorial: https://sotrh.github.io/learn-wgpu/ (I'm also doing my own thing, trying to make a basic UI library) and I'm experiencing a bit of a problem. The tutorial makes you create a State struct which stores all the variables you'll need such your surface, device, queue, window, window size, etc. But it's getting increasingly larger and now I want to add text support via the glyphon crate (https://github.com/grovesNL/glyphon/tree/main), but that requires adding even more stuff to my State. At this point I have around 20 fields in the State struct and it's getting quite unmanagable.

Is there some other method for this that is more readable and extensible?

mystic widget
#

it's normal to need to keep track of a large number of GPU objects when doing graphics programming

#

you can sometimes group them into structs for sensible sub-sections like say "all the text rendering stuff" but in general, expect to have lots of stuff

#

generally the only time you need to care about all the fields at once is on initialization