Accessing Cocoa/Quartz from a dynamic library function
Accessing Cocoa/Quartz from a dynamic library function
- Subject: Accessing Cocoa/Quartz from a dynamic library function
- From: Mikael Grev <email@hidden>
- Date: Mon, 1 Jun 2009 22:38:23 +0200
Hello all,
I'm new to this Mac development thing, but I'm old when it comes to
developing in general.
I'm trying to create a dylib with a function that will ultimately
notify me of screen refresh rectangles. It is all working when I run
it as an application (with a main method) but nothing happens if I run
the exact same code in a method in a library. What am I missing?
I know the dylib is being called, I can change the log strings and
they change appropriately. It is just the callback that doesn't get
called.
As you can see from my commented lines I have tried quite a few
combinations without luck, the callback is never called.
void MyScreenRefreshCallback ( CGRectCount count, const CGRect *
rectArray, void * userParameter) {
NSLog(@"Callback called!");
//for (int i=0; i < count; i++) {
//NSLog(@"Got a Rect");
//fprintf(stdout, "%f %f %f %f\n", rectArray[i].origin.x,
rectArray[i].origin.y, rectArray[i].size.width,
rectArray[i].size.height);
//}
}
void startLoop()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSLog(@"Starting...");
NSApplicationLoad();
//[NSApplication sharedApplication];
CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
[runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow: 10]];
//[NSApp run];
NSLog(@"Done.");
//CFAbsoluteTime now = CFAbsoluteTimeGetCurrent ();
//while ( CFAbsoluteTimeGetCurrent() - now < 15 ) {
// sleep(1);
//}
CGUnregisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
//return 0;
[pool release];
}
In hope for a simple solution.
Cheers,
Mikael
Mikael Grev
Systems Architect
MiG InfoCom AB
S:t Olofsg 28a, 3tr
753 32 Uppsala
Sweden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden