#API design

3 messages · Page 1 of 1 (latest)

spiral harness
#
struct IRenderable{
        virtual void draw(Renderer& renderer) = 0;

        virtual ~IRenderable() = default;
    };
struct Sprite : IRenderable{
  private:
        //Bounding rectangle
        FRect rect;
        //The thing to render, Either<Textuere*, Color>
        std::variant<Texture*, Color> to_render;
        //Rotation around origin
        double rotation;
        //Origin of rotation
        FPoint origin;
}
void Renderer::render(IRenderable& renderable) {
        renderable.draw(*this);
    }

Now I have the dilemma of Sprite being useful for rendering fixed colors but when I want to add eg. Text, its almost a sprite but it doesn't make sense to have the Color part of the Sprite, because a Text is always rendered as a texture.

This is a university assignment that is why I'm so pedantic about hierarchies here

lost geyserBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

spiral harness
#

I could also move the FRect rect part into IRenderable but idk