samedi 28 octobre 2023

Custom operator for SDL

I have a class, it have a operator which returns a SDL_Renderer

class renderer {
public:
  explicit renderer(SDL_Window *window);
  ~renderer() = default;

  operator const SDL_Renderer *() const;

private:
  renderer_ptr _renderer;
};

I would like to use it on a SDL_CreateTextureFromSurface.

SDL_CreateTextureFromSurface(r, surface)

Where r is const std::shared_ptr<renderer> r

I tried other ways, like

SDL_CreateTextureFromSurface(r.get(), surface)

and

SDL_CreateTextureFromSurface(*r, surface)

But no luck.

I remember that this used to work, but nowadays my C++ skills have rusted.

How can I use this operator while using a shared_ptr?

Aucun commentaire:

Enregistrer un commentaire