#ifndef _MOUSE_H
#define _MOUSE_H
/*=
Mouse
1100
**/

// Introduction
/**
Mouse API is almost explainded at the top of this guide, but here it
is some other usefull functions (macros, in fact).
**/


#define raydium_mouse_hide() glutSetCursor(GLUT_CURSOR_NONE);
/**
Hides mouse cursor.
**/

#define raydium_mouse_show() glutSetCursor(GLUT_CURSOR_LEFT_ARROW);
/**
Shows mouse cursor.
**/

__rayapi void raydium_mouse_move(int x, int y);
/**
Moves cursor to (##x##,##y##) position (in pixel).
Example if you want to move cursor at window's center:
%%(c)raydium_mouse_move(raydium_window_tx/2, raydium_window_ty/2);%%
**/

__rayapi signed char raydium_mouse_isvisible(void);
/**
Returns true or false (0 or 1), if the mouse is visible or not.
See ##raydium_mouse_show()## and ##raydium_mouse_hide()## above.
**/

__rayapi void raydium_mouse_init (void);
/**
Internal use.
**/

__rayapi void raydium_mouse_click_callback (int but, int state, int x, int y);
/**
Internal callback.
**/

__rayapi void raydium_mouse_move_callback (int x, int y);
/**
Internal callback.
**/

__rayapi int raydium_mouse_button_pressed (int button);
/**
returns ##button## state. (See first part of this document)
**/

// Mouse Wheel
/**
To get the mouse wheel status you have to check directly the variable
##raydium_mouse_click##.
 -Value 4 means "mouse wheel up".
 -Value 5 means "mouse wheel down".
Usage example:
%%(c)
if (raydium_mouse_click==4)
	zoom*=1.1f;
if (raydium_mouse_click==5)
	zoom*=0.9f;
%%
This piece of code will change the value of zoom according mouse wheel.
**/

__rayapi void raydium_mouse_grab_delta(int *x, int *y);
/**
This function will "grab" the mouse and return mouse moves since last call.
Output parameters ##x## and ##y## will gives you the delta.

You can yse this function for any "FPS like" mouse look controls, or any other
situation where you need to known how far the user moves the mouse since
the last frame.

This function now use a box model, so its compliant with all window sizes,
even odd ones.
**/

#endif
*a);
/**
Since OpenAL is very sensitive to malformed values, this function is used
internally to check consistency of provided ALfloat arrays.
**/

__rayapi void raydium_sound_InitSource (int src);
/**
Internal use.
**/

__rayapi int raydium_sound_LoadWav (const char *fname);
/**
This function tries to load the ##fname## wav file into a buffer, if
successful, it returns the source id, else 0.
**/

__rayapi int raydium_sound_SourceVerify (int src);
/**
Internal id checks.
**/

__rayapi int raydium_sound_SetSourceLoop (int src, signed char loop);
/**
Modifies the ##loop## property of the ##src## source (loops if loop is non-zero,
default value for a source is "true").
Returns 0 if ok, -1 if error.
**/

__rayapi int raydium_sound_GetSourcePitch (int src, ALfloat * p);
/**
Returns current pitch for ##src## source.
**/

__rayapi int raydium_sound_SetSourcePitch (int src, ALfloat p);
/**
Sets pitch for ##src## source.
Current OpenAL spec is not clear about pitch's limits. Raydium will
clamp values to to ]0,2] interval.
**/

__rayapi int raydium_sound_GetSourceGain (int src, ALfloat * g);
/**
Returns current gain ("volume") for ##src## source.
**/

__rayapi int raydium_sound_SetSourceGain (int src, ALfloat g);
/**
Sets gain ("volume") for ##src## source.
Current OpenAL spec is not clear about pitch's limits. Raydium do not allows
negative values, but no upper limit is set.
Warning: some OpenAL implementations will provide strange gain curves. More
work is needed on this issue.
**/

__rayapi int raydium_sound_SetSourceRefDist(int src, ALfloat distance);
/**
Sets reference distance for source ##src##. The reference distance is
the distance where the sound will be half-volume.
**/

__rayapi int raydium_sound_SetSourcePos (int src, ALfloat Pos[]);
/**
Sets 3D position of ##src## source.
##Pos## is a 3 * ALfloat array.
**/

__rayapi int raydium_sound_SetSourcePosCamera(int src);
/**
Sets 3D position of ##src## source on the current camera position.
**/

__rayapi int raydium_sound_GetSourcePos (int src, ALfloat * Pos[]);
/**
Returns current 3D position of ##src## source.
##Pos## is a 3 * ALfloat array.
**/

__rayapi int raydium_sound_SetSourceDir (int src, ALfloat Dir[]);
/**
Sets 3D direction of ##src## source.
##Dir## is a 3 * ALfloat array.
**/

__rayapi int raydium_sound_GetSourceDir (int src, ALfloat * Dir[]);
/**
Returns current 3D direction of ##src## source.
##Dir## is a 3 * ALfloat array.
**/

__rayapi int raydium_sound_SetSourceVel (int src, ALfloat Vel[]);
/**
Sets 3D velocity of ##src## source.
##Vel## is a 3 * ALfloat array.
**/

__rayapi int raydium_sound_GetSourceVel (int src, ALfloat * Vel[]);
/**
Returns current 3D velocity of ##src## source.
##Vel## is a 3 * ALfloat array.
**/

__rayapi void raydium_sound_SetListenerPos (ALfloat Pos[]);
/**
Sets 3D position of listener.
This is done automatically by Raydium, each frame, using camera informations
##Pos## is a 3 * ALfloat array.
**/

__rayapi void raydium_sound_GetListenerPos (ALfloat * Pos[]);
/**
Returns current 3D position of listener.
##Pos## is a 3 * ALfloat array.
**/

__rayapi void raydium_sound_SetListenerOr (ALfloat Or[]);
/**
Sets 3D orientation of listener.
This is done automatically by Raydium, each frame, using camera informations
##Or## is a 3 * ALfloat array.
**/

__rayapi void raydium_sound_GetListenerOr (ALfloat * Or[]);
/**
Returns current 3D orientation of listener.
##Or## is a 3 * ALfloat array.
**/

__rayapi void raydium_sound_SetListenerVel (ALfloat Vel[]);
/**
Sets 3D velocity of Listener.
##Vel## is a 3 * ALfloat array.
**/

__rayapi void raydium_sound_GetListenerVel (ALfloat * Vel[]);
/**
Returns current 3D velocity of Listener.
##Vel## is a 3 * ALfloat array.
**/

__rayapi void raydium_sound_init (void);
/**
Internal use.
**/

__rayapi int raydium_sound_SourcePlay (int src);
/**
Plays the ##src## source.
If ##src## was already in "play" state, the buffer is rewinded.
Returns 0 if ok, -1 if error.
**/

__rayapi int raydium_sound_SourceStop (int src);
/**
Stops the ##src## source.
Returns 0 if ok, -1 if error.
**/

__rayapi int raydium_sound_SourcePause (int src);
/**
Will pause the ##src## source.
Returns 0 if ok, -1 if error.
**/

__rayapi int raydium_sound_SourceUnpause (int src);
/**
##src## will restart playback after being paused.
Returns 0 if ok, -1 if error.
**/

__rayapi signed char raydium_sound_IsPlaying(int src);
/**
Returns true (1) if ##src## is playing, false (0) if stopped or invalid.
**/


__rayapi void raydium_sound_close (void);
/**
Internal use.
**/

__rayapi int BufferData (ALuint buffer, OggVorbis_File * file, vorbis_info * ogginfo);
__rayapi void raydium_sound_internal_cleanstreambuffs (void);
__rayapi int StartMusic (ALuint musicsource, ALuint * buffers, OggVorbis_File * file, vorbis_info * ogginfo);
__rayapi int raydium_sound_load_music (char *fname);
/**
Opens fname **OGG** music file and prepairs Raydium for playing it.
The music will be automatically played after a call to this function.
This function will use R3S (data repositories) if needed.
To switch to another audio track, simply call again this function.
Send ##NULL## or an empty string to cancel music playback.
Returns 0 if ok, -1 if error

See also ##raydium_sound_music_eof_callback## at the top of this chapter.

You can get OGG informations from ##raydium_sound_music_info##, using
its members:
%%(c)
char artist[RAYDIUM_MAX_NAME_LEN];
char title [RAYDIUM_MAX_NAME_LEN];
char album [RAYDIUM_MAX_NAME_LEN];
%%
**/

__rayapi void raydium_sound_music_info_init(void);
/**
Internal use. Will reset infos.
**/

__rayapi void raydium_sound_music_info_refresh(void);
/**
Internal use. Will flush infos from disk to ##raydium_sound_music_info##.
**/


__rayapi void raydium_sound_music_callback (void);
/**
Internal use.
**/

__rayapi void raydium_sound_callback (void);
/**
Internal use.
**/

__rayapi void raydium_sound_source_fade(int src, ALfloat len);
/**
This function will fade down source ##src## over ##len## seconds.
Since gain is not linear, you may have to play a bit with ##len## to
find the correct value for you.
Use source 0 for music source.
**/

// Sound API Example
/**
%%(c)
int sound;
sound=raydium_sound_LoadWav("explo.wav");
raydium_sound_SetSourceLoop(sound,0);
[...]
if(explosion) raydium_sound_SourcePlay(sound);
%%
**/

__rayapi void raydium_sound_source_fade_to(int src, ALfloat len, char *to);
/**
Same as above, but plays ##to## file at the end of the fade.
Warning: Works only for "music" source (##src## = 0).
**/

#endif