CSFML icon indicating copy to clipboard operation
CSFML copied to clipboard

[Question] Loading sRGB textures

Open silverweed opened this issue 4 years ago • 5 comments

I cannot figure out how to load an sRGB texture from disk (or memory, or image) in CSFML. In SFML, if I understand it correctly, you would do:

sf::Texture texture;
texture.setSrgb(true);
texture.loadFromFile(...);

But in CSFML this is not possible since the loadFrom functions are not exposed directly. Is it currently possible at all to load an sRGB texture? Am I missing something?

silverweed avatar May 11 '20 10:05 silverweed

IIRC:

sfTexture *texture;
sfTexture_loadFromFile(texture, "filepath");

LoneWolfHT avatar May 11 '20 15:05 LoneWolfHT

Indeed. This looks like a missing feature in CSFML.

LaurentGomila avatar May 11 '20 16:05 LaurentGomila

So would that work along the lines of:

sfTexture *texture = sfTexture_createEmpty(); // <- this function needs to be created
sfTexture_setSrgb(texture, true);
sfTexture_loadFromFile(texture, file); // <- this function needs to be created
// ...
sfTexture_destroy(texture);

?

I can implement this if this design is agreed upon.

silverweed avatar May 12 '20 07:05 silverweed

Or an extra srgb argument to all the create functions. I should make a quick review of the sfTexture API to figure out what's best.

LaurentGomila avatar May 12 '20 08:05 LaurentGomila

I think the version with create + setSrgb + load, while more verbose, is basically the same as the SFML way of doing that, thus it's what I would expect I'd have to do in CSFML also. If CSFML wants to be just a binding API for SFML I think the functions should behave the same way, and since there is no "srgb" extra argument in SFML, IMHO there shouldn't be one in CSFML either (unless of course that extra argument is also added to the sf::Texture constructor).

silverweed avatar May 14 '20 08:05 silverweed

Any updates?

therealbluepandabear avatar Dec 13 '22 04:12 therealbluepandabear

No updates. Kind of forgot about this issue and Laurent hasn't followed up on it either.

eXpl0it3r avatar Dec 16 '22 14:12 eXpl0it3r

@therealbluepandabear This has been addressed now, just awaiting the review process to finish on #177 and then it will be in master. That doesn't mean you'll have access to it straight away in D since I assume the binding is pinned to 2.5.1. I believe (and @eXpl0it3r can confirm this for us) that there is a plan to do a 2.5.2 release for CSFML prior to 2.6.0.

Bambo-Borris avatar Dec 23 '22 15:12 Bambo-Borris

This should be fixed with #177

eXpl0it3r avatar Dec 25 '22 22:12 eXpl0it3r