summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp
diff options
context:
space:
mode:
authorcomex <comexk@gmail.com>2014-11-02 18:08:55 -0500
committercomex <comexk@gmail.com>2014-11-02 18:08:55 -0500
commit890b788633c3e8f959cf71b3e74a0815a2ec1a2e (patch)
treea28fa6b83a326a3feb426f66306e05cbc95efefe /Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp
parent1c41acaddd4a92e89ebe0305d21a00769fe46843 (diff)
parent3d63d22e539fb6aaf4bad3c4d9e51f30d122fd56 (diff)
Merge pull request #1467 from waddlesplash/dolphin-qt
DolphinQt: Games now boot!
Diffstat (limited to 'Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp109
1 files changed, 109 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp b/Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp
new file mode 100644
index 0000000000..4ab1cdd565
--- /dev/null
+++ b/Source/Core/VideoBackends/OGL/GLInterface/AGL.cpp
@@ -0,0 +1,109 @@
+// Copyright 2014 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "VideoBackends/OGL/GLInterface/AGL.h"
+
+#include "VideoCommon/RenderBase.h"
+#include "VideoCommon/VertexShaderManager.h"
+#include "VideoCommon/VideoConfig.h"
+
+void cInterfaceAGL::Swap()
+{
+ [cocoaCtx flushBuffer];
+}
+
+// Create rendering window.
+// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
+bool cInterfaceAGL::Create(void *window_handle)
+{
+ cocoaWin = reinterpret_cast<NSView*>(window_handle);
+ NSSize size = [cocoaWin frame].size;
+
+ // Enable high-resolution display support.
+ [cocoaWin setWantsBestResolutionOpenGLSurface:YES];
+
+ NSWindow *window = [cocoaWin window];
+
+ float scale = [window backingScaleFactor];
+ size.width *= scale;
+ size.height *= scale;
+
+ // Control window size and picture scaling
+ s_backbuffer_width = size.width;
+ s_backbuffer_height = size.height;
+
+ NSOpenGLPixelFormatAttribute attr[] = { NSOpenGLPFADoubleBuffer, NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core, NSOpenGLPFAAccelerated, 0 };
+ NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc]
+ initWithAttributes: attr];
+ if (fmt == nil)
+ {
+ ERROR_LOG(VIDEO, "failed to create pixel format");
+ return false;
+ }
+
+ cocoaCtx = [[NSOpenGLContext alloc] initWithFormat: fmt shareContext: nil];
+ [fmt release];
+ if (cocoaCtx == nil)
+ {
+ ERROR_LOG(VIDEO, "failed to create context");
+ return false;
+ }
+
+ if (cocoaWin == nil)
+ {
+ ERROR_LOG(VIDEO, "failed to create window");
+ return false;
+ }
+
+ [window makeFirstResponder:cocoaWin];
+ [cocoaCtx setView: cocoaWin];
+ [window makeKeyAndOrderFront: nil];
+
+ return true;
+}
+
+bool cInterfaceAGL::MakeCurrent()
+{
+ [cocoaCtx makeCurrentContext];
+ return true;
+}
+
+bool cInterfaceAGL::ClearCurrent()
+{
+ [NSOpenGLContext clearCurrentContext];
+ return true;
+}
+
+// Close backend
+void cInterfaceAGL::Shutdown()
+{
+ [cocoaCtx clearDrawable];
+ [cocoaCtx release];
+ cocoaCtx = nil;
+}
+
+void cInterfaceAGL::Update()
+{
+ NSWindow *window = [cocoaWin window];
+ NSSize size = [cocoaWin frame].size;
+
+ float scale = [window backingScaleFactor];
+ size.width *= scale;
+ size.height *= scale;
+
+ if (s_backbuffer_width == size.width &&
+ s_backbuffer_height == size.height)
+ return;
+
+ s_backbuffer_width = size.width;
+ s_backbuffer_height = size.height;
+
+ [cocoaCtx update];
+}
+
+void cInterfaceAGL::SwapInterval(int interval)
+{
+ [cocoaCtx setValues:(GLint *)&interval forParameter:NSOpenGLCPSwapInterval];
+}
+