SDL - XCode

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

SDL - XCode

Post 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?
User avatar
dandymcgee
ES Beta Backer
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: SDL - XCode

Post by dandymcgee »

You should probably post the relevant code, from the minimal circumstances in which it happens.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Re: SDL - XCode

Post 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)
User avatar
Van-B
Chaos Rift Regular
Chaos Rift Regular
Posts: 125
Joined: Tue Aug 10, 2010 7:17 am
Current Project: iPhone puzzle game
Favorite Gaming Platforms: All - Except Amiga
Programming Language of Choice: DBPro, ObjC++
Location: Scotland

Re: SDL - XCode

Post 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.
Health, ammo.... and bacon and eggs.
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: SDL - XCode

Post 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...
User avatar
hurstshifter
ES Beta Backer
ES Beta Backer
Posts: 713
Joined: Mon Jun 08, 2009 8:33 pm
Favorite Gaming Platforms: SNES
Programming Language of Choice: C/++
Location: Boston, MA
Contact:

Re: SDL - XCode

Post 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...
"Time is an illusion. Lunchtime, doubly so."
http://www.thenerdnight.com
ajtgarber
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 97
Joined: Wed Jun 10, 2009 8:56 am

Re: SDL - XCode

Post 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)
User avatar
avansc
Respected Programmer
Respected Programmer
Posts: 1708
Joined: Sun Nov 02, 2008 6:29 pm

Re: SDL - XCode

Post 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.
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
User avatar
Van-B
Chaos Rift Regular
Chaos Rift Regular
Posts: 125
Joined: Tue Aug 10, 2010 7:17 am
Current Project: iPhone puzzle game
Favorite Gaming Platforms: All - Except Amiga
Programming Language of Choice: DBPro, ObjC++
Location: Scotland

Re: SDL - XCode

Post 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.
Health, ammo.... and bacon and eggs.
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: SDL - XCode

Post 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.
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
User avatar
Van-B
Chaos Rift Regular
Chaos Rift Regular
Posts: 125
Joined: Tue Aug 10, 2010 7:17 am
Current Project: iPhone puzzle game
Favorite Gaming Platforms: All - Except Amiga
Programming Language of Choice: DBPro, ObjC++
Location: Scotland

Re: SDL - XCode

Post 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.
Health, ammo.... and bacon and eggs.
Post Reply