Re: [AD] Allegro 4.2.0 RC1 timetable |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On June 4, 2005 01:46 am, Evert Glebbeek wrote:
> Let's see if I don't forget anything that still needs to be done:
>
Someone on #allegro gave entheh and I a brilliant Idea, making it easier for
people to chain a builtin datafile object onto a custom one:
create_myobj(...) {
BITMAP *bmp = load_bitmap_object(...);
/* ...wooo... */
...
}
...
register_datafile_object(DAT_BITMAP, create_myobj, ...);
>
> Evert
>
I have attached a preliminary patch to allow such a dastardly thing.
Now, with this it should be possible to auto load a BMP object directly into a
GL texture, and return a fancy texture object. Or whatever you can think of
really.
I thought it would be usefull enough :D
edit: My last attempt got BLOCKED. Don't try sending a ziped file to the list.
Diagnostic code: smtp;550-"For the time being, we are blocking all mail with
the .zip extension. If this this is a problem, please open a Support Request
on the SF.net webite."
fn...
--
Thomas Fjellstrom
tfjellstrom@xxxxxxxxxx
diff -rbEu allegro/docs/src/allegro._tx allegro_work/docs/src/allegro._tx
--- allegro/docs/src/allegro._tx 2005-06-04 04:25:35.000000000 -0600
+++ allegro_work/docs/src/allegro._tx 2005-06-04 07:12:29.000000000 -0600
@@ -10471,6 +10471,43 @@
existing formats. See tools/plugins/plugins.txt for an overview of how to
write your own grabber plugins.
+@hnode Custom Object helper functions
+@@void *@al_dat_load_data(PACKFILE *f, long size);
+@@void *@al_dat_load_font(PACKFILE *f, long size);
+@@void *@al_dat_load_sample(PACKFILE *f, long size);
+@@void *@al_dat_load_midi(PACKFILE *f, long size);
+@@void *@al_dat_load_bitmap(PACKFILE *f, long size);
+@@void *@al_dat_load_rle_sprite(PACKFILE *f, long size);
+@@void *@al_dat_load_compiled_sprite(PACKFILE *f, long size);
+@@void *@al_dat_load_xcompiled_sprite(PACKFILE *f, long size);
+@@void @al_dat_unload_sample(SAMPLE *s);
+@@void @al_dat_unload_midi(MIDI *m);
+@xref register_datafile_object
+@shortdesc Semi internal datafile functions
+ Semi internal datafile functions only useful for "sub classing" the builtin object types.
+ For example, you wanted to take a normal datafile filled with BMP objects,
+ and immediatly load them into an OpenGL texture, you could create a simple function
+ that calls al_dat_load_bitmap and uploads it to a texture, and returns a custom texture
+ structure.
+
+<codeblock>
+ void *load_myobject(PACKFILE *f, long size)
+ {
+ BITMAP *bmp = al_dat_load_bitmap(f, size);
+ MYOBJECT *myobj;
+ /* ... do something really clever here ... */
+ return myobj;
+ }
+
+ void destroy_myobject(MYOBJECT *m)
+ {
+ /* clean up */
+ }
+
+ /* ... */
+
+ register_datafile_object(DAT_BITMAP, load_myobject, destroy_myobject);
+<endblock>
@heading
diff -rbEu allegro/include/allegro/datafile.h allegro_work/include/allegro/datafile.h
--- allegro/include/allegro/datafile.h 2005-04-02 09:42:24.000000000 -0700
+++ allegro_work/include/allegro/datafile.h 2005-06-04 06:35:22.000000000 -0600
@@ -97,6 +97,18 @@
AL_FUNC(void, register_bitmap_file_type, (AL_CONST char *ext, AL_METHOD(struct BITMAP *, load, (AL_CONST char *filename, struct RGB *pal)), AL_METHOD(int, save, (AL_CONST char *filename, struct BITMAP *bmp, AL_CONST struct RGB *pal))));
+AL_FUNC(void *, al_dat_load_data, (PACKFILE *f, long size));
+AL_FUNC(void *, al_dat_load_font, (PACKFILE *f, long size));
+AL_FUNC(void *, al_dat_load_sample, (PACKFILE *f, long size));
+AL_FUNC(void *, al_dat_load_midi, (PACKFILE *f, long size));
+AL_FUNC(void *, al_dat_load_bitmap, (PACKFILE *f, long size));
+AL_FUNC(void *, al_dat_load_rle_sprite, (PACKFILE *f, long size));
+AL_FUNC(void *, al_dat_load_compiled_sprite, (PACKFILE *f, long size));
+AL_FUNC(void *, al_dat_load_xcompiled_sprite, (PACKFILE *f, long size));
+
+AL_FUNC(void, al_dat_unload_sample, (SAMPLE *s));
+AL_FUNC(void, al_dat_unload_midi, (MIDI *m));
+
#ifdef __cplusplus
}
#endif
diff -rbEu allegro/src/datafile.c allegro_work/src/datafile.c
--- allegro/src/datafile.c 2005-06-04 04:25:39.000000000 -0600
+++ allegro_work/src/datafile.c 2005-06-04 08:07:48.249153640 -0600
@@ -25,7 +25,7 @@
-static void unload_midi(MIDI *m);
+static void al_dat_unload_midi(MIDI *m);
static void initialise_datafile(DATAFILE *data);
@@ -651,7 +651,7 @@
if (m->track[c].len > 0) {
m->track[c].data = read_block(f, m->track[c].len, 0);
if (!m->track[c].data) {
- unload_midi(m);
+ al_dat_unload_midi(m);
return NULL;
}
}
@@ -1013,20 +1013,20 @@
-/* load_data_object:
+/* al_dat_load_data:
* Loads a binary data object from a datafile.
*/
-static void *load_data_object(PACKFILE *f, long size)
+void *al_dat_load_data(PACKFILE *f, long size)
{
return read_block(f, size, 0);
}
-/* load_font_object:
+/* al_dat_load_font:
* Loads a font object from a datafile.
*/
-static void *load_font_object(PACKFILE *f, long size)
+void *al_dat_load_font(PACKFILE *f, long size)
{
short height = pack_mgetw(f);
@@ -1040,30 +1040,30 @@
-/* load_sample_object:
+/* al_dat_load_sample:
* Loads a sample object from a datafile.
*/
-static void *load_sample_object(PACKFILE *f, long size)
+void *al_dat_load_sample(PACKFILE *f, long size)
{
return read_sample(f);
}
-/* load_midi_object:
+/* al_dat_load_midi:
* Loads a midifile object from a datafile.
*/
-static void *load_midi_object(PACKFILE *f, long size)
+void *al_dat_load_midi(PACKFILE *f, long size)
{
return read_midi(f);
}
-/* load_bitmap_object:
+/* al_dat_load_bitmap:
* Loads a bitmap object from a datafile.
*/
-static void *load_bitmap_object(PACKFILE *f, long size)
+void *al_dat_load_bitmap(PACKFILE *f, long size)
{
short bits = pack_mgetw(f);
@@ -1072,10 +1072,10 @@
-/* load_rle_sprite_object:
+/* al_dat_load_rle_sprite:
* Loads an RLE sprite object from a datafile.
*/
-static void *load_rle_sprite_object(PACKFILE *f, long size)
+void *al_dat_load_rle_sprite(PACKFILE *f, long size)
{
short bits = pack_mgetw(f);
@@ -1084,10 +1084,10 @@
-/* load_compiled_sprite_object:
+/* al_dat_load_compiled_sprite:
* Loads a compiled sprite object from a datafile.
*/
-static void *load_compiled_sprite_object(PACKFILE *f, long size)
+void *al_dat_load_compiled_sprite(PACKFILE *f, long size)
{
short bits = pack_mgetw(f);
@@ -1096,10 +1096,10 @@
-/* load_xcompiled_sprite_object:
+/* al_dat_load_xcompiled_sprite:
* Loads a mode-X compiled object from a datafile.
*/
-static void *load_xcompiled_sprite_object(PACKFILE *f, long size)
+void *al_dat_load_xcompiled_sprite(PACKFILE *f, long size)
{
short bits = pack_mgetw(f);
@@ -1108,10 +1108,10 @@
-/* unload_sample:
+/* al_dat_unload_sample:
* Destroys a sample object.
*/
-static void unload_sample(SAMPLE *s)
+void al_dat_unload_sample(SAMPLE *s)
{
if (s) {
if (s->data) {
@@ -1126,10 +1126,10 @@
-/* unload_midi:
+/* al_dat_unload_midi:
* Destroys a MIDI object.
*/
-static void unload_midi(MIDI *m)
+void al_dat_unload_midi(MIDI *m)
{
int c;
@@ -1172,7 +1172,7 @@
}
/* if not found, load binary data */
- obj->dat = load_data_object(ff, d);
+ obj->dat = al_dat_load_data(ff, d);
Found:
pack_fclose_chunk(ff);
@@ -2083,12 +2083,12 @@
void _initialize_datafile_types(void)
{
register_datafile_object(DAT_FILE, load_file_object, (void (*)(void *data))unload_datafile );
- register_datafile_object(DAT_FONT, load_font_object, (void (*)(void *data))destroy_font );
- register_datafile_object(DAT_SAMPLE, load_sample_object, (void (*)(void *data))unload_sample );
- register_datafile_object(DAT_MIDI, load_midi_object, (void (*)(void *data))unload_midi );
- register_datafile_object(DAT_BITMAP, load_bitmap_object, (void (*)(void *data))destroy_bitmap );
- register_datafile_object(DAT_RLE_SPRITE, load_rle_sprite_object, (void (*)(void *data))destroy_rle_sprite );
- register_datafile_object(DAT_C_SPRITE, load_compiled_sprite_object, (void (*)(void *data))destroy_compiled_sprite);
- register_datafile_object(DAT_XC_SPRITE, load_xcompiled_sprite_object, (void (*)(void *data))destroy_compiled_sprite);
+ register_datafile_object(DAT_FONT, al_dat_load_font, (void (*)(void *data))destroy_font );
+ register_datafile_object(DAT_SAMPLE, al_dat_load_sample, (void (*)(void *data))al_dat_unload_sample );
+ register_datafile_object(DAT_MIDI, al_dat_load_midi, (void (*)(void *data))al_dat_unload_midi );
+ register_datafile_object(DAT_BITMAP, al_dat_load_bitmap, (void (*)(void *data))destroy_bitmap );
+ register_datafile_object(DAT_RLE_SPRITE, al_dat_load_rle_sprite, (void (*)(void *data))destroy_rle_sprite );
+ register_datafile_object(DAT_C_SPRITE, al_dat_load_compiled_sprite, (void (*)(void *data))destroy_compiled_sprite);
+ register_datafile_object(DAT_XC_SPRITE, al_dat_load_xcompiled_sprite, (void (*)(void *data))destroy_compiled_sprite);
}