In my engine I have 2 types of 2D renderables: sprites and groups (and maybe primitives later). Sprites are just textured quads and groups are multiple renderables grouped in a single object. I have this drawcall system now:

struct Renderable
    virtual void Render(Renderer& renderer) = 0;

struct Sprite : public Renderable
    Texture& texture;
    // other sprite specific stuff
    void Render(Renderer& renderer) override { renderer.RenderSprite(...); }

struct Group : public Renderable
    vector<Renderable*> elements;
    // Other group related stuff like a transformation matrix
    void Render(Renderer& renderer) override
        for (Renderable* r : elements)

Instead of sendig them straight to the renderer, I need an indirection. This makes rendering many (like 20K) sprites super slow. Is there a better design to avoid indirection (or even abstraction)?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.