Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


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.

  • You cannot reply to this topic
22 replies to this topic

#1 xzbobzx   Members   -  Reputation: 120

Like
1Likes
Like

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?

Sponsor:

#2 fisyher   Members   -  Reputation: 136

Like
2Likes
Like

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.

#3 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

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.

#4 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

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?

#5 Wooh   Members   -  Reputation: 875

Like
0Likes
Like

Posted 03 May 2011 - 06:09 AM

make sure the file hello.bmp exists and is located at the right path.

#6 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

Posted 03 May 2011 - 06:28 AM

Its there and in the right path, but It still doesn't work. :c

#7 Wooh   Members   -  Reputation: 875

Like
0Likes
Like

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.

#8 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

Posted 03 May 2011 - 06:59 AM

I guess I'll go over the setting up part once more.

#9 Wooh   Members   -  Reputation: 875

Like
0Likes
Like

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());
	}


#10 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

Posted 03 May 2011 - 07:44 AM

SDL_LoadBMP failed: Couldn't open hello.bmp

That's what I got in stdout.

#11 Wooh   Members   -  Reputation: 875

Like
0Likes
Like

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.

#12 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

Posted 03 May 2011 - 08:29 AM

I clicked the properties on hello.bmp, and it said;
Item Type: Does not participate in build

#13 Wooh   Members   -  Reputation: 875

Like
0Likes
Like

Posted 03 May 2011 - 08:36 AM

I think that just means that visual c++ will not try to compile that file.

#14 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

Posted 03 May 2011 - 08:45 AM

Tried all other options, doesn't do anything... :c

#15 NightCreature83   Crossbones+   -  Reputation: 3782

Like
0Likes
Like

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, Mad Max

#16 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

Posted 03 May 2011 - 09:32 AM

Also didn't work... :|

#17 scgames   Members   -  Reputation: 2048

Like
0Likes
Like

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).

#18 fastcall22   Crossbones+   -  Reputation: 5753

Like
1Likes
Like

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".
QWxsIHRvYXN0LXRvYXN0aW5nIHRvYXN0ZXJzIGNhbiB0b2FzdCB0b2FzdGVkIHRvYXN0LCBhbHRob3Vn aCByZS10b2FzdGluZyB0b2FzdGVkIHRvYXN0IGlzIGdlbmVyYWxseSBub3QgcmVjb21tZW5kZWQgYnkg dGhlIG1hbnVmYWN0dXJlcnMgb2YgdG9hc3QtdG9hc3RpbmcgdG9hc3RlcnMuLi4=

#19 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

Posted 03 May 2011 - 10:52 AM

I also get this sometimes:
LINK : [external drive]\SDL_Tutorial\Debug\SDL_Tutorial.exe not found or not built by the last incremental link; performing full link
[external drive] being, of course, my external drive. :|

#20 xzbobzx   Members   -  Reputation: 120

Like
0Likes
Like

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.



PARTNERS