$10 ### Image of the Day Submit IOTD | Top Screenshots ### The latest, straight to your Inbox. Subscribe to GameDev.net's newsletters to receive the latest updates and exclusive content. Sign up now ## How do I set up SDL in visual C++ 2010 express? Old topic! Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic. 22 replies to this topic ### #1xzbobzx Members Posted 27 April 2011 - 07:19 AM I've searched for tutorials but couldn't find any good ones, so I decided to ask here, how do I set up SDL in Visual C++ 2010 express? ### #2fisyher Members Posted 27 April 2011 - 07:24 AM LazyFoo's SDL tutorials: http://lazyfoo.net/SDL_tutorials/index.php The explanations are very clear and easy to follow. Start with Lesson 1 and you are good to go. If you do not understand any of the steps, just post again to ask. ### #3xzbobzx Members Posted 27 April 2011 - 08:55 AM LazyFoo's SDL tutorials: http://lazyfoo.net/S...rials/index.php The explanations are very clear and easy to follow. Start with Lesson 1 and you are good to go. If you do not understand any of the steps, just post again to ask. Wow, that guy sure ain't lazy. o.o Thanks. ### #4xzbobzx Members Posted 03 May 2011 - 05:59 AM So I tried lesson 1, all compiles fine. But when I run the program it's just a black screen without any picture on it, what have I done wrong? ### #5Wooh Members Posted 03 May 2011 - 06:09 AM make sure the file hello.bmp exists and is located at the right path. ### #6xzbobzx Members Posted 03 May 2011 - 06:28 AM Its there and in the right path, but It still doesn't work. :c ### #7Wooh Members Posted 03 May 2011 - 06:53 AM have you written the code or did you just copy it? It is easy to miss a line. The full source can be downloaded at the bottom of the page. If that source don't work you have probably not set up SDL properly. ### #8xzbobzx Members Posted 03 May 2011 - 06:59 AM I guess I'll go over the setting up part once more. ### #9Wooh Members Posted 03 May 2011 - 07:08 AM When I think about it, a blank window sounds more like an error in the code than SDL being not properly set up. Try add the following code after hello = SDL_LoadBMP( "hello.bmp" ); : if (!hello) { printf("SDL_LoadBMP failed: %s\n", SDL_GetError()); } ### #10xzbobzx Members Posted 03 May 2011 - 07:44 AM SDL_LoadBMP failed: Couldn't open hello.bmp That's what I got in stdout. ### #11Wooh Members Posted 03 May 2011 - 08:02 AM So the problem is that it could not open hello.bmp, most likely because it didn't found it. I don't know what visual c++ use for current directory when running your program. Maybe the file should be located at he project root. If you replace the filename ("hello.bmp") with the full path to the file ("C:\\...\hello.bmp") it should work. ### #12xzbobzx Members Posted 03 May 2011 - 08:29 AM I clicked the properties on hello.bmp, and it said; Item Type: Does not participate in build ### #13Wooh Members Posted 03 May 2011 - 08:36 AM I think that just means that visual c++ will not try to compile that file. ### #14xzbobzx Members Posted 03 May 2011 - 08:45 AM Tried all other options, doesn't do anything... :c ### #15NightCreature83 Members Posted 03 May 2011 - 08:46 AM I clicked the properties on hello.bmp, and it said; Item Type: Does not participate in build BMP files are binary data, binary data and other data files are never compiled they are just that data. Make sure that your runtime directory is setup properly in the solution file, by default when launching the exe from the IDE it doesn't start in the same directory as to which it builds, it starts in the solution directory. 1. Right click your project and open properties on it. 2. Go to the debugging item in the tree view 3. Set the working directory to the one where the bmp is located Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max ### #16xzbobzx Members Posted 03 May 2011 - 09:32 AM Also didn't work... :| ### #17scgames Members Posted 03 May 2011 - 10:14 AM If you haven't already, change the path back to just "hello.bmp" (that is, don't use the full path). Then, check and see what the working directory is set to, as NightCreature83 described. I'm not looking at Visual Studio right now, but the path might be expressed in terms of a macro; if you're not sure how to interpret the path, you could post it here. Or, you could just try putting the file in a few different directories until you find one that works. A good place to start would probably be the project directory itself (the directory where your source code and so on is). ### #18fastcall22 Moderators Posted 03 May 2011 - 10:46 AM By default, when you run your program from within the IDE, the working directory is set to "$(ProjectDir)", which is the directory containing the project file and source files. However, if you were to run your program from outside the IDE, then the working directory is the directory of the executable. You can change the working directory of a program by going to the project properties (alt+f7), and changing the "Working Directory" field under "Debugging->General".
zlib: eJzVVLsSAiEQ6/1qCwoK i7PxA/2S2zMOZljYB1TO ZG7OhUtiduH9egZQCJH9 KcJyo4Wq9t0/RXkKmjx+ cgU4FIMWHhKCU+o/Nx2R LEPgQWLtnfcErbiEl0u4 0UrMghhZewgYcptoEF42 YMj+Z1kg+bVvqxhyo17h nUf+h4b2W4bR4XO01TJ7 qFNzA7jjbxyL71Avh6Tv odnFk4hnxxAf4w6496Kd OgH7/RxC

### #19xzbobzx  Members

Posted 03 May 2011 - 10:52 AM

I also get this sometimes:
[external drive] being, of course, my external drive. :|

### #20xzbobzx  Members

Posted 03 May 2011 - 10:58 AM

By default, when you run your program from within the IDE, the working directory is set to "\$(ProjectDir)", which is the directory containing the project file and source files. However, if you were to run your program from outside the IDE, then the working directory is the directory of the executable. You can change the working directory of a program by going to the project properties (alt+f7), and changing the "Working Directory" field under "Debugging->General".

Ah, ok, so it should work if I placed the 'hello.bmp' in the folder containing the .exe?

Edit: it worked.

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.