[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Major API change for SDL 0.9.11



I'm implementing "load-from-memory" for SDL_LoadWAV() and SDL_LoadBMP().
The most flexible way to do this is to implement a general data source
abstraction and allow you to define your own data sources.  This should
help people writing PAK file compilers and so forth.
Comments anybody?

0.9.11:
        SDL now has a data source abstraction which can encompass a file,
        an area of memory, or any custom object you can envision.  It uses
        these abstractions, SDL_RWops, in the endian read/write functions,
        and the built-in WAV and BMP file loaders.  This means you can load
        WAV chunks from memory mapped files, compressed archives, network
	pipes, or anything else that has a data read abstraction.

        There are three built-in data source abstractions:
                SDL_RWFromFile(), SDL_RWFromFP(), SDL_RWFromMem()
        along with a generic data source allocation function:
                SDL_AllocRW()
        These data sources can be used like stdio file pointers with the
        following convenience functions:
                SDL_RWseek(), SDL_RWread(), SDL_RWwrite(), SDL_RWclose()
        These functions are defined in the new header file "SDL_rwops.h"
        
        The endian swapping functions have been turned into macros for speed.
        
        The endian read/write functions now take an SDL_RWops pointer
        instead of a stdio FILE pointer, to support the new data source
        abstraction.

        The SDL_*LoadWAV() functions have been replaced with a single
        SDL_LoadWAV() function that takes a SDL_RWops pointer as it's
        first parameter, and a flag whether or not to automatically
        free it as the second parameter.  You can still load WAV files
        in one line:
                SDL_LoadWAV(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
        The SDL_LoadWAV() function will close the opened file automatically.

        The SDL_*LoadBMP() functions have been replaced with a single
        SDL_LoadBMP() function that takes a SDL_RWops pointer as it's
        first parameter, and a flag whether or not to automatically
        free it as the second parameter.  You can still load BMP files
        in one line:
                SDL_LoadBMP(SDL_RWFromFile("sample.bmp", "rb"), 1, ...);
        The SDL_LoadBMP() function will close the opened file automatically.

See ya!
	-Sam Lantinga				(slouken@devolution.com)

Lead Programmer, Loki Entertainment Software
--
Author of Simple DirectMedia Layer -
	http://www.devolution.com/~slouken/SDL/
--