|
Compiles correctly but i get an error report error |
GuitarGod1134
Member #8,482
April 2007
|
Im using DevCPP with Allegro and C++. I have a program Im making and so far the coding went excellent no errors at all, then when I ran it it was black for maybe 4 seconds and then said "Would you like to send an error report" and when I click dont send it just exits the program. Idk what is wrong but if you know that would be appreciated here is my code
And here is everything if you want to test it yourself (which i recommend) |
spork222
Member #7,263
May 2006
|
The biggest and probably what's causing the problem is that you're loading bitmaps inside the while loop. This means that it will be constantly trying to reload your bitmaps every cycle of the while. Your code should instead be something like this:
|
BAF
Member #2,981
December 2002
|
If you must mess with acquire/release screen, it should be directly around the drawing calls, not around the logic too. You should also have a timer on your logic. And you should be drawing to a buffer, the blitting the buffer to the screen. |
GuitarGod1134
Member #8,482
April 2007
|
OK i loaded the images outside of the while loop and im still getting the error report |
LennyLen
Member #5,313
December 2004
|
Chances are that the BITMAPs are failing to load. Try checking the return values of the load_bitmap() calls to see if they are successful or not.
|
Jonatan Hedborg
Member #4,886
July 2004
|
Remove the acquire_bitmap and release_bitmap things entirely. Just make a buffer and draw to that (as people have said). Considering how many people misuse acquire_bitmap, maybe we should consider changing whatever it says about it in the manual?
|
Matthew Leverton
Supreme Loser
January 1999
|
You assume that people read the manual: Quote: Warning: This function can be very dangerous to use, since the whole program may get locked while the bitmap is locked. So the lock should only be held for a short time, and you should not call anything but drawing operations onto the locked video bitmap while a lock is in place. Especially don't call things like show_mouse (or scare_mouse which calls that) or readkey, since it will most likely deadlock your entire program.
|
Jonatan Hedborg
Member #4,886
July 2004
|
But where does people learn of that evil function?
|
Matthew Leverton
Supreme Loser
January 1999
|
Tutorials, other code, and (perhaps) skimming the table of contents. |
GuitarGod1134
Member #8,482
April 2007
|
Quote: LennyLen: Chances are that the BITMAPs are failing to load. Try checking the return values of the load_bitmap() calls to see if they are successful or not.
Ya how do i Do that? |
LennyLen
Member #5,313
December 2004
|
Quote: Ya how do i Do that? Something like this: if (!(charupSprite = load_bitmap("charup.bmp", NULL))) { allegro_message("Error loading charup.bmp"); exit(-1); } In C++, you might get away with declaring and testing the value all in line, but in C, you can't, which is why I removed the dclaration. I always prefer to declare all variables in one place rather than when I first use them anyway. If you feel you absolutely MUST declare them when you first use them, then you can use this method of testing: BITMAP *charupSprite = load_bitmap("charup.bmp", NULL); if (!charupSprite) { allegro_message("Error loading charup.bmp"); exit(-1); }
|
GuitarGod1134
Member #8,482
April 2007
|
Ya it turns out they are failing to load. I tried that error message and sure enough it returned the error message. I even tried renaming the bmp's to 1,2,3,4 to make sure that they are not misspelled but they still failed to load. EDIt; ok i got it my pics arent valid for some reason. I used different pics and they worked so I now know its the pics thanks for the help! |
LennyLen
Member #5,313
December 2004
|
You probably have the .bmp files in the wrong directory. IIRC, Dev-C++ creates a directory for your project, then it creates a DEBUG and RELEASE subdirectory within that where the executables will be. Put the .bmp files in the project directory, not in the subdirectory with the .exe.
|
chaseC
Member #8,368
February 2007
|
I used to put my bitmap files in the wrong directory to. None of the tutorials I read said anything about it. Finally I found out that with Dev-c++, you put it in the folder called Dev-c++ where all your c++ files are saved automatically saved to. |
ImLeftFooted
Member #3,935
October 2003
|
Quote: IIRC, Dev-C++ creates a directory for your project, then it creates a DEBUG and RELEASE subdirectory within that where the executables will be. You don't recall correctly.:-X You're describing Visual Studio's behavior. |
LennyLen
Member #5,313
December 2004
|
Quote: You don't recall correctly. You're describing Visual Studio's behavior. I think my mind is trying to block all memory of Dev-C++. The only IDE I've liked less is Visual-MinGW, which somehow managed to have even more bugs than Dev-C++.
|
|