Asynchronous resource loading with SDL only

Hi.

How would I go about loading images asynchronously using SDL only (not working directly with OGL)?

I imagine we can’t use SDL calls that work with a renderer safely in various threads, so I wanted to know if it is possible to associate the renderer to another thread so we can use it in that thread. With an OpenGL rendering context this is easily done with SDL_GL_MakeCurrent (in SDLs case), but I haven’t found anything similar working with SDL renderers.

Thank you in advance.

Even though SDL_Render can?t be used it multiple threads, you can still load images from disk into RAM and decode them into bytes (those are both generally the most costly operations by far when loading images) in a separate thread, using e.g. SDL_Image or stb_image or LodePNG or whatever you?re using.
Once it?s loaded and decoded you can pass it to the main thread for use with SDL_Render.On Aug 9, 2014, at 4:18 PM, ShiroAisu wrote:

Hi.

How would I go about loading images asynchronously using SDL only (not working directly with OGL)?

I imagine we can’t use SDL calls that work with a renderer safely in various threads, so I wanted to know if it is possible to associate the renderer to another thread so we can use it in that thread. With an OpenGL rendering context this is easily done with SDL_GL_MakeCurrent (in SDLs case), but I haven’t found anything similar working with SDL renderers.

Thank you in advance.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Ok, then I’m thinking each time a loop starts I need to check if there are loaded images ready to be put into video memory, and if they are create the textures for them. Is this the idea or is there a better way of doing this?

Looks like i am refering to oryol quite often these days. It has async io
implemented. The code is on github. You might want to check it out.Am 09.08.2014 21:43 schrieb “ShiroAisu” :

Ok, then I’m thinking each time a loop starts I need to check if there
are loaded images ready to be put into video memory, and if they are create
the textures for them. Is this the idea or is there a better way of doing
this?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

OK, thank you very much.

OK, thank you very much.

Also, you can take a look at this

There’s no README and/or examples, so

and

ASS_Init(renderer); /* For loading textures */

SDL_Surface *sprites = NULL;
ASS_LoadSurfaceTO(&sprites, “sprites.bmp”);

/* Wait for assets to load (when using non-blocking calls) */
Uint32 files_left;
while ((files_left = ASS_GetProgress(NULL, NULL))) {
printf(“Files left: %d\n”, files_left);
SDL_Delay(100);
}

/* Freeing is not mandatory, ASS_Quit() will do that for you */
ASS_FreeSurface(sprites);

ASS_Quit();
SDL_Quit();On Sun, 10 Aug 2014 17:53:18 +0000 “ShiroAisu” wrote:


driedfruit