Computing.Net > Forums > Programming > Allegro Datafiles

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Allegro Datafiles

Reply to Message Icon

Name: djas
Date: December 25, 2006 at 12:13:43 Pacific
OS: Windows XP Home SP2
CPU/Ram: PM 1.73 GHZ 1GB RAM
Product: Gateway MX6635b
Comment:

hey, I'm new to Allgero and am trying to understand how to use datafiles to display a background image stored in one.

I get this error:
`Background' undeclared (first use this function)

the only problem is that 'Background' is the name of the file in the datafile which I created using the grabber tool packaged with Allegro.

This is the code I'm trying to use:

#include <allegro.h>

int main()
{

allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);

DATAFILE *dat = load_datafile_object("bg.dat", "Background");
BITMAP *bmp;

if (!dat)
{
/* report an error! */
return 1;
}
blit( ( BITMAP* )dat[ Background ].dat, bmp, 0, 0, 0, 0, 100, 100 );

readkey();
unload_datafile(dat);
}
END_OF_MAIN();

-----------------
Thanks for any help

djas



Sponsored Link
Ads by Google

Response Number 1
Name: djas
Date: December 26, 2006 at 17:17:00 Pacific
Reply:

ok I've managed to fiddle a bit and found out some more but I'm still stuck.
I can now compile my program successfully however I am unable to display the bitmap stored in my datafile.
Any suggestions anyone?

--------------------
#include <allegro.h>

int main()
{

allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);

BITMAP *bmp;

DATAFILE *dat = load_datafile("bg.dat");
if (!dat)
{
return 1;
}
blit( ( BITMAP* )dat[1].dat, bmp, 0, 0, 0, 0, 640, 480 );

readkey();
unload_datafile(dat);
}
END_OF_MAIN();


djas


0

Response Number 2
Name: djas
Date: December 27, 2006 at 10:18:19 Pacific
Reply:

It seems that in my tinkering I've managed to get this working on my own but just in case anyone is interested this code works:

#include <allegro.h>

int main()
{

allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);

DATAFILE *dat = load_datafile("bg.dat");
if (!dat)
{
return 1;
}
acquire_screen();
draw_sprite( screen, (BITMAP*)dat[0].dat, 0, 0);
release_screen();
readkey();

unload_datafile(dat);
return 0;
}
END_OF_MAIN();

djas


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


A problem with batch rena... Copy and rename with a ba...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Allegro Datafiles

read a datafile in C www.computing.net/answers/programming/read-a-datafile-in-c/5041.html

Allegro problem www.computing.net/answers/programming/allegro-problem/8363.html

Is there ayone who can help me with this www.computing.net/answers/programming/is-there-ayone-who-can-help-me-with-this/511.html