Showing resize control over NSOpenGLView - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Showing resize control over NSOpenGLView (/thread-6160.html)
Showing resize control over NSOpenGLView - AnotherJake - Oct 22, 2004 11:55 AM
Is there a way to get the resize control to show in the lower right corner of an NSOpenGLView where the view fills the entire window?
Showing resize control over NSOpenGLView - PowerMacX - Oct 22, 2004 07:10 PM
Faking it with a texture? Remember that on machines without Quartz Extreme enabled, anything over an OpenGL view will make it run MUCH slower.
Showing resize control over NSOpenGLView - AnotherJake - Oct 22, 2004 07:51 PM
Wouldn't lines be faster in this case if it were to be faked? I think I can do a good job with it, but should it be faked? What happens if Apple eventually takes care of it themselves? What if they change the style of the resize control down the road? Should I wait to see what happens with Tiger? This has been bugging me since OS X 10.1. I've done some searching here, mamasam, and general google and haven't found a whisper of it (not that it's not out there).
I guess the reason I'm bringing it up is because I recently sent an alpha of a level editor I'm working on to a friend, who I trust, and has a lot of experience with Macs, and he had no idea that he could change the size of the window until I told him. This seems really wrong to me. I think I should put at least a hint down there or something.
So if it needs to be faked, then what should be the best procedure to do so? Check for version "this" and "that"? Add a check for the future if it never gets maintained? Should I really care and just fake it anyway and say Apple screwed up future versions?
I'm still holding out for a "proper" way to deal with this if it can be found here.
Showing resize control over NSOpenGLView - arekkusu - Oct 22, 2004 09:48 PM
If you really want this, just fake it with a little alpha blended textured quad in the corner of your scene. You can get the bitmap to use from the System resources with an app like ThemePark (/System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Resources/Extras.rsrc, pxm# 450, image 3 for Aqua and 4 for BM.)
The default view system doesn't do this, because the GL surface is floated on top of all the other Quartz surfaces. I think it's unlikely that Apple will change it in Tiger (though feel free to log a feature request!)
Showing resize control over NSOpenGLView - PowerMacX - Oct 23, 2004 05:09 PM
Just in case I made you think otherwise, I didn't mean fake a "white square with some drag lines in it", because that always looks awful! So awful that Apple added a little command line switch so you could decide wether you wanted them enabled in Java apps or not. The kind of "fake" drag corner I'm suggesting is just some "drag lines" in the corner, just as Preview does. And, no, drawing those lines as GL lines is a bad idea, since line antialiasing doesn't work in many graphic cards (just ask arekkusu )
Go with the alpha blended quad, even if Apple decides to change the resize graphic in the future is unlikely that it will be much different (it has been the same since System 8)
Showing resize control over NSOpenGLView - AnotherJake - Oct 23, 2004 08:13 PM
Don't worry, the way it's done in Preview is exactly what I had in mind to begin with. I don't think those lines are anti-aliased though, not that it matters anyway since line drawing style can't be guaranteed across different renderers. I agree, the alpha blended quad is the way to go and it looks just like the real thing after trying it out. It still reallly bugs me that this is the way I have to do things to give any indication of resizability to the user. There's just no logical way, that I've been able to come up with, that would make this technique future-compatible. Make no mistake about it, this is a clumsy hack around an Apple mistake. If they are going to fix this, I hope they decide to make it an optional feature (at least initially) instead of forcing their fix over those of us who've had to fill the gap in the meantime.
Showing resize control over NSOpenGLView - arekkusu - Oct 23, 2004 08:28 PM
You could say the same thing about GL minimization, or fullscreen events, or splitview resizing, or a hundred other things. Nobody writes perfect code the first time, especially OS vendors. Writing an OS is hard! Yeah, we have to deal with backwards and forwards compatibility, but that's life.
At least your workaround doesn't involve using any private APIs
Showing resize control over NSOpenGLView - AnotherJake - Oct 23, 2004 09:22 PM
arekkusu Wrote:You could say the same thing about GL minimization, or fullscreen events, or splitview resizing, or a hundred other things.... like key up events not being sent with the cmd key... Yeah, I hear ya'. You're right, I shouldn't sound like such a pooh pooh about it. I've found over the years that often one of the more frustrating things about programming is running into situations like this where you wind up trying to second-guess the OS vendor. It's like trying to hit a moving target all the time. Not like this particular problem is such a huge deal, I realize it's just a realitively minor detail in the grander scheme of things. It just really bugged me, but I'm happy with the solution we seem to have agreed upon here. I really appreciate your input guys.
Showing resize control over NSOpenGLView - reubert - Oct 24, 2004 01:31 AM
you could always leave a border around your view if it's resizable. I don't see why you'd want to have a windowed game that takes up the whole view anyway. Just chuck some text in there that says "Windowed Mode - Paused" and set full screen as the default, and you'll be right. Otherwise, if it's actually a windowed-style game, why isn't the score, lives left etc. written next to the OpenGLView rather than on top of it?
Showing resize control over NSOpenGLView - arekkusu - Oct 24, 2004 01:48 AM
Because borders suck.
Showing resize control over NSOpenGLView - MattDiamond - Oct 24, 2004 09:48 AM
PowerMacX Wrote:Just in case I made you think otherwise, I didn't mean fake a "white square with some drag lines in it", because that always looks awful!
My game Black Cube showed the user that they could resize the window simply by drawing three white diagonal lines in the bottom corner. (The background was black for the entire window.) It didn't look awful, and several people commented about the resizability so I know it worked.
Looking at my Safari window that I'm typing this in, it's just three dark lines drawn over the brushed steel frame of the window. If you look really closely you can see that they also draw light lines to suggest depth, but they are almost invisible. It's very basic, and I don't think the lines are anti-aliased either.
Showing resize control over NSOpenGLView - PowerMacX - Oct 25, 2004 12:12 PM
MattDiamond Wrote:My game Black Cube showed the user that they could resize the window simply by drawing three white diagonal lines in the bottom corner. (The background was black for the entire window.) It didn't look awful, ...
You didn't read my entire post, did you ?
Showing resize control over NSOpenGLView - MattDiamond - Oct 25, 2004 03:59 PM
PowerMacX Wrote:You didn't read my entire post, did you ?
Nope, my bad. Somehow I went too fast over the middle bit. Sorry!
You and I basically agree, but my point was (in part) that it doesn't have to be a textured quad. I'd go with whichever way fits with the current code. If you already load and display some quad sprites then this is just one more. In my case I was already drawing some GL_LINE's so drawing three more in the corner was painless.
Showing resize control over NSOpenGLView - arekkusu - Oct 25, 2004 04:10 PM
Lines won't look quite the same as the Aqua widget. Of course that might not matter to you.
If you want to closely approximate the Aqua widget, this will build a 16x16 texture for you (save 4k of disk):
It's still an approximation because the real widget has very (very) subtle variation across the largest line, but you can't really tell without comparing individual pixels in Photoshop.
Showing resize control over NSOpenGLView - AnotherJake - Oct 25, 2004 06:13 PM
Awesome job arekkusu! Works like a charm. It's not quite perfect but I think it's actually better than the alpha blended quad coming straight out of the system prefs as you suggested earlier. It's great to have this hard-coded!