|
load_bitmap not working |
Charles256
Member #8,370
February 2007
|
I really hate asking this question because this seems like some little bug that's probably been posted a few dozen times. Either way, relevant code. The load_bitmap is returning null. I'm using MSVC 2005 pro edition. I put the images folder under the project folder and in it is a title.bmp file, would it be looking for the file somewhere else by any chance?
and for those wondering setup does the following... void setup() { set_color_depth(16); set_color_conversion(16); allegro_init(); install_keyboard(); install_mouse(); setup_screen(); show_mouse(screen); } and setup screen does void setup_screen() { int ret=set_gfx_mode(GFX_AUTODETECT_WINDOWED,1024,768,0,0); if (ret!=0) { allegro_message(allegro_error); return; } textprintf(screen,font,1,1,makecol(255,189,73),"Extreme Racing - %dx%d",1024,768); rect(screen,0,12,1023,767,makecol(255,242,169)); rect(screen,1,13,1022,765,makecol(255,242,169)); } Edit: i actually had an end of main.;D Sorry about the lack of formatting, used to devnetwork.net which has a button to click for code editing. My mistake. :-D I am clicking the debug button which means it's supposed to look in the project folder. |
CGamesPlay
Member #2,559
July 2002
|
Quote: would it be looking for the file somewhere else by any chance? Are you using Debug->Start Without Debugging, or double clicking on the EXE? In the case of the former, it will look under the project folder. In the case of the latter, it will look for project/Debug/images/title.bmp. -- Ryan Patterson - <http://cgamesplay.com/> |
gnolam
Member #2,030
March 2002
|
Edit your post with code tags so it's actually readable. Click the "Help" icon for info. Quote: I put the images folder under the project folder and in it is a title.bmp file, would it be looking for the file somewhere else by any chance? Check the working directory for your project. Also, "void main" is an illegal construction, and you lack an END_OF_MAIN(). That's all I'm willing to read in the unformatted code. [EDIT] -- |
Charles256
Member #8,370
February 2007
|
Doh. You said in unformatted code. At first I took it as a strike upon my spacing. :-D Which is a bit off with the code tags... Oh well.. Sorry. :-D Honest, I know c++. Only reason I used a void main is because of the book I'm using to learn allegro. I normally do a good ole standard int main(){ return 0;} format but since the code didn't work the first time through I made the code more and more like the book so I could eliminate assumption errors. |
gnolam
Member #2,030
March 2002
|
Quote: Only reason I used a void main is because of the book I'm using to learn allegro. ... it's "Game Programming All In One", isn't it? Anyway, on to the code: Quote: set_color_conversion(16); That's not how you do it. It possibly does something useful, but even in that case it's unreadable: set_color_conversion() takes as its argument an bitfield with your choice of conversion modes ORed together. Quote: textprintf textprintf() is deprecated. Use textprintf_ex() instead. Other than that it looks ok.
-- |
Charles256
Member #8,370
February 2007
|
yep. looks just fine, doesn't it? It's still not working though..... help? |
gnolam
Member #2,030
March 2002
|
Well, how do you start your program? And what are your working directory settings in MSVS? -- |
LennyLen
Member #5,313
December 2004
|
Does it load the file correctly if you give the full path name?
|
someone972
Member #7,719
August 2006
|
See if the attached file works, it only has minor changes to the code you originally gave. ______________________________________ |
Charles256
Member #8,370
February 2007
|
I start the program by starting debugging which means it should search under my project folder for the image. And what do you mean by working directory settings? Been programming in c++ for a bit but it's all been command line stuff that very rarely acts this poorly so you'll have to forgive me. :-D Be a bit more specific and I'll dig up the info for you. edit: the attached file did not work and even if I give the full path name it does not load teh file however I can load the file in any old image viewer. |
someone972
Member #7,719
August 2006
|
Are you linking with -lalleg or -lalld, it might not even make a difference. ______________________________________ |
Charles256
Member #8,370
February 2007
|
i have an additional dependency of alld.lib |
gnolam
Member #2,030
March 2002
|
someone972: As I've said to others: if you have absolutely no idea, keep silent. Incorrect linking would show up immediately as a linking error. Quote: And what do you mean by working directory settings? Somewhere in the myriad settings in MSVS you can set the working directory (= the directory your executable starts in) for your project. Quote: the attached file did not work and even if I give the full path name it does not load teh file however I can load the file in any old image viewer.
How did you load it with the full path? -- |
Charles256
Member #8,370
February 2007
|
this working directory, as you put it, as far as I can tell is the standard directory. all MSVC projects assume the project folder. there's two of em. the original one i tried to use is titled test now |
gnolam
Member #2,030
March 2002
|
Those BMPs are kosher.
-- |
Kikaru
Member #7,616
August 2006
|
If you are running on Windows this: load_bitmap("images/title.bmp", NULL); |
ImLeftFooted
Member #3,935
October 2003
|
Quote: If you are running on Windows this: What you are saying is false.
If load_bitmap is still returning NULL, you know the issue is something else. |
Charles256
Member #8,370
February 2007
|
current code. it's an 8 bit bmp. i am exiting with an error message if it doesn't load. because if it wasn't null it wouldn't get to the else. :-D i took out color conversion. I also went to the folder with the exe, ran it, and it still didn't load the file. Thanks for all the help guys but we're still short. Please help. I can program but if I can't get this working I'll have to do thigns the hard way and learn direct x
|
LennyLen
Member #5,313
December 2004
|
The combination of your code and the title.bmp file you attached earlier works fine for me. The only thing different I'm doing is using MinGW instead of MSVC. I've attached the .exe to this post. Check to see that it works when it's in the same directory as the .bmp.
|
gnolam
Member #2,030
March 2002
|
Quote: You're STILL not doing it right! -- |
Charles256
Member #8,370
February 2007
|
i deleted the set color conversion entirely and it still didn't work. i didn't follow what you wanted me to do originally when you said i wasn't doing it right. |
LennyLen
Member #5,313
December 2004
|
Quote: i deleted the set color conversion entirely and it still didn't work. i didn't follow what you wanted me to do originally when you said i wasn't doing it right. You supply a mode that says how conversions are specified. To see a list of the valid modes, see the manual. And did the .exe I provided work for you?
|
Indeterminatus
Member #737
November 2000
|
Quoting the manual on allegro_message: "Outputs a message, using a printf() format string. Usually you want to use this to report messages to the user in an OS independant way when some Allegro subsystem cannot be initialised. But you must not use this function if you are in a graphic mode, only before calling set_gfx_mode(), or after a set_gfx_mode(GFX_TEXT). Also, this function depends on a system driver being installed, which means that it won't display the message at all on some platforms if Allegro has not been initialised correctly." [emphasis added, ed.] That said, LennyLen's exe with your bitmaps (I tried them all by renaming them to title.bmp sequentially) displayed a white rectangle in the middle of the window for the two title.bmps, and some weird pixels for test.bmp that look like the bitmap was loaded correctly, but drawn with the wrong palette set. _______________________________ |
Charles256
Member #8,370
February 2007
|
: sighs : it still didn't work for me.... I have a small theory... Windows Vista no longer sees it's directory as C:\PROGRA~1\micro~\blah\blah any more. It actually now acknowledges it as literally "C:\Program Files\Microsoft Visual Studio" maybe it's getting lost? Somehow I doubt that but it was the problem I ran into when I tried to compile allegro. I eventually gave in and just used the pre-compiled files. :-D So, to someone who has this working. Can you please tell me your exact system setup. I'll miss my parameter pop up on functions but I'll get over it and c++ is c++ anywhere so I'm to the point I'm willing to try a different compiler. And a continuing thanks to all those that contniue to provide input. Edit: Installed XP Pro. Set up everything. At first it didn't work. Rebooted my computer, worked like a charm with my existing code. You shall see a remake and improvement on New Horizons: Uncharter Waters from me shortly. ( SNES, Sega, PC, and Nintendo version of aforementioned games exist) |
|