Allegro Image
Well, Ive been trying to get allegro up and running for a while now, and finally got it installed with the devpack (I also had to download the windows DLL). I was able to run the sample code, which just printed some text on the screen:) I read some tutorials, all of which dealt with loading a bitmap and displaying it on screen. This is where im having trouble. #include <allegro.h> int main() { allegro_init(); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0); install_keyboard(); BITMAP *my_pic; my_pic = load_bitmap("picture.bmp", NULL); acquire_screen(); blit(my_pic, screen, 0,0,0,0,640,480); release_screen(); readkey(); destroy_bitmap(my_pic); allegro_exit(); return 0; } END_OF_MAIN(); It compiles with no errors, but fails to actually display anything. It just zooms in whatever was on the screen when I run it, hangs for a sec, then exits. Any help would be greatly appreciated:) Im using Dev-c++ ver. 4.9.9.0
Try this:
PALETTE thePalette;get_palette(thePalette);my_pic = load_bitmap("picture.bmp", thePalette);
http://www.roboguy.net(WIP) - lisperati - SICP - Haskell - Python - OCaml - Lambda the Ultimate - Good Math, Bad Math - Wiki (not Wikipedia) - Pure - Term-Rewriting Functional Language
Still same problem:/ Its almost like its going into the program, then it stops after going fullscreen, keeping dev-cpp on screen only zoomed in a little.
Are you sure the image exists in the same directory as the executable? you don't have any NULL checking on my_pic
http://www.roboguy.net(WIP) - lisperati - SICP - Haskell - Python - OCaml - Lambda the Ultimate - Good Math, Bad Math - Wiki (not Wikipedia) - Pure - Term-Rewriting Functional Language
Are you running the compiled program by actually running the program, or are you running it from within Dev-C++? I haven't used Dev-C++ in ages, but I recall that mattering ...
Jesus saves ... the rest of you take 2d4 fire damage.
Ive done both. Used the compile and run button, and clicked on the actual application icon. Either way it just zooms in the screen:(
Ok I replaced the image with another, and that seemed to help. It still wont display it, but now it actually seems to run and shows a blank screen. It will also wait for me to hit a key before exiting.
Another update, I just took out the pallete, and set it back to NULL. Now instead of a blank screen, it shows a blue square where the image should be. So I guess theres just something wrong with the color settings?
Lol. Ok I finally got it to load :) I think whatever picture I was using was messed up. One last question though, with the blit function what do all the parameters represent?
blit(my_pic, screen, 0,0,0,0,640,480);
Do the last two numbers actually stretch the image to that size?
Or will I have to make an image already custom fitted to run as a backgound. Right now its only showing up in the upper left corner.
[Edited by - Greyish on November 3, 2004 11:57:39 AM]
Ok I replaced the image with another, and that seemed to help. It still wont display it, but now it actually seems to run and shows a blank screen. It will also wait for me to hit a key before exiting.
Another update, I just took out the pallete, and set it back to NULL. Now instead of a blank screen, it shows a blue square where the image should be. So I guess theres just something wrong with the color settings?
Lol. Ok I finally got it to load :) I think whatever picture I was using was messed up. One last question though, with the blit function what do all the parameters represent?
blit(my_pic, screen, 0,0,0,0,640,480);
Do the last two numbers actually stretch the image to that size?
Or will I have to make an image already custom fitted to run as a backgound. Right now its only showing up in the upper left corner.
[Edited by - Greyish on November 3, 2004 11:57:39 AM]
The last two numbers are the width and height of the region of the source bitmap you want to blit. So you could, say, store all your 32x32 tiles on one bitmap, and blit a tile at a time by passing 32's as the last two parameters.
If you want to stretch a bitmap, Allegro has a seperate function for that. See the docs. And it's going in the upper left corner because you're blitting it to 0, 0. [smile] Again, see the docs. They're excellent.
If you want to stretch a bitmap, Allegro has a seperate function for that. See the docs. And it's going in the upper left corner because you're blitting it to 0, 0. [smile] Again, see the docs. They're excellent.
Jesus saves ... the rest of you take 2d4 fire damage.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement