|
From: <c99...@us...> - 2006-11-26 01:59:08
|
Revision: 385
http://svn.sourceforge.net/cadcdev/?rev=385&view=rev
Author: c99koder
Date: 2006-11-25 17:59:05 -0800 (Sat, 25 Nov 2006)
Log Message:
-----------
Tiki: Mac OS X: Pass argc,argv onto tiki_main. Append the document passed by Finder onto argv (see tikitest's controller for example). Output argc,argv in TikiTest.
Modified Paths:
--------------
tiki/examples/TikiTest/src/Controller.h
tiki/examples/TikiTest/src/Controller.m
tiki/examples/TikiTest/src/test.cpp
tiki/osx/include/Tiki/TikiMain.h
tiki/osx/include/Tiki/tikitypes.h
tiki/osx/src/TikiMain.m
tiki/osx/src/init_shutdown.cpp
Modified: tiki/examples/TikiTest/src/Controller.h
===================================================================
--- tiki/examples/TikiTest/src/Controller.h 2006-11-25 20:53:55 UTC (rev 384)
+++ tiki/examples/TikiTest/src/Controller.h 2006-11-26 01:59:05 UTC (rev 385)
@@ -9,5 +9,6 @@
IBOutlet NSWindow *mainWindow;
TikiMain * tm;
+ NSString * openFileName;
}
@end
Modified: tiki/examples/TikiTest/src/Controller.m
===================================================================
--- tiki/examples/TikiTest/src/Controller.m 2006-11-25 20:53:55 UTC (rev 384)
+++ tiki/examples/TikiTest/src/Controller.m 2006-11-26 01:59:05 UTC (rev 385)
@@ -5,12 +5,16 @@
void tiki_main();
@implementation Controller
+- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
+{
+ openFileName = filename;
+}
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
TikiMain * otm = [[TikiMain alloc] retain];
tm = otm;
- [tm doMainWithWindow: mainWindow andView: mainView andMainFunc: tiki_main];
+ [tm doMainWithWindow: mainWindow andView: mainView andMainFunc: tiki_main andOpenFile:openFileName];
tm = nil;
[otm release];
}
Modified: tiki/examples/TikiTest/src/test.cpp
===================================================================
--- tiki/examples/TikiTest/src/test.cpp 2006-11-25 20:53:55 UTC (rev 384)
+++ tiki/examples/TikiTest/src/test.cpp 2006-11-26 01:59:05 UTC (rev 385)
@@ -240,6 +240,11 @@
Tiki::GL::showCursor(false);
Hid::callbackReg(tkCallback, NULL);
+ Debug::printf("argc: %i\n", argc);
+ for(int i=0; i<argc; i++) {
+ Debug::printf("argv[%i]: %s\n",i,argv[i]);
+ }
+
#if TIKI_PLAT != TIKI_DC
//Attach events happen before we start :(
mp[0].valid=1;
Modified: tiki/osx/include/Tiki/TikiMain.h
===================================================================
--- tiki/osx/include/Tiki/TikiMain.h 2006-11-25 20:53:55 UTC (rev 384)
+++ tiki/osx/include/Tiki/TikiMain.h 2006-11-26 01:59:05 UTC (rev 385)
@@ -19,10 +19,15 @@
NSView * mainView;
pthread_t glThreadHnd;
void (*mainFunc)(int, char**);
+ NSString * openFile;
}
- (void) doMainWithWindow: (NSWindow *)mainWindow andView: (NSView *)mainView
andMainFunc: (void (*)(int, char**))mainFunc;
+
+- (void) doMainWithWindow: (NSWindow *)mainWindow andView: (NSView *)mainView
+ andMainFunc: (void (*)(int, char**))mainFunc andOpenFile: (NSString *)openFile;
+
- (void) quitSoon;
@end
Modified: tiki/osx/include/Tiki/tikitypes.h
===================================================================
--- tiki/osx/include/Tiki/tikitypes.h 2006-11-25 20:53:55 UTC (rev 384)
+++ tiki/osx/include/Tiki/tikitypes.h 2006-11-26 01:59:05 UTC (rev 385)
@@ -17,6 +17,8 @@
#define TIKI_WIN32 1
#define TIKI_SDL 2
#define TIKI_DC 3
+#define TIKI_GP2X 4
+#define TIKI_NDS 5
#define TIKI_PLAT TIKI_OSX
namespace Tiki {
Modified: tiki/osx/src/TikiMain.m
===================================================================
--- tiki/osx/src/TikiMain.m 2006-11-25 20:53:55 UTC (rev 384)
+++ tiki/osx/src/TikiMain.m 2006-11-26 01:59:05 UTC (rev 385)
@@ -69,16 +69,23 @@
}
@implementation TikiMain
+- (void) doMainWithWindow: (NSWindow *)iMainWindow andView: (NSView *)iMainView
+ andMainFunc: (void (*)(int, char**))iMainFunc
+{
+
+ [self doMainWithWindow:iMainWindow andView:iMainView andMainFunc:iMainFunc andOpenFile: nil];
+}
- (void) doMainWithWindow: (NSWindow *)iMainWindow andView: (NSView *)iMainView
- andMainFunc: (void (*)(int, char**))iMainFunc;
+ andMainFunc: (void (*)(int, char**))iMainFunc andOpenFile: (NSString *)iOpenFile
{
width = targetW;
height = targetH;
mainWindow = iMainWindow;
mainView = iMainView;
mainFunc = iMainFunc;
-
+ openFile = iOpenFile;
+
[mainWindow makeKeyAndOrderFront:nil];
[mainWindow makeFirstResponder:mainView];
[mainWindow setAcceptsMouseMovedEvents:true];
@@ -265,10 +272,32 @@
tiki_scene_finish_hook();
- // XXX get args in here
assert( mainFunc );
- mainFunc(0, NULL);
+ NSArray *args;
+ if(openFile != nil)
+ args = [[[NSProcessInfo processInfo] arguments] arrayByAddingObject:openFile];
+ else
+ args = [[NSProcessInfo processInfo] arguments];
+
+ int argc = [args count];
+
+ if(argc > 0) {
+ char ** argv = malloc(sizeof(char*) * argc);
+ NSString *arg;
+
+ for(int i = 0; i < argc; i++) {
+ arg = [args objectAtIndex: i];
+ argv[i] = malloc([arg length] + 2);
+ strncpy(argv[i],[arg cString],[arg cStringLength]);
+ argv[i][[arg cStringLength]] = '\0';
+ }
+ mainFunc(argc, argv);
+ } else {
+ mainFunc(0, NULL);
+ }
+
+
NSLog(@"glThread exiting");
[NSApp terminate: self];
Modified: tiki/osx/src/init_shutdown.cpp
===================================================================
--- tiki/osx/src/init_shutdown.cpp 2006-11-25 20:53:55 UTC (rev 384)
+++ tiki/osx/src/init_shutdown.cpp 2006-11-26 01:59:05 UTC (rev 385)
@@ -11,9 +11,11 @@
#include <CoreFoundation/CFString.h>
#if TIKI_PLAT == TIKI_OSX
-# include <OpenAL/alut.h>
+# include <OpenAL/al.h>
+# include <OpenAL/alc.h>
#else
-# include <alut.h>
+# include <al.h>
+# include <alc.h>
#endif
#include "Tiki/sound.h"
@@ -27,7 +29,17 @@
namespace Tiki {
bool init(int argc, char **argv) {
- alutInit(&argc, argv);
+ ALCdevice *dev = NULL;
+ ALCcontext *ctx = NULL;
+
+ dev = alcOpenDevice(getenv("OPENAL_DEVICE")); // getenv()==NULL is okay.
+ if (dev != NULL) {
+ ctx = alcCreateContext(dev, 0);
+ if (ctx != NULL) {
+ alcMakeContextCurrent(ctx);
+ alcProcessContext(ctx);
+ } // if
+ } // if
Audio::Sound::initGlobal();
Audio::Stream::initGlobal();
@@ -42,7 +54,7 @@
Audio::Stream::shutdownGlobal();
Hid::shutdown();
- alutExit();
+ //alutExit();
}
void setName(const char *windowName, const char *icon) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|