Can't open a image

Questions regarding game mechanics and graphic programming should go here.

Moderators: Darobat, RecursiveS, Dante Shamest, Bugdude, Wizard

Can't open a image

Postby Callum5042 » Sun Jul 04, 2010 6:02 am

I'm using this code here

Code: Select all
BITMAP*myplane=NULL;
myplane=load_bitmap("myplane_all-around_100hp.tga", NULL);
draw_sprite(screen,myplane,320,240);
destroy_bitmap(myplane);


But it comes up with this error

Debuy Error!

Program:
...isual_allegro\First\Allegro_testrun\Debug\Allegro_testun.exe

R6010
-abort() has been called

(Press Retry to bebug the application)


What's wrong with the code?
Callum5042
 
Posts: 1
Joined: Sun Jul 04, 2010 6:00 am

Re: Can't open a image

Postby Sunny » Fri Jul 23, 2010 3:47 am

I know that this thread is old, but I hate it, if a question is not answered.

you have to check the return value from 'load_bitmap'. If an error occured, load_bitmap would return NULL.
but you don't check it and call 'draw_sprite(...)' with 'myplane', which is maybe a nullptr -> Crash.

here the documentation about 'load_bitmap': http://www.allegro.cc/manual/api/loadin ... oad_bitmap
User avatar
Sunny
 
Posts: 6
Joined: Thu Jul 22, 2010 5:01 pm


Return to Games and Graphics

Who is online

Users browsing this forum: No registered users and 2 guests

cron