Need some clarification on behavior's of Sprite #2546
Unanswered
meilleur102
asked this question in
Q&A - Sprites
Replies: 1 comment 1 reply
-
Hi, I think I've been bitten by this too, can you try changing the argument in iRacing.cpp from object copy to reference by adding an ampersand between TFT_eSprite and pitSprite, it should be In my case I was trying to use sprites inside STL containers, but the copy constructor kicks in when shuffling them around, and the destructor will delete allocated memory twice, since cloning is not implemented. I've tested them with these additions, @Bodmer could you include this? in Sprite.h #if __cplusplus >= 201103L
TFT_eSprite(const TFT_eSprite&) = delete; // disable cloning, not implemented
TFT_eSprite(TFT_eSprite&& source) noexcept; // enable moving instead
#endif and in Sprite.cpp #if __cplusplus >= 201103L
TFT_eSprite::TFT_eSprite(TFT_eSprite&& source) noexcept {
// move resource ownership from source to *this
// 1. transfer everything from source
memcpy(this, &source, sizeof(*this)); // TFT_eSprite must be trivially copyable
// 2. erase source by calling constructor on its own address
new (&source) TFT_eSprite(_tft);
// alternative: memset(&source, 0, sizeof(source));
}
#endif |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Sorry in advance, it will be a long one.
I've been playing with the Sprite a lot and I need some clarification on some thing that I can't do.
Function in the Main
Function in another cpp File
Main
iRacing.cpp
When everything is inside the Main loop everything work fine. But when I push the sprite from another class, I have some lag and even some reset from the board.
I try with the pitSprite.created() function, but still not working for me.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions