u3d-community / U3D

Open-source, cross-platform 2D and 3D game engine built in C++
https://u3d.io
MIT License
160 stars 26 forks source link

Add E_DEVICERESET handle in AnimationSet2D and AnimatedSprite2D #36

Closed lucasvinbr closed 1 year ago

lucasvinbr commented 1 year ago

This should fix some AnimatedSprite2Ds breaking on openGL context lost. (issue #35)

I've tested demos 33, 49 and 50 on windows desktop, and fullscreen toggling seems to be fine now. Tested sample 49 in a web build and the sprites also didn't disappear.

I've added a "HasSpriteSheet" method to AnimatedSprite2D, to be able to only subscribe to E_DEVICERESET where it's really needed. AnimatedSprite2D needs to know about the reset in order to point to the rebuilt animationSet data.

I'm not a C++ guy, so I'm not sure if I did things the right way or forgot to clean up something. Maybe there's a better approach for reloading?

klaussilveira commented 1 year ago

@lucasvinbr this will need a quick rebase, but other than that, looks good!

SirNate0 commented 1 year ago

Also, I suspect the build may be failing because of a bad ccache result. If this is the case, I believe adding a [cache clear] line on the commit message should clear the cache.