
#define BETRAY_PLUGGIN_KEYS
#define BETRAY_PLUGGIN_DEFINES
#include "betray.h"

#include "b_plugin_api_internal.h"

#ifdef BETRAY_PLUGGIN_POINTERS

/* This is the api to use if you want to write a plugin for Bertray


No NOT use funtions from betray.h but do use defines and typedefs

To build a library you need to include this file, betray.h, b_keys.h, 
b_plugin_api.c, b_plugin_api_internal.h and the files for the libs 
Forge (forge.h and files starting with "f_") and Imagine (imagine.h 
and files starting with "i_").

Your plug-in will need to implement:
 
void betray_plugin_init(void)

In this function you can then set upp all callbacks you need. See
b_plugin_templet.c for sample code.

*/

/* Functions to get access to betray state */
/* --------------------------------------- */

extern BInputState	*betray_plugin_get_input_state(void);
extern BContextType	betray_plugin_context_type_get();
extern double		betray_plugin_screen_mode_get(uint *x_size, uint *y_size, boolean *fullscreen);  
extern void			*betray_plugin_gl_proc_address_get(void);

/* Read and set clip board text */
/* --------------------------------------- */

extern void		betray_plugin_clipboard_set(char *text);
extern char		*betray_plugin_clipboard_get(void);


/* Callbacks you can set */
/* ------------------------------------ */

 /* set a callback for the main loop */
extern void		betray_plugin_callback_set_main(void (*main_loop)(BInputState *input)); /* set a callback for the main loop */

/* set a callback to update the vantage */
extern void		betray_plugin_callback_set_view_vantage(void (*vantage)(float *pos));

 /* set a callback to update the view direction 4X4 matrix */
extern void		betray_plugin_callback_set_view_direction(void (*matrix)(float *matrix));

 /* set a callback to give you access to windows event pump */
extern void		betray_plugin_callback_set_event_pump(uint event, boolean exclusive, void (*event_loop)(BInputState *input, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam));

 /* set a callback to give you access to the image as a texture, and lets you return a different texture for screen drawing */
extern void		betray_plugin_callback_set_image_warp(boolean (*image_warp)(BInputState *input));

extern void		betray_plugin_application_draw(uint fbo, uint x_size, uint y_size, float *vantage, float *matrix);

/* Sound call backs */
/* ------------------------------------ */

/*mirrors the betray sound API */
extern uint		betray_plugin_callback_set_audio_sound_create(uint (*func)(uint type, uint stride, uint length, uint frequency, void *data, char *name));
extern void		betray_plugin_callback_set_audio_sound_destroy(void (*func)(uint sound));
extern uint		betray_plugin_callback_set_audio_sound_play(uint (*func)(uint sound, float *pos, float *vector, float speed, float volume, boolean loop, boolean ambient));
extern void		betray_plugin_callback_set_audio_sound_set(void (*func)(uint play, float *pos, float *vector, float speed, float volume, boolean loop, boolean ambient));
extern void		betray_plugin_callback_set_audio_sound_stop(void (*func)(uint play));

extern void		betray_plugin_callback_set_audio_listener(void (*func)(float *pos, float *vector, float *forward, float *side, float scale));
extern void		betray_plugin_callback_set_audio_master_volume_set(void (*func)(float volume));
extern float	betray_plugin_callback_set_audio_master_volume_get(float (*func)(void));
extern void		betray_plugin_callback_set_audio_master_volume_silence_cutoff(void (*func)(float volume));


/* Allocate new buttons, pointers and axis */
/* --------------------------------------- */

#define BETRAY_PLUGGIN_UNDEFINED_KEY

extern uint		betray_plugin_button_allocate(uint code, char *name);
extern void		betray_plugin_button_set(uint id, boolean press, uint character);
extern void		betray_plugin_button_free(uint id);

extern uint		betray_plugin_pointer_allocate(uint code, char *name);
extern uint		betray_plugin_pointer_set(uint code, float x, float y, boolean *buttons);
extern void		betray_plugin_pointer_free(uint id);

extern uint		betray_plugin_axis_allocate(uint code, char *name, BAxisType type, uint axis_count);
extern void		betray_plugin_axis_set(uint id, float axis_x, float axis_y, float axis_z);
extern void		betray_plugin_axis_free(uint id);

/* Settings api to comunicate plugin settings to application */
/* --------------------------------------------------------- */

extern uint		betray_settings_create(BSettingType type, char *name, uint select_count, char **select_options);
extern uint		betray_settings_count();
extern BSettingType betray_settings_type(uint id);
extern char		*betray_settings_name(uint id);

extern boolean	betray_settings_toggle_get(uint id);
extern void		betray_settings_toggle_set(uint id, boolean toggle);

extern uint		betray_settings_select_get(uint id);
extern void		betray_settings_select_set(uint id, uint select);
extern uint		betray_settings_select_count_get(uint id);
extern char		*betray_settings_select_name_get(uint id, uint option);

extern float	betray_settings_number_float_get(uint id);
extern void		betray_settings_number_float_set(uint id, float number);

extern int		betray_settings_number_int_get(uint id);
extern void		betray_settings_number_int_set(uint id, int number);

extern float	betray_settings_slider_get(uint id);
extern void		betray_settings_slider_set(uint id, float slider);

extern void		betray_settings_2d_get(uint id, float *x, float *y);
extern void		betray_settings_2d_set(uint id, float x, float y);

extern void		betray_settings_3d_get(uint id, float *x, float *y, float *z);
extern void		betray_settings_3d_set(uint id, float x, float y, float z);

extern void		betray_settings_color_get(uint id, float *red, float *green, float *blue);
extern void		betray_settings_color_set(uint id, float red, float green, float blue);

extern void		betray_settings_4x4_matrix_get(uint id, float *matrix);
extern void		betray_settings_4x4_matrix_set(uint id, float *matrix);


/* Windows specific functionality */
/* --------------------------------------------------------- */

extern void		*betray_plugin_windows_window_handle_get(void);


#endif