mirror of https://github.com/snes9xgit/snes9x.git
Mac: fix rendering and placement of window
This commit is contained in:
parent
e9edecd94f
commit
0d698f666f
|
@ -9,17 +9,47 @@
|
|||
#import <snes9x_framework/snes9x_framework.h>
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
@property (strong) S9xEngine *s9xEngine;
|
||||
@property (nonatomic, strong) S9xEngine *s9xEngine;
|
||||
@property (nonatomic, strong) NSWindow *window;
|
||||
@end
|
||||
|
||||
static NSWindowFrameAutosaveName const kMainWindowIdentifier = @"s9xMainWindow";
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
|
||||
self.s9xEngine = [S9xEngine new];
|
||||
[self importRecentItems];
|
||||
}
|
||||
|
||||
NSWindow *window = [[NSWindow alloc] initWithContentRect:s9xView.frame styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
|
||||
|
||||
window.contentView.wantsLayer = YES;
|
||||
window.contentView.layer.backgroundColor = NSColor.blackColor.CGColor;
|
||||
|
||||
window.title = @"Snes9x";
|
||||
window.restorationClass = [self class];
|
||||
window.frameAutosaveName = kMainWindowIdentifier;
|
||||
window.releasedWhenClosed = NO;
|
||||
|
||||
[window.contentView addSubview:s9xView];
|
||||
[s9xView.topAnchor constraintEqualToAnchor:window.contentView.topAnchor].active = YES;
|
||||
[s9xView.bottomAnchor constraintEqualToAnchor:window.contentView.bottomAnchor].active = YES;
|
||||
[s9xView.centerXAnchor constraintEqualToAnchor:window.contentView.centerXAnchor].active = YES;
|
||||
[s9xView.leftAnchor constraintGreaterThanOrEqualToAnchor:window.contentView.leftAnchor].active = YES;
|
||||
[s9xView.rightAnchor constraintLessThanOrEqualToAnchor:window.contentView.rightAnchor].active = YES;
|
||||
|
||||
if ( ![window setFrameUsingName:kMainWindowIdentifier] )
|
||||
{
|
||||
[window center];
|
||||
}
|
||||
|
||||
[NSNotificationCenter.defaultCenter addObserverForName:NSWindowWillCloseNotification object:window queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *notification)
|
||||
{
|
||||
[self.s9xEngine stop];
|
||||
}];
|
||||
|
||||
self.window = window;
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(NSNotification *)aNotification {
|
||||
// Insert code here to tear down your application
|
||||
|
@ -64,6 +94,8 @@
|
|||
{
|
||||
if ([self.s9xEngine loadROM:url])
|
||||
{
|
||||
|
||||
[self.window makeKeyAndOrderFront:self];
|
||||
[NSDocumentController.sharedDocumentController noteNewRecentDocumentURL:url];
|
||||
return YES;
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ typedef struct
|
|||
int glStorageHint;
|
||||
} ExtraOption;
|
||||
|
||||
#define kMacWindowHeight (SNES_HEIGHT_EXTENDED << 1)
|
||||
#define kMacWindowHeight (SNES_HEIGHT_EXTENDED)
|
||||
#define MAC_MAX_PLAYERS 8
|
||||
#define MAC_MAX_CHEATS 150
|
||||
#define MAC_NUM_KEYCODES 255
|
||||
|
@ -181,6 +181,7 @@ uint64 GetMicroseconds(void);
|
|||
@interface S9xEngine : NSObject
|
||||
|
||||
- (void)start;
|
||||
- (void)stop;
|
||||
|
||||
- (BOOL)loadROM:(NSURL *)fileURL;
|
||||
|
||||
|
|
|
@ -3067,6 +3067,7 @@ void QuitWithFatalError ( NSString *message)
|
|||
if ( !NSEqualRects(frame, self.frame) )
|
||||
{
|
||||
windowResizeCount = 2;
|
||||
[super setFrame:frame];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3090,15 +3091,13 @@ void QuitWithFatalError ( NSString *message)
|
|||
{
|
||||
Initialize();
|
||||
|
||||
CGRect frame = NSMakeRect(0, 0, SNES_WIDTH * 2.0, kMacWindowHeight);
|
||||
CGRect frame = NSMakeRect(0, 0, SNES_WIDTH * 2, SNES_HEIGHT * 2);
|
||||
s9xView = [[S9xView alloc] initWithFrame:frame pixelFormat:nil];
|
||||
s9xView.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
s9xView.autoresizingMask = NSViewWidthSizable|NSViewHeightSizable;
|
||||
NSWindow *window = [[NSWindow alloc] initWithContentRect:frame styleMask:NSWindowStyleMaskTitled|NSWindowStyleMaskClosable|NSWindowStyleMaskMiniaturizable|NSWindowStyleMaskResizable backing:NSBackingStoreBuffered defer:NO];
|
||||
window.contentView = s9xView;
|
||||
window.title = @"Snes9x";
|
||||
|
||||
[window center];
|
||||
[window makeKeyAndOrderFront:self];
|
||||
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:s9xView attribute:NSLayoutAttributeWidth multiplier:(CGFloat)SNES_HEIGHT/(CGFloat)SNES_WIDTH constant:0.0]];
|
||||
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_WIDTH]];
|
||||
[s9xView addConstraint:[NSLayoutConstraint constraintWithItem:s9xView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationGreaterThanOrEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:SNES_HEIGHT]];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -3109,9 +3108,8 @@ void QuitWithFatalError ( NSString *message)
|
|||
Deinitialize();
|
||||
}
|
||||
|
||||
- (void) start
|
||||
- (void)start
|
||||
{
|
||||
NSLog(@"Starting");
|
||||
if (!finished)
|
||||
{
|
||||
#ifdef DEBUGGER
|
||||
|
@ -3167,6 +3165,11 @@ void QuitWithFatalError ( NSString *message)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)stop
|
||||
{
|
||||
pauseEmulation = true;
|
||||
}
|
||||
|
||||
- (BOOL)loadROM:(NSURL *)fileURL
|
||||
{
|
||||
if ( SNES9X_OpenCart(fileURL) )
|
||||
|
|
|
@ -997,24 +997,6 @@ static void S9xPutImageOpenGL (int width, int height)
|
|||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
if ( fullscreen )
|
||||
{
|
||||
if (glstretch)
|
||||
{
|
||||
float fpw = (float) glScreenH / vh * 512.0f;
|
||||
int pw = (int) (fpw + ((float) glScreenW - fpw) * (float) macAspectRatio / 10000.0);
|
||||
|
||||
glViewport((glScreenW - pw) >> 1, 0, pw, glScreenH);
|
||||
}
|
||||
else
|
||||
glViewport((glScreenW - 512) >> 1, (glScreenH - vh) >> 1, 512, vh);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (windowExtend)
|
||||
glViewport(0, ((glScreenH - vh) >> 1), glScreenW, vh);
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
|
||||
|
||||
if (!ciFilterEnable)
|
||||
|
@ -1049,20 +1031,20 @@ static void S9xPutImageOpenGL (int width, int height)
|
|||
{
|
||||
glTexSubImage2D(OpenGL.target, 0, 0, 0, OpenGL.texW[textureNum], OpenGL.texH[textureNum], OpenGL.format, OpenGL.type, GFX.Screen);
|
||||
|
||||
if (!screencurvature)
|
||||
if (!screencurvature && OpenGL.texW[textureNum] > 0)
|
||||
{
|
||||
glBegin(GL_QUADS);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][6]);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][4]);
|
||||
glVertex2f( 1.0f, -1.0f);
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][2]);
|
||||
glVertex2f( 1.0f, 1.0f);
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][0]);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][6]);
|
||||
glVertex2f(-1.0f, -1.0f);
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][4]);
|
||||
glVertex2f( 1.0f, -1.0f);
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][2]);
|
||||
glVertex2f( 1.0f, 1.0f);
|
||||
glTexCoord2fv(&OpenGL.vertex[textureNum][0]);
|
||||
glVertex2f(-1.0f, 1.0f);
|
||||
|
||||
glEnd();
|
||||
glEnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
307C863022D29E29001B879E /* mac-render.mm in Sources */ = {isa = PBXBuildFile; fileRef = EA942A50059B0F9000D7D022 /* mac-render.mm */; };
|
||||
307C863222D29E29001B879E /* mac-snes9x.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB68604AC7FCE00A80003 /* mac-snes9x.mm */; };
|
||||
307C863322D29E29001B879E /* mac-stringtools.mm in Sources */ = {isa = PBXBuildFile; fileRef = EAECB68804AC7FCE00A80003 /* mac-stringtools.mm */; };
|
||||
308092F72320B041006A2860 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 308092F62320B041006A2860 /* CoreGraphics.framework */; };
|
||||
308092F92320B06F006A2860 /* Quartz.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 308092F82320B06F006A2860 /* Quartz.framework */; };
|
||||
30D15CF322CE6B5A005BC352 /* snes9x_framework.h in Headers */ = {isa = PBXBuildFile; fileRef = 30D15CF122CE6B5A005BC352 /* snes9x_framework.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
30D15CFC22CE6B74005BC352 /* sha256.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90A20DDB18D00C038E9 /* sha256.cpp */; };
|
||||
30D15CFE22CE6B74005BC352 /* bml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 85FEF90620DDB15B00C038E9 /* bml.cpp */; };
|
||||
|
@ -236,6 +238,8 @@
|
|||
307C861022D27C53001B879E /* tileimpl-h2x1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "tileimpl-h2x1.cpp"; sourceTree = "<group>"; usesTabs = 1; };
|
||||
307C861A22D29D6D001B879E /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
|
||||
307C861C22D29DD2001B879E /* GLUT.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GLUT.framework; path = System/Library/Frameworks/GLUT.framework; sourceTree = SDKROOT; };
|
||||
308092F62320B041006A2860 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
|
||||
308092F82320B06F006A2860 /* Quartz.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Quartz.framework; path = System/Library/Frameworks/Quartz.framework; sourceTree = SDKROOT; };
|
||||
30AD1D1E22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
30AD1D1F22FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
30AD1D2022FBB2EA000EE989 /* en */ = {isa = PBXFileReference; lastKnownFileType = folder; name = en; path = "en.lproj/Snes9x Help"; sourceTree = "<group>"; };
|
||||
|
@ -487,6 +491,8 @@
|
|||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
308092F92320B06F006A2860 /* Quartz.framework in Frameworks */,
|
||||
308092F72320B041006A2860 /* CoreGraphics.framework in Frameworks */,
|
||||
302EECA522DAD1B9006D1502 /* CoreAudio.framework in Frameworks */,
|
||||
302EECA322DAD0C5006D1502 /* CoreImage.framework in Frameworks */,
|
||||
302EECA122DAD0B9006D1502 /* OpenGL.framework in Frameworks */,
|
||||
|
@ -555,6 +561,8 @@
|
|||
3045A1EB22D03C420092B97D /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
308092F82320B06F006A2860 /* Quartz.framework */,
|
||||
308092F62320B041006A2860 /* CoreGraphics.framework */,
|
||||
302EECA422DAD1B9006D1502 /* CoreAudio.framework */,
|
||||
302EECA222DAD0C5006D1502 /* CoreImage.framework */,
|
||||
302EECA022DAD0B9006D1502 /* OpenGL.framework */,
|
||||
|
|
Loading…
Reference in New Issue