[GB.SDL2]

* NEW: Font.DefaultHeight is a new constant that returns the height of the 
  default font.

[GB.SDL2.AUDIO]
* NEW: Sound.Play method has been implemented.


git-svn-id: svn://localhost/gambas/trunk@6784 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-12-31 15:49:49 +00:00
parent 9019886842
commit 7dca5a263a
4 changed files with 10 additions and 7 deletions

View file

@ -82,7 +82,7 @@ static void channel_finished_cb(int channel)
ch->free = (write(_pipe[1], &buf, 1) == 1); ch->free = (write(_pipe[1], &buf, 1) == 1);
} }
static void return_channel(int channel, CSOUND *sound) void CHANNEL_return(int channel, CSOUND *sound)
{ {
CCHANNEL *ch = NULL; CCHANNEL *ch = NULL;
@ -176,7 +176,7 @@ static void update_channel_effect(CCHANNEL *_object)
BEGIN_METHOD(Channels_get, GB_INTEGER index) BEGIN_METHOD(Channels_get, GB_INTEGER index)
return_channel(VARG(index), NULL); CHANNEL_return(VARG(index), NULL);
END_METHOD END_METHOD

View file

@ -48,6 +48,8 @@ extern GB_DESC ChannelsDesc[];
bool CHANNEL_init(void); bool CHANNEL_init(void);
void CHANNEL_exit(void); void CHANNEL_exit(void);
int CHANNEL_play_sound(int channel, CSOUND *sound, int loops, int fadein);
void CHANNEL_return(int channel, CSOUND *sound);
#endif /* __C_CHANNEL_H */ #endif /* __C_CHANNEL_H */

View file

@ -23,6 +23,7 @@
#define __C_SOUND_C #define __C_SOUND_C
#include "c_channel.h"
#include "c_sound.h" #include "c_sound.h"
#define THIS ((CSOUND *)_object) #define THIS ((CSOUND *)_object)
@ -106,18 +107,16 @@ BEGIN_PROPERTY(Sound_Volume)
END_PROPERTY END_PROPERTY
#if 0
BEGIN_METHOD(Sound_Play, GB_INTEGER loops; GB_FLOAT fadein) BEGIN_METHOD(Sound_Play, GB_INTEGER loops; GB_FLOAT fadein)
int loops = VARGOPT(loops, 0); int loops = VARGOPT(loops, 0);
int channel; int channel;
GB.Ref(THIS); GB.Ref(THIS);
channel = play_channel(-1, THIS, loops, MISSING(fadein) ? 0 : (int)(VARG(fadein) * 1000)); channel = CHANNEL_play_sound(-1, THIS, loops, MISSING(fadein) ? 0 : (int)(VARG(fadein) * 1000));
return_channel(channel, THIS); CHANNEL_return(channel, THIS);
END_METHOD END_METHOD
#endif
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -136,7 +135,7 @@ GB_DESC SoundDesc[] =
GB_PROPERTY("Volume", "i", Sound_Volume), GB_PROPERTY("Volume", "i", Sound_Volume),
//GB_METHOD("Play", "Channel", CSOUND_play, "[(Loops)i(FadeIn)f]"), GB_METHOD("Play", "Channel", Sound_Play, "[(Loops)i(FadeIn)f]"),
GB_END_DECLARE GB_END_DECLARE
}; };

View file

@ -501,6 +501,8 @@ GB_DESC FontDesc[] =
{ {
GB_DECLARE("Font", sizeof(CFONT)), GB_NOT_CREATABLE(), GB_DECLARE("Font", sizeof(CFONT)), GB_NOT_CREATABLE(),
GB_CONSTANT("DefaultHeight", "i", DEFAULT_FONT_HEIGHT),
GB_STATIC_METHOD("Load", NULL, Font_Load, "(Path)s[(Name)s]"), GB_STATIC_METHOD("Load", NULL, Font_Load, "(Path)s[(Name)s]"),
GB_STATIC_METHOD("_get", "Font", Font_get, "(Font)s"), GB_STATIC_METHOD("_get", "Font", Font_get, "(Font)s"),
GB_STATIC_METHOD("_exit", NULL, Font_exit, NULL), GB_STATIC_METHOD("_exit", NULL, Font_exit, NULL),