goto error;
I knew someone would say it's bad.
Well yes, I have to agree it's bad to do that C style goto error/fail/ret in C++, even though I'm the C leper of this forum usually.
Just use a RAII wrapper for it instead, that's MUCH better way to do things like that in C++.
0167aadb400215ac35e8453ff58e2650f5322499inline errorSVG( type_of_rast *rast , type_of_image *image , const char* error )
inline void errorSVG( type_of_rast *rast , type_of_image *image , const char* error )
A typo there.
you don't need to add SVG prefix on the method
He inherits from sf::Texture and so he'd hide the loadFromFile from sf::Texture if he named a method the same and it'd be hard to distinguish methods to load a file and an svg from just the parameter lists and overloading is nice but it shouldn't be abused to do stuff like:
int compute(int seed);
int compute(Randomizer * rnd);
int compute(const char * methodname);
It should be:
int computeFromSeed(int seed);
int computeFromRandomizer(Randomizer * rnd);
int computeByMethod(const char * methodname);
or something like that, overloading is fine but within reason.
This is accidentally one of my problems with nullptr, promoting overloading functions with complete impunity.
As for the library itself:
Manual memory management with malloc and free is a no-no in C++, obviously...
And the inheritance from sf::Texture is also a little worrying.
There's no need for it. To use this code you'll now need to replace textures in code with SVGTextures, which are not even SVG of any kind at all, just an SVG file rasterized into a normal Texture, or even a normal image Texture since you inherit everything so the SVGTexture can always replace the real Texture in code, even if the new load method is never used and the usage has nothing to do with SVG at all.
And since one big advantage of scalable vector graphics is not being raster graphics and being scalable and so on I think I'd enjoy a way to get a triangle strip vertex array with right colors and all more than just rasterizing but I have no idea if that's possible with that nanosvg library.
I mean, If I want to just rasterize an SVG I can do it offline (possibly few times with different settings) with way more capable tool and then just load the resulting png. It'd be bigger than the xml, but still small enough for practical purposes.