GLUT apple menu close application

Member
Posts: 81
Joined: 2007.07
Post: #1
Is there a way to disable or capture the Quit Application command when issued by the command bar? The problem I am having is my game isn't saving settings when its closed via this method, glutMainLoop isn't returning, maybe I can capture this by hooking exit(int)?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
glutMainLoop never returns, as the docs say.

No, you can't alter the fixtures that GLUT gives you. If you want more control, you can write your GUI yourself in Cocoa.

You can use "atexit" to have something run when your app exits.
Quote this message in a reply
Member
Posts: 20
Joined: 2007.02
Post: #3
Can't you just do something like

Begin/Init code
glutMainLoop
Save Settings
end

Tobs
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #4
No, because glutMainLoop doesn't return, it calls exit(1) instead. Smile
Quote this message in a reply
Moderator
Posts: 370
Joined: 2006.08
Post: #5
you could always have another program load your program as a child and then you could have code after the child program exited; this probably isn't a great way to go, though...you'd be better off taking OSC's route.
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Member
Posts: 567
Joined: 2004.07
Post: #6
...because glut is a load of flying !$%@#.
Personally, I'd just save the settings as they are set. Of course, you could always use atexit, as osc suggested, to do what you were doing before.

It's not magic, it's Ruby.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #7
Nayr Wrote:...because glut is a load of flying !$%@#.

... since when? Rolleyes
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
GLUT's very good at what it was designed for -- being a very quick and easy way to get an OpenGL program up and running.

For anything else (like, say, shipping a game), it's precisely what Nayr says it is Wink
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #9
GLUT is what GLUT is. It works perfectly for what it was designed for. Calling it a superlatively bad thing is not what it was designed for.Wink
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #10
Personally, I think setting up your own custom OpenGL view is a learning experience. (BTW, if your using Cocoa, do the extra work and derive from NSView, not NSOpenGLView. You won't get true double buffering the other way). Anyway, ADC has some pretty good sample code for this sort of thing...
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #11
Nevada Wrote:Personally, I think setting up your own custom OpenGL view is a learning experience. (BTW, if your using Cocoa, do the extra work and derive from NSView, not NSOpenGLView. You won't get true double buffering the other way).
Say wuh? What is `true' double buffering? NSOpenGLView has worked perfectly fine for me for years.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
I think what Nevada is trying to say is that if you drag an NSOpenGLView in IB2, you can't get double buffering. However, that's not to say that NSOpenGLView is useless; dragging a custom view, making it an instance of a custom subclass of NSOpenGLView, works just fine.

Personally, these days, I prefer to avoid NSOpenGLView, however. I find that I don't want many of the things it does for me, and do want a bunch of stuff which is just as hard to add to NSOpenGLView as NSView, so there's no benefit.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #13
OneSadCookie Wrote:I think what Nevada is trying to say is that if you drag an NSOpenGLView in IB2, you can't get double buffering. However, that's not to say that NSOpenGLView is useless; dragging a custom view, making it an instance of a custom subclass of NSOpenGLView, works just fine.
Yeah, that's what I've always done. I haven't had any problems with it at all, and have not yet found a need to subclass directly from NSView.

The IB palette glView is junk. I'm not sure why they have it in there.
Quote this message in a reply
Member
Posts: 100
Joined: 2006.05
Post: #14
Eh, I just said screw it and went with NSView. I think in the long run I may need something that NSOpenGLView doesn't support. I just remember constantly trying to set up a pixel format for it, but consistently getting jitters.
Quote this message in a reply
Moderator
Posts: 3,570
Joined: 2003.06
Post: #15
Nevada Wrote:Eh, I just said screw it and went with NSView. I think in the long run I may need something that NSOpenGLView doesn't support. I just remember constantly trying to set up a pixel format for it, but consistently getting jitters.
What do you mean by `jitters'? What were you using for your pixel format? Were you mistakenly trying to use NSOpenGLPFAStereo or something? If NSView is really better than NSOpenGLView performance-wise then that is *really* important! I am a bit surprised here that NSOpenGLView sounds like such a bad subclass of NSView to begin with. I am skeptical but I'll stop using it if there is something wrong with it. I have seen absolutely nothing wrong with it for years, and I have used it a LOT, so I am very curious about this.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  SDL and menu bar on OS X A_SN_ 9 9,018 Feb 7, 2012 11:51 AM
Last Post: trailmix
  Can't get menu bars to work. XSTNX 0 2,268 Jun 26, 2009 09:08 AM
Last Post: XSTNX
  OpenGL Menu engine? BinarySpike 4 7,191 Jun 11, 2007 09:43 PM
Last Post: JeroMiya
  Remove the File Menu from app guvidu 2 3,298 Mar 23, 2007 12:43 PM
Last Post: PowerMacX
  Enabling the "quit" menu function in an SDL program ferum 2 4,012 Sep 10, 2006 02:35 PM
Last Post: PowerMacX