Skip to content

Proper way to create a generic container of uniforms? #345

Description

@andrew-kennedy

In my program I'm trying to store a map of "global uniforms" where drawn meshes can optionally override these with their own internal maps of uniforms. I am really struggling to get it to compile though, what with needing a generic container. I am struggling to understand if the container should be of type unordered_map<string, AbstractUniform> or
unordered_map<string, ref_ptr<AbstractUniform>>.

As I understand it, I need to use the AbstractUniform abstract class in order to have containers of uniforms of arbitrary types. I would update these values by doing something like

container["modelview"]->as<glm::mat4>()->set(glm::mat4(1.0f));

However, I cannot figure out the necessary type signatures of functions to be able to pass around uniforms. I need to pass uniforms into my individual meshes, and I can't pass around a raw ref_ptr<AbstractUniform> because it can't be instantiated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions