diff --git a/OSBindings/Mac/Clock Signal/Atari2600Document.swift b/OSBindings/Mac/Clock Signal/Atari2600Document.swift
index 129f69c09..79f5fea35 100644
--- a/OSBindings/Mac/Clock Signal/Atari2600Document.swift
+++ b/OSBindings/Mac/Clock Signal/Atari2600Document.swift
@@ -20,6 +20,8 @@ class Atari2600Document: NSDocument, CSOpenGLViewDelegate, CSAtari2600Delegate {
super.windowControllerDidLoadNib(aController)
openGLView!.delegate = self
+
+ // bind the content aspect ratio to remain 4:3 from now on
aController.window!.contentAspectRatio = NSSize(width: 4.0, height: 3.0)
}
@@ -41,9 +43,6 @@ class Atari2600Document: NSDocument, CSOpenGLViewDelegate, CSAtari2600Delegate {
}
override func readFromData(data: NSData, ofType typeName: String) throws {
- // Insert code here to read your document from the given data of the specified type. If outError != nil, ensure that you create and set an appropriate error when returning false.
- // You can also choose to override readFromFileWrapper:ofType:error: or readFromURL:ofType:error: instead.
- // If you override either of these, you should also override -isEntireFileLoaded to return false if the contents are lazily loaded.
atari2600 = CSAtari2600()
atari2600!.setROM(data)
atari2600!.delegate = self
diff --git a/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Document.xib b/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Document.xib
index 1683915f3..0b4c8c76b 100644
--- a/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Document.xib
+++ b/OSBindings/Mac/Clock Signal/Base.lproj/Atari2600Document.xib
@@ -16,15 +16,14 @@
-
+
-
-
+
-
+
diff --git a/OSBindings/Mac/Clock Signal/OpenGLView.m b/OSBindings/Mac/Clock Signal/OpenGLView.m
index a56a22430..18f215cc3 100644
--- a/OSBindings/Mac/Clock Signal/OpenGLView.m
+++ b/OSBindings/Mac/Clock Signal/OpenGLView.m
@@ -48,15 +48,47 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
CVDisplayLinkRelease(displayLink);
}
+- (void)reshape
+{
+ [super reshape];
+
+ CGSize viewSize = [self convertSize:self.bounds.size toView:self];
+ glViewport(0, 0, viewSize.width, viewSize.height);
+}
+
- (void)drawRect:(NSRect)dirtyRect
{
[self.openGLContext makeCurrentContext];
- CGSize viewSize = [self convertSize:self.bounds.size toView:self];
- glViewport((GLint)0, (GLint)0, (GLsizei)viewSize.width, (GLsizei)viewSize.height);
[self.delegate openGLViewDrawView:self];
glSwapAPPLE();
}
+- (void) awakeFromNib
+{
+ NSOpenGLPixelFormatAttribute attributes[] =
+ {
+ NSOpenGLPFADoubleBuffer,
+ NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
+ 0
+ };
+
+ NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
+ NSOpenGLContext *context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
+
+#ifdef DEBUG
+ // When we're using a CoreProfile context, crash if we call a legacy OpenGL function
+ // This will make it much more obvious where and when such a function call is made so
+ // that we can remove such calls.
+ // Without this we'd simply get GL_INVALID_OPERATION error for calling legacy functions
+ // but it would be more difficult to see where that function was called.
+ CGLEnable([context CGLContextObj], kCGLCECrashOnRemovedFunctions);
+#endif
+
+ self.pixelFormat = pixelFormat;
+ self.openGLContext = context;
+ self.wantsBestResolutionOpenGLSurface = YES;
+}
+
@end