Fullscreen/Window Setup/toggle
I'm using Objective C++ (so I have all those options). In the past I'd just inherit from NSOpenGLView and have a set view in a window to work in. This was great for the most part (as I like playing games in a window, even if the window takes up most of the screen).
But time has come for me to be able to do both windowed and fullscreen, and toggle. Advice on how to do this? Code? Donuts?
But time has come for me to be able to do both windowed and fullscreen, and toggle. Advice on how to do this? Code? Donuts?
much love cookie
m'k, it toggles. but the code I use in drawrect doesn't draw when in full screen. In fact, the full screen view is all black. What's up?
You need to be careful about which OpenGL context is current, particularly given that NSOpenGLView likes to mess with it behind your back. Check the example code, it works
Something that bit me bad is that if you're sharing contexts, it doesn't share state. Even if you use the copyState selector, it doesn't copy things like the projection matrix.
If you're not setting up your projection again after the switch, you're dead. Bang.
If you're not setting up your projection again after the switch, you're dead. Bang.
That's actually a great feature of context sharing. Say you have two NSOpenGLView displaying stuff at the same time. Both are going to have their own context, and each will have their own state. However, they can share ressources in order to save VRAM. This way, you can have the same scene seen from different point of views (and/or with different shaders enabled) each in their own window.
the code below is crashing between a = 2 and a=3
Code:
if (_fullScreenContext != nil)
{
int a=0;
NSLog(@"%d",a++); //0
[_windowedContext clearDrawable];
NSLog(@"%d",a++);
CGCaptureAllDisplays();
NSLog(@"%d",a++); // 2
CGDisplaySwitchToMode(kCGDirectMainDisplay, (CFDictionaryRef)_fullScreenMode);
NSLog(@"%d",a++);
[_fullScreenContext setFullScreen];
NSLog(@"%d",a++); //4
[_fullScreenContext makeCurrentContext];
NSLog(@"%d",a++);
_fullScreen = YES;
NSLog(@"%d",a++); //6
NSSize contextSize;
NSLog(@"%d",a++);
contextSize.width = CGDisplayPixelsWide(kCGDirectMainDisplay);
NSLog(@"%d",a++); //8
contextSize.height = CGDisplayPixelsHigh(kCGDirectMainDisplay);
NSLog(@"%d",a++);
GSEventOpenGLContextStateInvalidated();
NSLog(@"%d",a++); //10
GSEventOpenGLContextResized(contextSize.width, contextSize.height);
NSLog(@"%d",a++);
}Quote:That's actually a great feature of context sharing.Agreed, I just made the stupid assumption that they did share state more thoroughly and spent a month debugging.
skyhawk Wrote:the code below is crashing between a = 2 and a=3
Code:
CGDisplaySwitchToMode(kCGDirectMainDisplay, (CFDictionaryRef)_fullScreenMode);
Then _fullScreenMode must be invalid in some way...
-Keith
I'm pretty sure it is not set to anything anywhere.
EDIT: I see my issue, I'll let you know if the fix works later tonight
EDIT: I see my issue, I'll let you know if the fix works later tonight
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| SDL. How to hide fullscreen window | e40pud | 1 | 3,417 |
Mar 11, 2010 01:23 PM Last Post: cmiller |
|
| xCode/SDL Setup | hammonjj | 2 | 4,292 |
Mar 2, 2007 06:37 AM Last Post: hammonjj |
|
| Copying from OpenGL window to other window | Ingemar | 7 | 4,064 |
Nov 4, 2006 03:50 AM Last Post: OneSadCookie |
|
| SDL 2D OpenGL setup | unknown | 13 | 6,376 |
Jul 16, 2005 09:07 PM Last Post: unknown |
|
| Setup! | Coin | 16 | 8,527 |
Mar 25, 2005 10:30 AM Last Post: tigakub |
|

