Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道如何将 SDL_Surface* 与 shared_ptr 连接起来? 我需要SDL_FreeSurface(SDL_Surface*)在删除之前打电话SDL_Surface。如何在 shared_ptr 中“修改删除过程”?
SDL_FreeSurface(SDL_Surface*)
SDL_Surface
只需将 SDL_FreeSurface 传递给构造函数:
std::shared_ptr<SDL_Surface> shared_surf(SDL_LoadBMP("foo.bmp"), SDL_FreeSurface);
请确保不要使用SDL_SetVideoModeor返回的指针执行此操作SDL_GetVideoSurface。
SDL_SetVideoMode
SDL_GetVideoSurface