Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.82k stars 821 forks source link

Starling: Added a default texture smoothing option to configure it globally #1092

Closed Adolio closed 2 years ago

Adolio commented 2 years ago

Hey Daniel,

I have added a global parameter in the Starling class to override the default texture smoothing value which is used in MeshStyle, FragmentFilter & FilterEffect.

This allows for example to setup "trilinear" texture filtering everywhere by doing:

var myFavouriteBird:Starling = new Starling(...);
myFavouriteBird.textureSmoothing = TextureSmoothing.TRILINEAR;

☝️ Note: this doesn't update any pre-existing meshes & filters.

Best, Aurélien

PrimaryFeather commented 2 years ago

I can totally see that this might be useful – thanks for the pull request, Aurélien!

I'd rather name this new property defaultTextureSmoothing, though. That way, it's more apparent that this is just a default that can be overridden anytime. I admit it's a long word to type, but I still think it's worth it. :wink:

What do you say?

Adolio commented 2 years ago

I don't have any concern about renaming this variable, I'm usually the one which is complaining about variable & class names 😅

In this particular case I just wanted to mimic what was done for the antiAliasing but I understand that maybe it's slightly different since it's the "value" used as default.

So all good for me 👍

Adolio commented 2 years ago

I will do the changes ASAP.

PrimaryFeather commented 2 years ago

Hm, that similarity with antiAliasing is a good point. Give me a minute, I'll have another look!

PrimaryFeather commented 2 years ago

Okay, the difference is that Starling.antiAliasing really only influences the back buffer, which is handled by the Starling class. What you set here is actually used by Starling.

However, the textureSmoothing property is used by other classes and can be overridden at multiple places. So in that light, I think it makes sense to add that default prefix.

Thanks for mentioning it, though! I hate it when the API is inconsistent. 😉

Adolio commented 2 years ago

Perfect, this makes sense too me as well - by the way, I initially wanted to name it exactly that way 😉

PrimaryFeather commented 2 years ago

Perfect, this makes sense too me as well - by the way, I initially wanted to name it exactly that way

Haha, brilliant! Then go for it! 😄

Adolio commented 2 years ago

Here we go 🙂!

Adolio commented 2 years ago

Sorry I forgot to stage two files - the last commit is fine now.

PrimaryFeather commented 2 years ago

Perfect – thanks again! It's now part of the master branch. 😄