Re: programmatically instantiating and displaying NSWindow
Re: programmatically instantiating and displaying NSWindow
- Subject: Re: programmatically instantiating and displaying NSWindow
- From: "b.bum" <email@hidden>
- Date: Sat, 24 Jan 2004 23:52:13 -0800
On Jan 24, 2004, at 3:31 PM, David Cairns wrote:
.... reasonable looking code doing a lot of work by hand deleted ...
>
Uncaught exception: <NSInternalInconsistencyException> Error (1002)
>
creating CGSWindow
>
>
pro_05 has exited due to signal 5 (SIGTRAP).
>
>
whenever the function gets to the "[window makeKeyAndOrderFront:nil];"
>
call, and the program exits. I've thoroughly checked the archive, but
>
i can't seem to find anything about this problem, at least not that
>
will help me.
This sounds like you haven't initialized Cocoa correctly prior to
trying to bring up windows and views, etc. Specifically, the app
doesn't have a viable connection to the window manager and, as such,
core graphics is barfing when it tries to create the resources it needs
to manage the window.
You must call NSApplicationMain() (or the equivalent -- see the docs)
to bring up a Cocoa based application properly. Alternatively, you
could bring it up view Carbon and then use the Cocoa integration
functionality to pass control over to Cocoa (no real advantage to doing
so).
>
I am trying to programmatically instantiate an NSWindow object, because
>
most of my program is in C++, and i would like to avoid using IB as
>
much as possible, so I have a (c++) ViewController class, in which, I
>
include the following:
The implication of your post is that you are writing (or porting) a
game that will run primarily in OpenGL?
If that is the case, why not create a straightforward, standard, single
window, Cocoa app and pass control into your C++/OpenGL code as soon as
the first window is on screen? Let IB and the Xcode templated project
do all the OS X specific work for you as much as possible, and
customize away from that only where needed.
This will give you an application shell with a menu bar, preferences
window [if you want], hide menu, about panel, help, and all the other
standard bits of a first class OS X app. Then, once control is passed
to your OpenGL/C++ code, you can pretty much do whatever you want with
the one area of contention being integration with the event loop (which
will be an issue regardless) and, of course, screen management (which
will be an issue anyway).
b.bum
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.