[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx: [273] branches/fusegl/fuse
Brought to you by:
fredm
From: <fr...@us...> - 2007-01-01 07:13:02
|
Revision: 273 http://svn.sourceforge.net/fuse-for-macosx/?rev=273&view=rev Author: fredm Date: 2006-12-31 23:13:02 -0800 (Sun, 31 Dec 2006) Log Message: ----------- Restore fullscreen support. Modified Paths: -------------- branches/fusegl/fuse/TODO branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/keyedobjects.nib branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m Modified: branches/fusegl/fuse/TODO =================================================================== --- branches/fusegl/fuse/TODO 2007-01-01 06:54:20 UTC (rev 272) +++ branches/fusegl/fuse/TODO 2007-01-01 07:13:02 UTC (rev 273) @@ -10,12 +10,15 @@ X Fix menus, preferences etc. X Add native mouse processing (removes SDL mouse input dependency from Fuse) X Make it possible to constrain Speccy image to "correct" aspect ratio -* Add native joystick processing (removes SDL joystick input dependency from - Fuse) -* Restore fullscreen support +X Restore fullscreen support * Fix scalers +* Add support for bilinear etc. OpenGL filters +* Add option to snap window size to 1x, 2x, 3x * Use sheets rather than modal dialogs * Run emulation in seperate thread to avoid sound glitches when menus are selected +* Restore activity icons +* Add native joystick processing (removes SDL joystick input dependency from + Fuse) $Id: TODO,v 1.4 2004/03/02 13:38:08 pak21 Exp $ Modified: branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib =================================================================== --- branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib 2007-01-01 06:54:20 UTC (rev 272) +++ branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/classes.nib 2007-01-01 07:13:02 UTC (rev 273) @@ -1,6 +1,11 @@ { IBClasses = ( - {CLASS = DisplayOpenGLView; LANGUAGE = ObjC; SUPERCLASS = NSOpenGLView; }, + { + ACTIONS = {fullscreen = id; }; + CLASS = DisplayOpenGLView; + LANGUAGE = ObjC; + SUPERCLASS = NSOpenGLView; + }, {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, { ACTIONS = { Modified: branches/fusegl/fuse/fusepb/nibs/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2007-01-01 06:54:20 UTC (rev 272) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.h 2007-01-01 07:13:02 UTC (rev 273) @@ -53,10 +53,19 @@ input_key unicode_keysym; CFAbsoluteTime time; + + NSWindow *fullscreenWindow; + NSWindow *windowedWindow; + + float target_ratio; } +(DisplayOpenGLView *) instance; +(void) initialize; +-(IBAction) fullscreen:(id)sender; + +-(void) setViewPort:(NSRect)rect; + -(void) createTexture:(Cocoa_Texture*)newScreen; -(void) destroyTexture; Modified: branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2007-01-01 06:54:20 UTC (rev 272) +++ branches/fusegl/fuse/fusepb/views/DisplayOpenGLView.m 2007-01-01 07:13:02 UTC (rev 273) @@ -37,11 +37,9 @@ extern keysyms_map_t unicode_keysyms_map[]; -#include <CoreAudio/AudioHardware.h> #include "sound/sfifo.h" extern sfifo_t sound_fifo; -extern AudioStreamBasicDescription deviceFormat; @implementation DisplayOpenGLView @@ -90,12 +88,43 @@ } +-(IBAction) fullscreen:(id)sender +{ + if( settings_current.full_screen == 1 ) { // we need to go back to non-full screen + [fullscreenWindow close]; + [windowedWindow setContentView: self]; + [windowedWindow makeKeyAndOrderFront: self]; + [windowedWindow makeFirstResponder: self]; + settings_current.full_screen = 0; + } else { // settings_current.full_screen == 0 + unsigned int windowStyle; + NSRect contentRect; + + windowedWindow = [self window]; + windowStyle = NSBorderlessWindowMask; + contentRect = [[NSScreen mainScreen] frame]; + fullscreenWindow = [[NSWindow alloc] initWithContentRect:contentRect + styleMask: windowStyle + backing:NSBackingStoreBuffered + defer: NO]; + if( fullscreenWindow != nil ) { + [fullscreenWindow setTitle: @"Fuse"]; + [fullscreenWindow setReleasedWhenClosed: YES]; + [fullscreenWindow setContentView: self]; + [fullscreenWindow makeKeyAndOrderFront:self ]; + [fullscreenWindow setLevel: NSScreenSaverWindowLevel - 1]; + [fullscreenWindow makeFirstResponder:self]; + settings_current.full_screen = 1; + } + } +} + -(id) initWithFrame:(NSRect)frameRect { /* Init pixel format attribs */ NSOpenGLPixelFormatAttribute attrs[] = { + NSOpenGLPFANoRecovery, NSOpenGLPFAAccelerated, - NSOpenGLPFANoRecovery, NSOpenGLPFADoubleBuffer, 0 }; @@ -115,6 +144,8 @@ instance = self; } + [pixFmt release]; + [[self openGLContext] makeCurrentContext]; timer = nil; @@ -122,8 +153,8 @@ /* Setup some basic OpenGL stuff */ glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - glClearColor(1.0f, 1.0f, 1.0f, 1.0f); - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + glColor4f(0.0f, 0.0f, 0.0f, 0.0f); screenTexInitialised = NO; @@ -135,6 +166,8 @@ cocoakeyboard_symbol_shift_pressed = 0; unicode_keysym = INPUT_KEY_NONE; + target_ratio = 4.0f/3.0f; + return self; } @@ -169,6 +202,8 @@ [[self openGLContext] makeCurrentContext]; + glClear(GL_COLOR_BUFFER_BIT); + /* Bind, update and draw new image */ glBindTexture(GL_TEXTURE_RECTANGLE_EXT, 1); @@ -199,6 +234,22 @@ [[self openGLContext] flushBuffer]; } +/* want to keep image in the original aspect ratio in the face of window resizing */ +-(void) setViewPort:(NSRect)rect +{ + float bounds_ratio = rect.size.width/rect.size.height; + + if( fabs(bounds_ratio - target_ratio) < 0.01f ) { + glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); + } else if( bounds_ratio > target_ratio ) { + int x_offset = (rect.size.width - (rect.size.height * target_ratio))/2.0f; + glViewport(x_offset, 0, (int)(rect.size.height*target_ratio), (int) rect.size.height); + } else { + int y_offset = (rect.size.height - (rect.size.width / target_ratio))/2.0f; + glViewport(0, y_offset, (int) rect.size.width, (int) (rect.size.width/target_ratio)); + } +} + /* moved or resized */ -(void) update { @@ -211,11 +262,13 @@ rect = [self bounds]; - glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); + [self setViewPort:rect]; glMatrixMode(GL_PROJECTION); glLoadIdentity(); + gluOrtho2D(0, rect.size.width, 0, rect.size.height); + glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -234,7 +287,7 @@ rect = [self bounds]; - glViewport(0, 0, (int) rect.size.width, (int) rect.size.height); + [self setViewPort:rect]; glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -470,6 +523,17 @@ -(void) keyDown:(NSEvent *)theEvent { + if( settings_current.full_screen ) { + unichar c = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; + switch (c) { + // [Esc] exits fullScreen mode. + case 27: + [self fullscreen:nil]; + return; + break; + } + } + [self keyChange:theEvent type:INPUT_EVENT_KEYPRESS]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |