NSGL full screen problems
Can anyone figure out why this only gives me a black screen when I attempt to go into full screen?
drawRect: is implemented by this class' subclass. It draws fine in windowed mode, but draws nothing in full screen. I've already determined through lots of NSLogs that the subclass' drawRect: gets called in full screen. I get no error messages on the console.
Code:
- (id)initWithFrame:(NSRect)frameRect color:(int)color depth:(int)depth
{
NSOpenGLPixelFormatAttribute attr[] =
{
NSOpenGLPFAWindow,
NSOpenGLPFASingleRenderer,
NSOpenGLPFANoRecovery,
NSOpenGLPFAScreenMask,
(NSOpenGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAAccelerated,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)color,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depth,
(NSOpenGLPixelFormatAttribute)0
};
NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if(pixelFormat == nil)
{
NSLog(@"Windowed pixel format is null");
return nil;
}
[pixelFormat autorelease];
attr[0] = NSOpenGLPFAFullScreen;
NSOpenGLPixelFormat *fullScreenPixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr];
if(fullScreenPixelFormat == nil)
{
NSLog(@"Full screen pixel format is null");
return nil;
}
[fullScreenPixelFormat autorelease];
self = [super initWithFrame:frameRect pixelFormat:pixelFormat];
if(self == nil)
{
NSLog(@"View is null");
return nil;
}
fullScreenContext = [[NSOpenGLContext alloc] initWithFormat:fullScreenPixelFormat
shareContext:[self openGLContext]];
if(fullScreenContext == nil)
{
NSLog(@"Full screen context is null");
[self dealloc];
return nil;
}
isFullScreen = NO;
[self initApp];
[self initOpenGL];
[self reshape];
return self;
}
- (id)initWithFrame:(NSRect)frameRect
{
self = [self initWithFrame:frameRect
color:DEFAULT_COLOR
depth:DEFAULT_DEPTH];
if(self == nil)
{
NSLog(@"View is null");
return nil;
}
return self;
}
- (void)initApp
{
[NSTimer scheduledTimerWithTimeInterval:0.001
target:self
selector:@selector(drawRect:)
userInfo:nil
repeats:YES];
[[self window] setDelegate:self];
}
- (IBAction)toggleFullScreen:(id)sender
{
if(isFullScreen)
{
[fullScreenContext clearDrawable];
[[self openGLContext] makeCurrentContext];
CGReleaseAllDisplays();
isFullScreen = NO;
}
else
{
CGCaptureAllDisplays();
[fullScreenContext setFullScreen];
[fullScreenContext makeCurrentContext];
isFullScreen = YES;
}
}
Does color match the depth of the current display mode?
Wow, I completely forgot I posted this...
I ended up figuring it out, and I believe the difference in color depth was part of the problem. It also had something to do with timers being goofy...
I ended up figuring it out, and I believe the difference in color depth was part of the problem. It also had something to do with timers being goofy...
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Full Screen OpenGL Crashes | Blacktiger | 13 | 6,534 |
Feb 19, 2009 02:39 PM Last Post: backslash |
|
| OpenGL full screen mode leaves garbage on screen when exiting app | Malarkey | 5 | 4,459 |
Nov 19, 2008 12:51 PM Last Post: Malarkey |
|
| Changing resolution while already in full-screen mode? | Malarkey | 1 | 2,259 |
Jun 10, 2008 07:49 PM Last Post: AnotherJake |
|
| Full Screen Switching | Blacktiger | 3 | 3,009 |
Feb 9, 2008 03:05 PM Last Post: Blacktiger |
|
| Dealing with Battery Low Warning During Full Screen | AnotherJake | 8 | 5,223 |
Feb 8, 2008 12:26 PM Last Post: OneSadCookie |
|

