construction of the image from PNG input is 18ms in average.construction of the image from BMP input is 3ms in average.disk access for PNG is 0.05ms in average (makes sense considering the files are way smaller).SDL_Surface* image = SDL_LoadBMP_RW(input, 0) // or IMG_Load_RW()įeeding some of my images to a similar, profiling code, here are some results: SDL_RWops* input = SDL_RWFromMem(buffer.data(), buffer.size()) Constructing the image from RAM access Std::vector buffer = file_to_buffer(filename) It looks like: // Reading from the disk (custom function) Ideally, I’d like to get the loading times of SDL_LoadBMP(), but using BMP files really seems like an overkill in terms of disk usage (my simple small 2D game would end up weighing several GB).Īnother interesting part: I also did some profiling but separating the file reading itself (which requires disk access, which I know is very costly) and the construction of the SDL image itself. So far I’ve continued using the latest variant, which gives me quite small files with an average loading time. lossy compressed PNG (again, using pngquant) are “only” 2 to 5 times longer to load than BMP, with files 50 to 120 times smaller.“standard” PNG files take in average 10 times longer to load with IMG_Load() than BMP, but files are 10 to 20 times smaller.using uncompressed bitmaps BMP files with SDL_LoadBPM() loads very fast, but of course the files are also very big.I’ve been doing some profiling on the image loading parts of the SDL functions, and here’s something interesting: Considering my images come from vector drawing (with large flat areas), using pngquant allows to substantially reduce the weight of the image files. Now to the technical part: I’m using PNG compressed images. ![]() Of course, the game runs at 1920x1080 and the images are thus quite big (especially the animations), but still. But considering it’s “just” a modest 2D game, it seems like a lot (I would expect, as a player, a loading time less than 1 second per level). Of course, these timings are not terrible. Overall, for a big level, it can take up to 5 seconds on a recent computer (and up to 10 or 15 seconds on a small tablet for example). So far it’s going very well and it’s been a pleasure to use the SDL, but there’s a little thing that’s been bothering me for a while: how long it takes to load the input images. I’m developing a small 2D point’n’click game using C++ with SDL2. ![]() A bit of a technical question about image formats.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |