summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-09-01 00:36:15 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-09-02 01:08:52 +0200
commita5346d7f3d8a7d4ecf4917a374c9ce930205ff6e (patch)
tree5ff4b428c048fda01a3bf6f3049cd665cf3c78dc /vcl
parent45f9f5f4d92323ebb78dff5437d49ed4b50804ee (diff)
switch to a NSOpenGLView implementation
Change-Id: Ifed59a9e899abc900ddf27378eec6b641be061d3
Diffstat (limited to 'vcl')
-rw-r--r--vcl/Library_vclopengl.mk20
-rw-r--r--vcl/inc/OpenGLWrapper.hxx30
-rw-r--r--vcl/osx/OpenGLWrapper.cxx31
-rw-r--r--vcl/source/opengl/OpenGLContext.cxx35
4 files changed, 86 insertions, 30 deletions
diff --git a/vcl/Library_vclopengl.mk b/vcl/Library_vclopengl.mk
index 11b46e576d71..e5fbbfe840f8 100644
--- a/vcl/Library_vclopengl.mk
+++ b/vcl/Library_vclopengl.mk
@@ -10,6 +10,7 @@
$(eval $(call gb_Library_Library,vclopengl))
$(eval $(call gb_Library_set_include,vclopengl,\
+ -I$(SRCDIR)/vcl/inc/ \
$$(INCLUDE) \
))
@@ -37,12 +38,28 @@ $(eval $(call gb_Library_use_libraries,vclopengl,\
$(gb_UWINAPI) \
))
+ifeq ($(OS),MACOSX)
+
+$(eval $(call gb_Library_add_cxxflags,vclopengl,\
+ $(gb_OBJCXXFLAGS) \
+))
+
+$(eval $(call gb_Library_add_libs,vcl,\
+ -framework IOKit \
+ -F/System/Library/PrivateFrameworks \
+ -framework CoreUI \
+ -lobjc \
+))
+
$(eval $(call gb_Library_add_exception_objects,vclopengl,\
+ vcl/osx/OpenGLWrapper \
vcl/source/opengl/OpenGLContext \
vcl/source/opengl/OpenGLHelper \
vcl/source/window/openglwin \
))
+endif
+
ifeq ($(strip $(OS)),WNT)
$(eval $(call gb_Library_use_system_win32_libs,vclopengl,\
opengl32 \
@@ -52,6 +69,9 @@ $(eval $(call gb_Library_use_system_win32_libs,vclopengl,\
else ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_use_system_darwin_frameworks,vclopengl,\
OpenGL \
+ Cocoa \
+ Carbon \
+ CoreFoundation \
))
else ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclopengl,\
diff --git a/vcl/inc/OpenGLWrapper.hxx b/vcl/inc/OpenGLWrapper.hxx
new file mode 100644
index 000000000000..6911c33630d7
--- /dev/null
+++ b/vcl/inc/OpenGLWrapper.hxx
@@ -0,0 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "AppKit/NSOpenGLView.h"
+#include "AppKit/NSOpenGL.h"
+
+class OpenGLWrapper
+{
+private:
+
+ OpenGLWrapper();
+ OpenGLWrapper(const OpenGLWrapper&);
+ OpenGLWrapper& operator=(const OpenGLWrapper&);
+
+public:
+
+ static void swapBuffers(NSOpenGLView* pView);
+ static void makeCurrent(NSOpenGLView* pView);
+ static void resetCurrent();
+
+ static void init(NSOpenGLView* pView);
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/osx/OpenGLWrapper.cxx b/vcl/osx/OpenGLWrapper.cxx
new file mode 100644
index 000000000000..dc9ad7ab7eec
--- /dev/null
+++ b/vcl/osx/OpenGLWrapper.cxx
@@ -0,0 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include "OpenGLWrapper.hxx"
+
+void OpenGLWrapper::swapBuffers(NSOpenGLView* pView)
+{
+ [[pView openGLContext] flushBuffer];
+}
+
+void OpenGLWrapper::makeCurrent(NSOpenGLView* pView)
+{
+ [[pView openGLContext] makeCurrentContext];
+}
+
+void OpenGLWrapper::resetCurrent()
+{
+ [NSOpenGLContext clearCurrentContext];
+}
+
+void OpenGLWrapper::init(NSOpenGLView* pView)
+{
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx
index e8ab18e15543..b4e7e0d70d4e 100644
--- a/vcl/source/opengl/OpenGLContext.cxx
+++ b/vcl/source/opengl/OpenGLContext.cxx
@@ -17,6 +17,10 @@
#include <vcl/bmpacc.hxx>
#include <vcl/graph.hxx>
+#include <premac.h>
+#include "OpenGLWrapper.hxx"
+#include <postmac.h>
+
using namespace com::sun::star;
GLWindow::~GLWindow()
@@ -44,8 +48,7 @@ OpenGLContext::~OpenGLContext()
ReleaseDC( m_aGLWin.hWnd, m_aGLWin.hDC );
}
#elif defined( MACOSX )
- CGLSetCurrentContext(NULL);
- CGLDestroyContext(m_aGLWin.context);
+ OpenGLWrapper::resetCurrent();
#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )
@@ -485,29 +488,6 @@ bool OpenGLContext::ImplInit()
#elif defined( MACOSX )
- CGLPixelFormatAttribute pixelFormatAttributes[] = {
-#if MACOSX_SDK_VERSION > 1060
- kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute) kCGLOGLPVersion_3_2_Core,
-#endif
- kCGLPFAColorSize, (CGLPixelFormatAttribute) 24,
- kCGLPFAAlphaSize, (CGLPixelFormatAttribute) 8,
- kCGLPFADoubleBuffer,
- kCGLPFASampleBuffers, (CGLPixelFormatAttribute) 1,
- kCGLPFASampleBuffers, (CGLPixelFormatAttribute) 4,
- (CGLPixelFormatAttribute) 0
- };
-
- if (mbRequestLegacyContext)
- pixelFormatAttributes[1] = (CGLPixelFormatAttribute) kCGLOGLPVersion_Legacy;
-
- CGLPixelFormatObj pixelFormat;
- GLint numberOfPixels;
- CGLChoosePixelFormat(pixelFormatAttributes, &pixelFormat, &numberOfPixels);
-
- CGLCreateContext(pixelFormat, 0, &m_aGLWin.context);
- CGLDestroyPixelFormat(pixelFormat);
-
- CGLSetCurrentContext(m_aGLWin.context);
#elif defined( IOS )
@@ -854,8 +834,6 @@ void OpenGLContext::makeCurrent()
SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent(): wglMakeCurrent failed: " << GetLastError());
}
#elif defined( MACOSX )
- CGLError nError = CGLSetCurrentContext(m_aGLWin.context);
- SAL_WARN_IF(nError != kCGLNoError, "vcl.opengl", "error in makeCurrent");
#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )
@@ -868,8 +846,6 @@ void OpenGLContext::resetCurrent()
#if defined( WNT )
wglMakeCurrent( m_aGLWin.hDC, 0 );
#elif defined( MACOSX )
- CGLError nError = CGLSetCurrentContext(NULL);
- SAL_WARN_IF(nError != kCGLNoError, "vcl.opengl", "error in makeCurrent");
#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )
@@ -882,7 +858,6 @@ void OpenGLContext::swapBuffers()
#if defined( WNT )
SwapBuffers(m_aGLWin.hDC);
#elif defined( MACOSX )
- CGLFlushDrawable(m_aGLWin.context);
#elif defined( IOS ) || defined( ANDROID )
// nothing
#elif defined( UNX )