SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Data Structures | Defines | Functions | Variables

# SgeResource

Resource handling functions. More...

## Data Structures
struct | SGEFILE
## Defines
#define | sgeDecryptBuffer sgeEncryptBuffer
## Functions
SGEFILE * | sgeOpenFile (const char *filename, const char *encryptionkey)
| Open a sge archive created with sga.
void | sgeCloseFile (SGEFILE *f)
| Close a sge archive and free its memory resources.
void | sgeCreateFile (const char *filename, char *filenames[], Uint32 numberOfFiles, const char *encryptionkey)
| Create a new sge archive.
int | sgeGetFileIndex (SGEFILE *f, const char *filename)
| Return the index a file is in the archives lookup table.
Uint32 | sgeGetFileSize (SGEFILE *f, const char *filename)
| Return the size of a file in the archive.
void * | sgeReadFile (SGEFILE *f, const char *filename)
| Read a file from the archive to memory.
SDL_Surface * | sgeReadImage (SGEFILE *f, const char *filename)
| Read a video accelerated image file from archive.
SDL_Surface * | sgeReadImageMemory (SGEFILE *f, const char *filename)
| Read a image file from archive into RAM.
Mix_Chunk * | sgeReadSound (SGEFILE *f, const char *filename)
| Read a sound file from archive.
SDL_Surface * | sgeDuplicateSDLSurface (SDL_Surface *s)
| Duplicate a sdl surface.
## Variables
int | SGEFILE::numberOfFiles
| The number of files contained in the archive.

## Detailed Description

Resource handling functions.

Functions to handle resources like encrypted files, images, audio data, ...

## Function Documentation

void sgeCreateFile | ( | const char * | filename,
|  | char * | filenames[],
|  | Uint32 | numberOfFiles,
|  | const char * | encryptionkey
| ) |  |

Create a new sge archive.

Parameters:

  filename | The name of the new sge archive
  filenames | A list of char pointers of the filenames to add to the archive
  numberOfFiles | The number of files to add to the archive
  encryptionkey | The password

Use this function only if for some reason you need to create a archive yourself. If you just want to pack data for your game it is recommended to use the commandline utility 'sga' which is in the 'tools' directory.

Definition at line 109 of file sgeresource.c.

SDL_Surface* sgeDuplicateSDLSurface | ( | SDL_Surface * | s | ) |

Duplicate a sdl surface.

Parameters:

  s | A SDL_Surface aka image

Returns:
  A copy of s

Definition at line 239 of file sgeresource.c.

int sgeGetFileIndex | ( | SGEFILE * | f,
|  | const char * | filename
| ) |  |

Return the index a file is in the archives lookup table.

Parameters:

  f | A SGEFILE oject
  filename | The filename to search for

Returns:
  A integer with the index of the file

Definition at line 167 of file sgeresource.c.

Uint32 sgeGetFileSize | ( | SGEFILE * | f,
|  | const char * | filename
| ) |  |

Return the size of a file in the archive.

Parameters:

  f | A SGEFILE oject
  filename | The filename to search for

Returns:
  The size of the file

Definition at line 177 of file sgeresource.c.

SGEFILE* sgeOpenFile | ( | const char * | filename,
|  | const char * | encryptionkey
| ) |  |

Open a sge archive created with sga.

Parameters:

  filename | The name of the archive file
  encryptionkey | The password of the file

Returns:
  A SGEFILE struct

A sge archive is not automatically read into memory, it may be much larger then the available ram. Think of it more like a encrypted disk image.

Please note, this uses a very simple encryption. It is meant to prevent standard users from extracting your game data. It is not hack safe and is not intended to hold real security relevand information.

Definition at line 31 of file sgeresource.c.

void* sgeReadFile | ( | SGEFILE * | f,
|  | const char * | filename
| ) |  |

Read a file from the archive to memory.

Parameters:

  f | A SGEFILE object
  filename | The filename to read

Returns:
  A void pointer to the file data

Definition at line 182 of file sgeresource.c.

SDL_Surface* sgeReadImage | ( | SGEFILE * | f,
|  | const char * | filename
| ) |  |

Read a video accelerated image file from archive.

Parameters:

  f | A SGEFILE object
  filename | The filename to read

Returns:
  A video accelerated SDL_Surface struct with the image

The image will be hold in video ram if possible, use only on images you really need for your actual game drawing functions.

Definition at line 218 of file sgeresource.c.

SDL_Surface* sgeReadImageMemory | ( | SGEFILE * | f,
|  | const char * | filename
| ) |  |

Read a image file from archive into RAM.

Parameters:

  f | A SGEFILE object
  filename | The filename to read

Returns:
  A SDL_Surface struct with the image

The image will be hold in the computers RAM. Use on images that are not that important to draw fast, otherwise use sgeReadImage

Definition at line 222 of file sgeresource.c.

Mix_Chunk* sgeReadSound | ( | SGEFILE * | f,
|  | const char * | filename
| ) |  |

Read a sound file from archive.

Parameters:

  f | A SGEFILE object
  filename | The filename to read

Returns:
  A Mix_Chunk struct with the sound file

Definition at line 226 of file sgeresource.c.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines