
/*
 * The following ifdef block is the standard way of creating macros which make exporting 
 * from a DLL simpler. All files within this DLL are compiled with the SDL_CONFIG_EXPORTS
 * symbol defined on the command line. this symbol should not be defined on any project
 * that uses this DLL. This way any other project whose source files include this file see 
 * SDL_CONFIG_API functions as being imported from a DLL, wheras this DLL sees symbols
 * defined with this macro as being exported.
 */
#ifndef __sdl_config_h
#define __sdl_config_h

#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include "SDL.h"
#include "SDL_mixer.h"

#ifdef SDL_CONFIG_EXPORTS
#define SDL_CONFIG_API __declspec(dllexport)
#else
#define SDL_CONFIG_API __declspec(dllimport)
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* SDL_Config data structure
 */
typedef struct
{
	Uint32 subSystems;				// What SDL subsystems to initialize
	// Video
	int width;						// pixels wide
	int height;						// pixels high
	int bpp;						// bits per pixel (0, 8, 16, 24 or 32)
	Uint32 videoFlags;				// if windowed/fulscreen, hardware surfaces, etc...
	char * videoDriver;				// what video driver to use (windib, directx, etc..)
	// Audio
	int frequency;					// samples per second
	int channels;					// 1 == mono, 2 == stereo
	Uint16 format;					// bits per sample (8 or 16) and signed/unsigned
	int audioBuffers;				// how many samples to prebuffer?
	char * audioDriver;				// what audio driver to use (dsound, waveout, etc..)
} SDL_Config_Struct;


int setStringOption ( char * value, char ** destination );
int processOption ( char * option, SDL_Config_Struct * config );


/* This particular instantiation of the SDL_Config_Struct
 * represents the state set by the SDL_Init/SDL_InitSubSystem
 * calls.  (ie:  if you're not going to use SDL_Config functions,
 * SDL will maintain its own struct and this is it)
 * May want to add a function that returns a pointer to this?
 */
extern SDL_CONFIG_API SDL_Config_Struct SDL_Config_CurrentConfig;



/* Set a few defaults, hopefully these will mean a succesful
 * init on ANY platform should they be used without modification
 */
extern SDL_CONFIG_API void SDL_Config_DefaultConfig ( SDL_Config_Struct * config );


/* Load an SDL_Config_Struct from an ini-like file (pointed to by fileName) 
 * and stuff the results in the provided reference
 */
extern SDL_CONFIG_API int SDL_Config_LoadConfig ( char * fileName, SDL_Config_Struct * config );


/* This function behaves pretty much like SDL_Init, except
 * it works with the SDL_Config_Struct struct. 
 * Call once to initialize SDL according to the struct
 */
extern SDL_CONFIG_API SDL_Surface * SDL_Config_Init ( SDL_Config_Struct * config );

/* This function behaves like SDL_Quit, except
 * it is aware of the SDL_Mixer and will close
 * any audio correctly.
 */
extern SDL_CONFIG_API void SDL_Config_Quit ( );


/* Call this when you are done with a SDL_Config_Struct
 * to deallocate it.
 */
extern SDL_CONFIG_API void SDL_Config_FreeConfig ( SDL_Config_Struct * config );


#ifdef __cplusplus
}
#endif

#endif