Major developments to love.audio/love.sound. Music and Sound are gone. There are only Sources now, which is much cleaner.

The audio module was not really stable in 0.6.0, it takes very little messing around to cause OpenAL to do horrible things. It should now be much more stable,
and you *should* be able to play/stop/pause/resume/rewind/loop like a madman without disasters. Seek and tell, however, are still not tested and verified for
all decoders, but that's less important. Also, all objects now have object:type() and object:typeOf(), which returns the type name of the object,
and checks whether an object is of a certain type, respectively.
This commit is contained in:
rude
2010-01-31 11:52:54 +01:00
parent 8e74574544
commit 5b30c7fcfe
51 changed files with 894 additions and 1693 deletions
+83
View File
@@ -24,6 +24,7 @@
#include "Module.h"
#include "Object.h"
#include "Reference.h"
#include "StringMap.h"
// STD
#include <iostream>
@@ -50,6 +51,14 @@ namespace love
return 1;
}
static int w__typeOf(lua_State * L)
{
Proxy * p = (Proxy *)lua_touserdata(L, 1);
Type t = luax_type(L, 2);
luax_pushboolean(L, p->flags.at(t));
return 1;
}
Reference * luax_refif(lua_State * L, int type)
{
Reference * r = 0;
@@ -178,6 +187,15 @@ namespace love
lua_pushcclosure(L, w__tostring, 1);
lua_setfield(L, -2, "__tostring");
// Add tostring to as type() as well.
lua_pushstring(L, tname);
lua_pushcclosure(L, w__tostring, 1);
lua_setfield(L, -2, "type");
// Add typeOf
lua_pushcfunction(L, w__typeOf);
lua_setfield(L, -2, "typeOf");
if(f != 0)
luaL_register(L, 0, f);
@@ -316,5 +334,70 @@ namespace love
}
}
StringMap<Type, TYPE_MAX_ENUM>::Entry typeEntries[] =
{
{"Invalid", INVALID_ID},
{"Object", OBJECT_ID},
{"Data", DATA_ID},
{"Module", MODULE_ID},
// Filesystem
{"File", FILESYSTEM_FILE_ID},
{"FileData", FILESYSTEM_FILE_DATA_ID},
// Font
{"GlyphData", FONT_GLYPH_DATA_ID},
{"Rasterizer", FONT_RASTERIZER_ID},
// Graphics
{"Drawable", GRAPHICS_DRAWABLE_ID},
{"Image", GRAPHICS_IMAGE_ID},
{"Quad", GRAPHICS_QUAD_ID},
{"Glyph", GRAPHICS_GLYPH_ID},
{"Font", GRAPHICS_FONT_ID},
{"ParticleSystem", GRAPHICS_PARTICLE_SYSTEM_ID},
{"SpriteBatch", GRAPHICS_SPRITE_BATCH_ID},
{"VertexBuffer", GRAPHICS_VERTEX_BUFFER_ID},
// Image
{"ImageData", IMAGE_IMAGE_DATA_ID},
// Audio
{"Source", AUDIO_SOURCE_ID},
// Sound
{"SoundData", SOUND_SOUND_DATA_ID},
{"Decoder", SOUND_DECODER_ID},
// Physics
{"World", PHYSICS_WORLD_ID},
{"Contact", PHYSICS_CONTACT_ID},
{"Body", PHYSICS_BODY_ID},
{"Shape", PHYSICS_SHAPE_ID},
{"CircleShape", PHYSICS_CIRCLE_SHAPE_ID},
{"PolygonShape", PHYSICS_POLYGON_SHAPE_ID},
{"Joint", PHYSICS_JOINT_ID},
{"MouseJoint", PHYSICS_MOUSE_JOINT_ID},
{"DistanceJoint", PHYSICS_DISTANCE_JOINT_ID},
{"PrismaticJoint", PHYSICS_PRISMATIC_JOINT_ID},
{"RevoluteJoint", PHYSICS_REVOLUTE_JOINT_ID},
{"PulleyJoint", PHYSICS_PULLEY_JOINT_ID},
{"GearJoint", PHYSICS_GEAR_JOINT_ID},
// The modules themselves. Only add abstracted modules here.
{"filesystem", MODULE_FILESYSTEM_ID},
{"image", MODULE_IMAGE_ID},
{"sound", MODULE_SOUND_ID},
};
StringMap<Type, TYPE_MAX_ENUM> types(typeEntries, sizeof(typeEntries));
Type luax_type(lua_State * L, int idx)
{
Type t = INVALID_ID;
types.find(luaL_checkstring(L, idx), t);
return t;
}
} // love
+2
View File
@@ -252,6 +252,8 @@ namespace love
**/
int luax_getregistry(lua_State * L, Registry r);
Type luax_type(lua_State * L, int idx);
/**
* Converts the value at idx to the specified type without checking that
* this conversion is valid. If the type has been previously verified with
+9 -13
View File
@@ -28,8 +28,9 @@ namespace love
{
enum Type
{
INVALID_ID = 0,
// Cross-module types.
OBJECT_ID = 0,
OBJECT_ID,
DATA_ID,
MODULE_ID,
@@ -46,8 +47,6 @@ namespace love
GRAPHICS_IMAGE_ID,
GRAPHICS_QUAD_ID,
GRAPHICS_GLYPH_ID,
GRAPHICS_ANIMATION_ID,
GRAPHICS_COLOR_ID,
GRAPHICS_FONT_ID,
GRAPHICS_PARTICLE_SYSTEM_ID,
GRAPHICS_SPRITE_BATCH_ID,
@@ -57,9 +56,6 @@ namespace love
IMAGE_IMAGE_DATA_ID,
// Audio
AUDIO_AUDIBLE_ID,
AUDIO_SOUND_ID,
AUDIO_MUSIC_ID,
AUDIO_SOURCE_ID,
// Sound
@@ -87,10 +83,12 @@ namespace love
MODULE_SOUND_ID,
// Count the number of bits needed.
BIT_SIZE
TYPE_MAX_ENUM
};
typedef std::bitset<BIT_SIZE> bits;
typedef std::bitset<TYPE_MAX_ENUM> bits;
const bits INVALID_T = bits(1) << INVALID_ID;
const bits OBJECT_T = bits(1) << OBJECT_ID;
const bits DATA_T = (bits(1) << DATA_ID) | OBJECT_T;
@@ -108,8 +106,6 @@ namespace love
const bits GRAPHICS_IMAGE_T = (bits(1) << GRAPHICS_IMAGE_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_QUAD_T = (bits(1) << GRAPHICS_QUAD_ID) | OBJECT_T;
const bits GRAPHICS_GLYPH_T = (bits(1) << GRAPHICS_GLYPH_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_ANIMATION_T = (bits(1) << GRAPHICS_ANIMATION_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_COLOR_T = (bits(1) << GRAPHICS_COLOR_ID) | OBJECT_T;
const bits GRAPHICS_FONT_T = (bits(1) << GRAPHICS_FONT_ID) | OBJECT_T;
const bits GRAPHICS_PARTICLE_SYSTEM_T = (bits(1) << GRAPHICS_PARTICLE_SYSTEM_ID) | GRAPHICS_DRAWABLE_T;
const bits GRAPHICS_SPRITE_BATCH_T = (bits(1) << GRAPHICS_SPRITE_BATCH_ID) | GRAPHICS_DRAWABLE_T;
@@ -119,9 +115,6 @@ namespace love
const bits IMAGE_IMAGE_DATA_T = (bits(1) << IMAGE_IMAGE_DATA_ID) | DATA_T;
// Audio.
const bits AUDIO_AUDIBLE_T = (bits(1) << AUDIO_AUDIBLE_ID) | OBJECT_T;
const bits AUDIO_SOUND_T = (bits(1) << AUDIO_SOUND_ID) | AUDIO_AUDIBLE_T;
const bits AUDIO_MUSIC_T = (bits(1) << AUDIO_MUSIC_ID) | AUDIO_AUDIBLE_T;
const bits AUDIO_SOURCE_T = (bits(1) << AUDIO_SOURCE_ID) | OBJECT_T;
// Sound.
@@ -148,6 +141,9 @@ namespace love
const bits MODULE_IMAGE_T = (bits(1) << MODULE_IMAGE_ID) | MODULE_T;
const bits MODULE_SOUND_T = (bits(1) << MODULE_SOUND_ID) | MODULE_T;
bool getType(const char * in, Type & out);
bool getType(Type in, const char *& out);
} // love
#endif // LOVE_TYPES_H