3/13/2024 0 Comments Sdl2 load pngThose structs just need to be able to access the Texture while rendering so that I am carrying around a reference to the Texture of the sprite batch item that I computed. The issue with the explicit lifetime on Texture is that as soon as you have some complex structure that needs to access the Texture, you start propagating explicit lifetimes all over your code. Reply to this email directly or view it on GitHub: You are receiving this because you are subscribed to this thread. I hope someone could point me to the rightīy the time I'll read some documentations about the lifetime :). I understand that the texture is bound to the creator, but I have noĬlue how to achieve this. Note: borrowed value must be valid for the lifetime 'a as defined on / I have to find someone to own my creator.Įrror: `creator` does not live long enough Texture: creator.create_texture_from_surface(&surface).unwrap() The code above would allows me to have a texture and its creatorīut when I am creating a GameScene with the following code I have no clue of how to do such a things, I did some attempts:Ĭreator: &'a sdl2::render::TextureCreator, So here it is, the code bellow does not compile because the creator / I would create a texture once and store it. (such as the texture for example) the `GameScene`: So basically I wanted to have a structure that own some information _texture_from_surface(&surface).unwrap() Let surface: Surface = map_loader.load_png().unwrap() Sdl2::rwops::RWops::from_file(Path::new("assets/Overworld.png"), Something like the code bellow to get a texture, but I have to do it atĮach iteration of my game loop. I am stuck with the lifetime of the texture. I have some trouble to understand how I can manage the Texture and the Hello, First of all sorry for the newbee question.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |