Page 1 of 1

SDL - XCode

Posted: Thu Apr 07, 2011 11:05 pm
by ajtgarber
In my main.cpp file whenever I try to create an SDL_Rect my player class decides to stop rendering, even when there's absolutely no connection between
my player object and the rectangle. Anyone know whats going on?

Re: SDL - XCode

Posted: Fri Apr 08, 2011 9:06 am
by dandymcgee
You should probably post the relevant code, from the minimal circumstances in which it happens.

Re: SDL - XCode

Posted: Fri Apr 08, 2011 1:47 pm
by ajtgarber
main.cpp: http://pastebin.com/5hPrpmrh
bullet.cpp: http://pastebin.com/PWnPh6jq

In main you won't see an SDL_Rect since I was trying to "hide" it behind the bullet constructor
but even with that it refuses to draw the player. if I remove the bullet then it draws the player
just fine.

(Tell me if you want to see any other files)

Re: SDL - XCode

Posted: Tue May 03, 2011 12:30 pm
by Van-B
Probably not relevant, but I always thought that you had to use .mm for C++ files in XCode, otherwise it get's upset.

Re: SDL - XCode

Posted: Wed May 04, 2011 2:38 pm
by Falco Girgis
Van-B wrote:Probably not relevant, but I always thought that you had to use .mm for C++ files in XCode, otherwise it get's upset.
You're supposed to stop linking to the Appkit library/includes. But yeah, changing your .cpps to .mms does the same trick.

Why in god's name XCode is too stupid to stop including Objective-C libraries when you're clearly using only C++ is beyond me...

Re: SDL - XCode

Posted: Wed May 04, 2011 3:08 pm
by hurstshifter
GyroVorbis wrote: Why in god's name XCode is too stupid to stop including Objective-C libraries when you're clearly using only C++ is beyond me...
I think the answer is in there somewhere...

Re: SDL - XCode

Posted: Wed May 04, 2011 3:39 pm
by ajtgarber
I've renamed my cpps to mms its still doing the same thing. I tried removing SDLMain.h & SDLMain.m, also tried making a new "console application" including the SDL frameworks from there but it refused to compile.
I don't really understand why including those libraries would cause an SDL_Rect to mess up drawing my player (especially since they have no connection with one another)

Re: SDL - XCode

Posted: Thu May 12, 2011 9:27 am
by avansc
Your problem has NOTHING to do with what they mentioned. You do not use mm for c++, you use mm when you do objectiveC.

The reference Falco is making is that when you create a target, and its of type cocoa, it by default includes some things that can cause you issues. If you create whats called a BSD target, it wont be an issue.

NOTE: making a project and adding a target(binary) have differences, making a project will do all the setup for you, adding a target however expects you to not be the stupid one.

Xcode has a perfectly fine debugger built in that you can step through and exactly see where the player class stops rendering.

Re: SDL - XCode

Posted: Thu May 12, 2011 9:33 am
by Van-B
You need to use .MM to compile C++ classes.

That could have PLENTY to do with a problem with CPP files, XCode and classes.

Re: SDL - XCode

Posted: Thu May 12, 2011 11:52 am
by MrDeathNote
Van-B wrote:You need to use .MM to compile C++ classes.

That could have PLENTY to do with a problem with CPP files, XCode and classes.
You don't man, i use xcode for mac and it compiles my .cpp files just fine.

Re: SDL - XCode

Posted: Fri May 13, 2011 9:42 am
by Van-B
Ahh, its probably related to the way I've been adding files - I would add an .M, then change it to .MM, ignoring the .CPP extension completely.