[Fuse-for-macosx-commits] SF.net SVN: fuse-for-macosx:[734] trunk/fuse/fusepb/views
Brought to you by:
fredm
From: <fr...@us...> - 2013-03-14 11:36:09
|
Revision: 734 http://sourceforge.net/p/fuse-for-macosx/code/734 Author: fredm Date: 2013-03-14 11:36:06 +0000 (Thu, 14 Mar 2013) Log Message: ----------- Fix 16x9 panoramic widescreen and non-panoramic non-4/3 widescreen (thanks, Adam Meath) Modified Paths: -------------- trunk/fuse/fusepb/views/DisplayOpenGLView.h trunk/fuse/fusepb/views/DisplayOpenGLView.m Modified: trunk/fuse/fusepb/views/DisplayOpenGLView.h =================================================================== --- trunk/fuse/fusepb/views/DisplayOpenGLView.h 2013-03-12 12:24:07 UTC (rev 733) +++ trunk/fuse/fusepb/views/DisplayOpenGLView.h 2013-03-14 11:36:06 UTC (rev 734) @@ -83,8 +83,6 @@ -(IBAction) fullscreen:(id)sender; -(IBAction) zoom:(id)sender; --(void) setViewPort:(NSRect)rect; - -(void) createTexture:(Cocoa_Texture*)newScreen; -(void) destroyTexture; -(void) blitIcon:(Texture*)iconTexture; Modified: trunk/fuse/fusepb/views/DisplayOpenGLView.m =================================================================== --- trunk/fuse/fusepb/views/DisplayOpenGLView.m 2013-03-12 12:24:07 UTC (rev 733) +++ trunk/fuse/fusepb/views/DisplayOpenGLView.m 2013-03-14 11:36:06 UTC (rev 734) @@ -47,13 +47,13 @@ #define QZ_5 0x16 #define QZ_m 0x2E -const void * +static const void * get_byte_pointer(void *bitmap) { return bitmap; } -CVReturn MyDisplayLinkCallback ( +static CVReturn MyDisplayLinkCallback ( CVDisplayLinkRef displayLink, const CVTimeStamp *inNow, const CVTimeStamp *inOutputTime, @@ -66,6 +66,13 @@ return error; } +static int +get_offset( int window_width, int window_height, + int image_width, int image_height ) { + float ratio = window_width/image_width; + return ((ratio * image_height) - window_height) / (ratio * 2); +} + @implementation DisplayOpenGLView static DisplayOpenGLView *instance = nil; @@ -102,16 +109,14 @@ backing:NSBackingStoreBuffered defer: NO]; if( fullscreenWindow != nil ) { + settings_current.full_screen = 1; [fullscreenWindow setTitle: @"Fuse"]; [fullscreenWindow setReleasedWhenClosed: YES]; [fullscreenWindow setContentView: self]; [fullscreenWindow makeKeyAndOrderFront:self ]; [fullscreenWindow setLevel: NSScreenSaverWindowLevel - 1]; [fullscreenWindow makeFirstResponder:self]; - settings_current.full_screen = 1; if( !ui_mouse_grabbed ) ui_mouse_grabbed = ui_mouse_grab( 0 ); - - [[self openGLContext] makeCurrentContext]; } } @@ -426,35 +431,59 @@ [[self openGLContext] makeCurrentContext]; + /* Clear buffer, needs to be done each frame */ + glClear( GL_COLOR_BUFFER_BIT ); + if (!screenTexInitialised) { [view_lock unlock]; return; } - /* Clear buffer, needs to be done each frame */ - glClear( GL_COLOR_BUFFER_BIT ); - int border_x_offset = 0; int border_y_offset = 0; - if( settings_current.full_screen && settings_current.full_screen_panorama ) { + if( settings_current.full_screen ) { /* how much of the top and bottom borders should be eliminated? */ NSRect rect = [self bounds]; float bounds_ratio = rect.size.width/rect.size.height; if( fabs( bounds_ratio - target_ratio ) < 0.01f ) { /* no change, we are already at 4:3 */ - } else if( bounds_ratio > target_ratio ) { - /* if wider than ideal, truncate border until we get to main section - then resize */ - float width_ratio = rect.size.width/screenTex[currentScreenTex].image_width; - border_x_offset = ((width_ratio * screenTex[currentScreenTex].image_height) - rect.size.height) / width_ratio; - border_x_offset >>= 1; + } else if( settings_current.full_screen_panorama ) { + /* Cap panorama to 16:10 as less truncates paper area TODO: properly + access border area of source images */ + if( bounds_ratio > 1.6 ) bounds_ratio = 1.6; + + if( bounds_ratio > target_ratio ) { + /* if wider than ideal, truncate border until we get to main section + then resize */ + border_x_offset = + get_offset( rect.size.width, rect.size.height, + screenTex[currentScreenTex].image_width, + screenTex[currentScreenTex].image_height); + } else { + /* if taller than ideal, truncate border until we get to main section + then resize */ + border_y_offset = + get_offset( rect.size.height, rect.size.width, + screenTex[currentScreenTex].image_height, + screenTex[currentScreenTex].image_width); + } } else { - /* if taller than ideal, truncate border until we get to main section - then resize */ - float height_ratio = rect.size.height/screenTex[currentScreenTex].image_height; - border_y_offset = ((height_ratio * screenTex[currentScreenTex].image_width) - rect.size.width) / height_ratio; - border_y_offset >>= 1; + if( bounds_ratio > target_ratio ) { + /* if wider than ideal, truncate border until we get to main section + then resize */ + border_y_offset = + get_offset( rect.size.width, rect.size.height, + screenTex[currentScreenTex].image_width, + screenTex[currentScreenTex].image_height); + } else { + /* if taller than ideal, truncate border until we get to main section + then resize */ + border_x_offset = + get_offset( rect.size.height, rect.size.width, + screenTex[currentScreenTex].image_height, + screenTex[currentScreenTex].image_width); + } } } @@ -497,26 +526,6 @@ [view_lock unlock]; } --(void) setViewPort:(NSRect)rect -{ - float bounds_ratio = rect.size.width/rect.size.height; - - if( settings_current.full_screen_panorama || - 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 ) ); - } -} - /* scrolled, moved or resized */ -(void) reshape { @@ -530,7 +539,7 @@ rect = [self bounds]; - [self setViewPort:rect]; + glViewport( 0, 0, (int) rect.size.width, (int) rect.size.height ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |