DemoGL::About::I/O support

I/O support.

To play soundfiles, to use textures, to show 3D modeldata, a developer needs to load files. DemoGL provides, both in the API and in scriptcommands, functionality to load files and to make DemoGL load the files from a certain location. DemoGL's file I/O system is transparent for the developer: where the files are located is set at the startup of the application and when the application loads a file, the exact location is not specified. This makes it possible to use the same functions to load a file from a datafile or a directory. A datafile is an ordinary .zip archive with directories in it, a directory is a normal directory on the harddisk. Because the API functionality and the TLE syntax don't use physical path information but rely on what DemoGL uses as the source of the files: a datafile or a directory, you can easily first use a directory during development and then place all files and subdirectories in one datafile and just tell DemoGL to use that datafile instead. No file loading API calls nor TLE's have to be changed to support the datafile instead of the directory.

To set the source of all the files the application will load, use DEMOGL_SetVariable to set the variable DGL_VF_FILESRC to either DGL_FSRC_LOADFROMDATAFILE to read from a datafile or DGL_FSRC_LOADFROMDIR to read from a directory. Use the DGL_VF_SRCDIR variable to set the name (i.e. the full path if the directory is not located in the directory where the application is located) of the directory and DGL_VF_DATAFILENAME to set the name of the datafile, including the full path, if the datafile is not located in the same directory as the application. Be aware of the fact that DemoGL needs to know the source of all the files before application execution starts (i.e. when DEMOGL_AppRun is called). DemoGL expects the systex directory and the application script in the root of the datafile, when loading from a datafile or in the directory itself when loading from a directory.

After the source for all the files is set and application execution is started, files can be loaded. DemoGL supports special purpose loading functions to load data automatically into internal structures (texturedata, sound elements) and a normal filedata loading function (binary data). For sound elements a developer can use TLE's or the API function DEMOGL_SoundSystemLoadElement to load a sound element into the soundsystem. To load a sound element by using a TLE in the script, see _SOUNDSYSTEM syntax for more details. For texture data, DemoGL provides special purpose API functions to load jpeg, bmp and tga data and to convert the contents of these files into RGBA8 bitmaps which are stored as textures in the texturestore inside DemoGL. Use DEMOGL_TextureLoad to load a jpeg, bmp or tga stored bitmap straight into a texture object inside DemoGL. For loading binary data into your application (for example to decode PNG or RAW textures into RGBA8 bitmaps) DemoGL provides the DEMOGL_FileLoad function.

All loading functionality in DemoGL has logic to free the loaded data. Allthough DemoGL cleans up everything that is loaded when the application is closed, it's recommended to free any loaded data when that data is not used anymore.



Last changed on 11-mar-2001

©1999-2001 Solutions Design