Jump to content
  • Advertisement
Sign in to follow this  
shadymokhtar

Small SDL_Problem

This topic is 3780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Another one of the potential situations could be the following: When you use Visual C++ 2008 (and probably others) and you run through the IDE, the running directory isn't the exe's directory. It actually is the project folder (NOT the solution folder). For example, if I had a solution called Test with a Project called Test and I executed through the ide, the actual running directory would be /Test/Test/ rather then /Test/Debug/ or whichever mode you built in. This is actually a slightly frustrating situation but I am probably sure there is some setting in the IDE to change the running path but I have not looked for it as of yet.


Edit: Removed unnecessary comments about the original post.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by shadymokhtar
i made debug and i found that the mistake is in the SDL_LoadBMP it seems that id doesn't find the file and i'm sure of that, and i didn't file any txt file, and i think i must make some settings in the compiler itself not the code

Quote:
Original post by shadymokhtar
i'm using visual C++ 2008

Sorry for the confusion, but I didn't realize Visual C++ 2008 causes problems with stdout and stderr. Thread. This is probably why they are not showing up.

You could do this, and get the error reports that way instead, but I think rip-off is probably right about your program looking in the wrong place for the image.

Share this post


Link to post
Share on other sites
Thank u all for helping
i discovered the mistake and it's such a stupid one ..so sorry.
the image i was loading was originally a JPG format so i just renamed it .BMP
and i thought this way will change its format but it didn't, i don't know why although when i renamed it, it had .bmp extention, anyway i fixed the problem now and thanks again

Share this post


Link to post
Share on other sites
Ah, that'd explain it certainly. The file's extension type doesn't guarantee what a file contains, it just helps both programs, and users, understand what the file is. I can rename a .exe file, to a .txt, but that doesn't make it into a text file, and if I tried to open it in Notepad, it'd look like a bunch of gibberish.

However, lucky for you, there is a very very simple and easy way to load .jpg files using SDL. You have to download a sub-library called 'SDL_image', and #include it to your program. You also need to link it, as you linked SDL.

Then all you need to do is replace SDL_LoadBMP with IMG_Load. You can read this tutorial to see how to set it up. In fact, I'd recommend reading a couple of those, as they are well written.

SDL_image adds support for loading .jpg, .png, .gif*, and .tga. (As well as a couple others) It can also load .bmps like SDL_LoadBMP can.


*As long as it's not animated

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!