Just in case there are any OS X heavyweights out there who grok the Cocoa thing, Frank and I are engaged in a pitched battle with Apple Glut, OpenMCL, Emacs, Aqua, Cocoa, and I am probably leaving someone out. :)
Begin forwarded message:
From: Hamilton Link hamlink@comcast.net Date: November 10, 2004 11:08:13 PM EST To: Kenneth Tilton ktilton@nyc.rr.com Cc: openmcl-devel@clozure.com Subject: Re: [Openmcl-devel] The Miracle of opengl-ffi.lisp Astounds Newby!
On Nov 10, 2004, at 4:36 PM, Kenneth Tilton wrote:
Platform: Mikel Evins's Lisp in a box, aka OpenMCL and Slime and Emacs
OK, the good news is that a significant amount of Cello has been ported to OS X/OpenMCL. If I could only manage to build ImageMagick and crucially the Wand API therein I think we could pop the cork.
But that is not why I am here. We observe that when the demo in opengl-ffi.lisp runs, the menubar changes to "Simple OpenGL Example" or some such and some standard menu iems appear.
<ogl.lisp>
That example was great because it got us going with calling Apple's Glut just to get a window open. ie, We borrowed liberally from that code and have been borrowing more to try to solve this problem:
The Cello window appears but the menu bar stays as Emacs's.
This is what I'd expect.
Emacs is its own program, and is forking off the lisp program and talking to it by attaching to its stdio. When the cocoa environment gets fired up, the lisp program is turning from a command-line app into a more aqua-ish app, and makes its own windows in that context. You should, for example, see a lisp doc item appear when the cocoa stuff is loaded, and if you click on the opengl window you should end up changing the window focus and thus the foremost app, and the openmcl menubar should appear. Switching back to emacs will get its menubar back. This is essentially identical to running openmcl/cocoa from the terminal, and switching between the terminal program's window (which holds a command line view of the lisp program) and the aqua view of lisp once cocoa is started.
Mind you this artifact of the transition from unix app to aqua app might be worth noting somewhere in the docs... I think we have or were going to have an FAQ? Dan?
And if you'd like a more extensive opengl example, where glut is used less (um, not at all actually iirc), look in the ccl/examples/rubix directory. Yes, looking now I made it use a NSOpenGLView and handle mouse events etc. through that view, and dispensed with glut entirely. It's more cocoa-friendly. When I first did the serpinski's gasket example (in opengl-ffi.lisp) it was using glut through the normal FFI, and I don't know if it ever got ported to the cocoa APIs, although I seem to recall GB taking a crack at it.
But anyway yeah, look at the rubix example. It's way better. And feel free to ask questions, to the list preferably, about the cocoa bridge or NSOpenGLView. Mind you that I may send you to the Cocoa docs for some things.
And if you want to make code look like anything, emulate the rubix example! It's much newer and it built on lessons learned from opengl-ffi.
h
Another contrast between opengl-ffi.lisp and Cello is that the former gets key events and the latter does not. (This sounds like the same thing to me, but anyway....)
Frank is slowly making the Cello demo look more and more like OpenGL-ffi's trying to make it work, while I am slowly replacing code in OpenGL-ffi trying to make it fail. That should pay off eventually, but I thought I would drop in here to see if anyone knew by what magic opengl-ffi was getting the menu bar and key events.
btw, my guess is there some mystery about OS X we are missing, not OpenMCL, but I thought I would cover all the bases just in case my guessqork is off.
kenny _______________________________________________ Openmcl-devel mailing list Openmcl-devel@clozure.com http://clozure.com/mailman/listinfo/openmcl-devel
Kenneth Tilton writes:
Just in case there are any OS X heavyweights out there who grok the Cocoa thing, Frank and I are engaged in a pitched battle with Apple Glut, OpenMCL, Emacs, Aqua, Cocoa, and I am probably leaving someone out. :)
As far as I can tell from this message, you're really just having an issue with OpenMCL not being its own app from the window-manager's point of view. The classic way to do this would be to call Initialize() (from Carbon.h), but also see functions like SetMenuBarFromNib, for a more modern approach. I don't have a ton of time, preparing for a new job, the ensuing move, assisting in the hotel strike here, and on and on, but feel free to cc me in your machinations, I'm not an OS X expert, but I might be able to help.
Busy as usual, Thomas
Thanks, Thomas. The puzzle is that the OpenMCL example code works in all respects: gets a menubar, and gets key events. But no matter how closely we make our cl-ftgl-test demo it gets neither menu bar nor key events! It does get display events.
Once more into the breach! I will try again simply morphing the working code toward sours to see if/when it stops working.
kenny