gboisse / gfx

A minimalist and easy to use graphics API.
MIT License
498 stars 35 forks source link

Should gfxDestroy methods reset handles by default ? #90

Closed smeunier-amd closed 11 months ago

smeunier-amd commented 11 months ago

Instead of the common pattern :

gfxDestroyTexture(gfx_, accumulationDIBuffer);
accumulationDIBuffer = {};

Just doing :

gfxDestroyTexture(gfx_, accumulationDIBuffer);

With :

GfxResult gfxDestroyTexture(GfxContext context, GfxTexture& texture)
{
    GfxInternal *gfx = GfxInternal::GetGfx(context);
    if(!gfx) return kGfxResult_InvalidParameter;
    GfxResult result = gfx->destroyTexture(texture);
    texture = {}; // maybe test result ? maybe reset in destroyTexture ?
    return result;
}
gboisse commented 11 months ago

Yep, that's typical of C-style APIs I guess, bit annoying I agree.