Cocoaアプリケーションでフルスクリーンを実現する方法です。 サンプルプログラムはESCキーを押すと終了します。
@interface MyOpenGLView:NSOpenGLView
{
NSWindow *fullscreen_window;
}
@end
- (void)awakeFromNib
{
[[self window] makeFirstResponder:self];
unsigned int window_style;
NSRect screen_rect;
window_style = NSBorderlessWindowMask;
screen_rect = [[NSScreen mainScreen] frame];
fullscreen_window = [[NSWindow alloc] initWithContentRect:screen_rect styleMask:window_style backing:NSBackingStoreBuffered defer:NO];
if(fullscreen_window != nil)
{
[fullscreen_window setReleasedWhenClosed:YES];
[fullscreen_window setContentView:self];
[fullscreen_window makeKeyAndOrderFront:self];
[fullscreen_window setLevel:NSScreenSaverWindowLevel - 1];
[fullscreen_window makeFirstResponder:self];
}
[NSCursor hide];
}
NSOpenGLViewから派生したクラスのawakeFromNibに上記のコードを追加するだけ。 解像度はWindowsのDirectXと違い画面の解像度そのままでフルスクリーン化されるので注意が必要です。
ファーストレスポンダ指定。
画面のサイズを取得。
フルスクリーン化。
ウインドウが無くなったらメモリを開放。
表示内容は自分自身。
キーウインドウに設定。
描画優先順位をスクリーンセーバーよりも1だけ下に設定。
新しいウインドウもファーストレスポンダを引き継ぐ。
カーソルを消す。
前に戻る?