Omegastick / bots

1 stars 1 forks source link

Implement system for drawing modules in an ImGui window #166

Closed Omegastick closed 4 years ago

Omegastick commented 4 years ago

Part of #106.

I'm thinking of doing something like this:

We have a ModuleImageStore or something similar. ModuleImageStore manages the textures to be used in the shop/part windows. A method called update_images() or similar goes through every module in the game (we need to register those somewhere), creates a texture for each, and renders an image of just that module onto the texture. These textures can be retrieved via some kind of get_image(std::string module) method.

Omegastick commented 4 years ago

Okay, here's the plan. We can do the rendering lazily to save performance rendering things that aren't really needed.

ModuleChooserWindow (or whatever it's called) calls ModuleImageStore::get(std::string module). ModuleImageStore checks it's cache and if it finds the matching image, it returns it straight away. If not, it passes the module name to ModuleFactory to get a fully constructed module. It makes a new texture, sets it up for drawing, and does a mini-render. It's going to need its own VectorRenderer for that. It stores the texture in its cache and returns a reference to it.