loading a .bmp file into SDL
Moderator: PC Supremacists
Re: loading a .bmp file into SDL
i am using c++ with SDL and i have no idea what to do to get this picture on screen so......as much in dummy langue as u can put it could u explain wht i need to do.......i learn from seeing and doing not reading and hearin! sorry if im a bother i am just rlly new with SDL but i know c++ pretty well!
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: loading a .bmp file into SDL
I understand your frustration. Programming a skill learned through much dedication over a long period of time. Spelling correctly (not perfectly, but rather putting effort into your thoughts and questions) makes you literally seem 1,000 times more intelligent when one post is the only thing I have to judge your entire existence on.azaron08 wrote:My bad....sorry just pisses me off at the program not working......ive been trying tons of stuff 4 like 2 weeks and havent gotten any results. Ill try and put the picture in the debug file because I'm using c++ and its one thing I haven't tried!
Not everyone is patient by nature. If that is the case you have two options: stop trying to program and just leave the topic alone, or ease yourself into it and learn the patience required to master this tough skill.
Of course, as OmelFelix pointed out (albeit rather bluntly) it is an enormous help if you use code blocks to post snippets of relevant code. There is also pastebin.com, if you find it necessary to post a larger portion of your program.
Keep in mind that setting things up for the first time and getting your first program to compile is often one of the hardest parts for new programmers. This is why a working "Hello World!" application is seen as such an accomplishment in your early days. This is where perseverance will pay off, just tell us exactly what you tried, what you expected to happen, and what actually happened and we'll do our best to help you out.
Edit: If you are using Visual Studio perhaps you could ZIP your entire project and upload it as an attachment. This would allow someone to check out configuration and file placement and better help you debug any issues you're having.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- bbguimaraes
- Chaos Rift Junior
- Posts: 294
- Joined: Wed Apr 11, 2012 4:34 pm
- Programming Language of Choice: c++
- Location: Brazil
- Contact:
Re: loading a .bmp file into SDL
What I meant is what compiler and IDE (if you use one) are you using? My guess is Visual Studio, so this page tells that in the Project Settings' Properties page, there is a field Working Directory, which is \bin\Debug and \bin\Release. So just put your image on this directory and it should work.azaron08 wrote:i am using c++ with SDL and i have no idea what to do to get this picture on screen so......as much in dummy langue as u can put it could u explain wht i need to do.......i learn from seeing and doing not reading and hearin! sorry if im a bother i am just rlly new with SDL but i know c++ pretty well!
Re: loading a .bmp file into SDL
k....I'll try zipping it up and c what i can do. As for what ie tried, ive put the image in the debug folder the project folder the program folder and the visual studios folder and nothing changed i thought at least one of them would bring the painted picture up onto my white background but it only shows a white screen ( white is my background ) also i have tried putting my surfaces all on one line and on there induvidual lines and nothing changed.....idk anything other than i cant figure out whats wrong and i cant continue my tutorial series without knowing this.
Re: loading a .bmp file into SDL
do i need win rar to zip up the file??? or a program like it??
- bbguimaraes
- Chaos Rift Junior
- Posts: 294
- Joined: Wed Apr 11, 2012 4:34 pm
- Programming Language of Choice: c++
- Location: Brazil
- Contact:
Re: loading a .bmp file into SDL
Find the executable file (the .exe file, should be somewhere inside your prject folder, probably bin\Debug or bin\Release) and copy it to a folder. Then copy the image to that folder. Run the executable by doulbe clicking it. This cannot go wrong (in theory ).
Re: loading a .bmp file into SDL
ok....i think ik wht ur saying take the debug folder and copy it to a new folder i have made then put the image in that folder and do i double click the new folder or the old debug folder??? is that correct???
- bbguimaraes
- Chaos Rift Junior
- Posts: 294
- Joined: Wed Apr 11, 2012 4:34 pm
- Programming Language of Choice: c++
- Location: Brazil
- Contact:
Re: loading a .bmp file into SDL
You just have to make sure the executable (the file ending with .exe) is in the same folder as the image. Then you double-click the executable.
Re: loading a .bmp file into SDL
see thats the problem i cant find any file that ends in .exe
Re: loading a .bmp file into SDL
i found the file and put the .dll and the picture in it and double clicked it and the image apeared on the white screen but when i run it from the visual studios (inside the program) it still only shows a white screen
Re: loading a .bmp file into SDL
I DID IT!!!!!!!!!!!!!!!!!!!!!! THANKS FOR ALL THE HELP TOOK A BIT PLAYING AROUND WITH THE FILES AND STUFF BUT I GOT IT!!!!!!!!!!!!! THX TO ALL WHO HELPED!!!!!!
- bbguimaraes
- Chaos Rift Junior
- Posts: 294
- Joined: Wed Apr 11, 2012 4:34 pm
- Programming Language of Choice: c++
- Location: Brazil
- Contact:
Re: loading a .bmp file into SDL
I'm gald you did it. Just so you know what is happening:
A relative path is a path that is relative to your current working directory. It is the opposite of a absolute path, which is the complete path to a file. Examples of both are:
When you specify a relative path, it is considered relative to your current working directory. That is set by the program that runs your program. If you use the command-line, for example, you can use
and the working directory will be set to "C:\data" (cd is the commando to change your working directory). All relative paths are considered relative to "C:\data", so if you open a file named "bmp.bmp", the actual path will be "C:\data\bmp.bmp".
When you run a program by double-clicking it on Windows Explorer (like you did), the working directory is considered the folder where you currently are in. So, if your code opens a file called "bmp.bmp", the file must be in that folder. That's why it worked. When Visual Studio runs the file, it uses the path you specify in the Project Settings, Working Directory field. So, any path you use in your code will be relative to that. Your file paths must be relative to that directory.
I hope this explanation helps you. Feel free to ask questions.
A relative path is a path that is relative to your current working directory. It is the opposite of a absolute path, which is the complete path to a file. Examples of both are:
Code: Select all
// Absolute
C:\data\program.exe
D:\something\file2
// Relative
data\program.exe
file2
Code: Select all
> cd C:\data
> program.exe
When you run a program by double-clicking it on Windows Explorer (like you did), the working directory is considered the folder where you currently are in. So, if your code opens a file called "bmp.bmp", the file must be in that folder. That's why it worked. When Visual Studio runs the file, it uses the path you specify in the Project Settings, Working Directory field. So, any path you use in your code will be relative to that. Your file paths must be relative to that directory.
I hope this explanation helps you. Feel free to ask questions.
Re: loading a .bmp file into SDL
all ik and got out of that is the debug folder is the relative and runs the program and any file used in the program must be in that file also! right??
- bbguimaraes
- Chaos Rift Junior
- Posts: 294
- Joined: Wed Apr 11, 2012 4:34 pm
- Programming Language of Choice: c++
- Location: Brazil
- Contact:
Re: loading a .bmp file into SDL
Yes, that's what you need to know (for now). You can also change the working directory (depends on how you run the program). And you can use ".." in a path, which means "the parent directory". So if you are in "project\bin\debug" and want to open a file in "project\img\bmp.bmp", you can use "..\..\img\bmp.bmp".
Re: loading a .bmp file into SDL
K funk's a ton ill probly have more question later on