Routing to a certain file in C++
If I bundled a file in a package, (in C++) how would I get it to route to that file every time with different user names? For instance to get to a file on my desktop "/users/matthew/desktop/myapp/data/titlehead.jpg" except at a point that I can use the "matthew" part as any user name...I need this information to finish a project of mine...
Last login: Sat Aug 6 09:15:05 on console
Welcome to Darwin!
Matt-Chelens-Computer:~ matthew$
You'd just do "(name_of_app).app/Contents/data/titlehead.jpg". That'll load it from within the bundle. This will only work assuming that's the correct location of the file and if you actually built in into the app. After building, right click the app and select Show Package Contents. This will let you explore the insides of the app and see where files are located.
I've read somewhere (can't remember where now...) that you're not really guaranteed any working directory from within a running .app. Here's a super safe way, if you have an Obj-C component to your app (probably at least main, yeah?) --
Then put a directory called "data" in your Resources dir inside the app bundle (e.g. with a copy build step) that has all your data files in it. You can then use relative paths to access it.
Code:
NSString * resPath = [[NSBundle mainBundle] pathForResource:@"data" ofType:nil];
chdir([resPath cString]);Then put a directory called "data" in your Resources dir inside the app bundle (e.g. with a copy build step) that has all your data files in it. You can then use relative paths to access it.
You want to change the cwd (current working directory) and keep things relative to the Resources folder in your app
-Jon
PHP Code:
CFURLRef resourceURL = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
char resourcePath[PATH_MAX];
if (CFURLGetFileSystemRepresentation(resourceURL, true, (UInt8 *)resourcePath, PATH_MAX))
chdir(resourcePath);
else
fprintf(stderr, "Cannot change path to resources directory!\n");
ok, with that answered, how do I get something to route to a certain webpage if a button is hit? ie: the 'Buy Now' button
Last login: Sat Aug 6 09:15:05 on console
Welcome to Darwin!
Matt-Chelens-Computer:~ matthew$
Code:
CFURLRef url;
if(( url = CFURLCreateWithString( kCFAllocatorDefault,
CFSTR( "http://www.sealfin.com/" ),
NULL )) != NULL )
{
LSOpenCFURLRef( url,
NULL );
CFRelease( url );
}That works, but error handling code would probably be nice...
Mark Bishop
And Obj-C in case you have a use for it:
Code:
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: @"http://foo"]];
Understood, last question, through OGL, how would you import a model that you made? Not just make quads and tris
I'm adding this but, last one for sure, in Cocoa or C++, how would you get to a certain item in the .nib file when using the Cocoa and C++ frameworks? ie: a slider, WebView, Text bar, button.
I'm adding this but, last one for sure, in Cocoa or C++, how would you get to a certain item in the .nib file when using the Cocoa and C++ frameworks? ie: a slider, WebView, Text bar, button.
Last login: Sat Aug 6 09:15:05 on console
Welcome to Darwin!
Matt-Chelens-Computer:~ matthew$
Keep in mind that for unrelated questions, separate topics are usually best. For the nibs, when you load the nib itself the runtime will take care of connecting all of your outlets/actions for you, so if you do that in IB it will keep them.
Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
I asked that because I'm trying to do a drop down menu that will go to different places for each item...
Last login: Sat Aug 6 09:15:05 on console
Welcome to Darwin!
Matt-Chelens-Computer:~ matthew$
Blorx2 Wrote:I'm adding this but, last one for sure, in Cocoa or C++, how would you get to a certain item in the .nib file when using the Cocoa and C++ frameworks? ie: a slider, WebView, Text bar, button.This is where you have to use objc in a c++ file. Presuming you're using xcode, then what it does is use GCC to compile the code and build it with the nib files. It compiles both languages in the same program. Therefore, every piece of code you write-just because it only has c++ code in it doesn't mean it is limited to that.
I however, recommend you go the nice and easy route with full screen SDL
You can get on to nibs later when necessary, as you are only making games.
Actually, I'm using this stuff for a weird game and a 'forum browser' that people have talked about and i decided to give it a go, so SDL won't help much in this case.
Last login: Sat Aug 6 09:15:05 on console
Welcome to Darwin!
Matt-Chelens-Computer:~ matthew$
If you're making an app and not a game, then you really should be in idevapps.com .
For a first proper like game thingy, I also recommend you don't chose a weird idea for one.
For a first proper like game thingy, I also recommend you don't chose a weird idea for one.
Blorx2 Wrote:Understood, last question, through OGL, how would you import a model that you made? Not just make quads and trisThat is the only way to import models. That's all that Maya, Wings3D, or any modeler does. It just keeps track of quads and tris and draws them all (though from what I've read, OpenGL makes all quads into tris anyway). There's no real set-up way in OGL to do this. You have to write your own code.
Presumably the easy route to do it would be to parse the text based obj files and taking tris and quads from them...
Perhaps quake 2 models may be easier to implement - mark (the one who made rotrix) used them so he must have found an easy way to do them rather than another fileformat.
Perhaps quake 2 models may be easier to implement - mark (the one who made rotrix) used them so he must have found an easy way to do them rather than another fileformat.

