Kaydet (Commit) a5346d7f authored tarafından Markus Mohrhard's avatar Markus Mohrhard

switch to a NSOpenGLView implementation

Change-Id: Ifed59a9e899abc900ddf27378eec6b641be061d3
üst 45f9f5f4
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
$(eval $(call gb_Library_Library,vclopengl)) $(eval $(call gb_Library_Library,vclopengl))
$(eval $(call gb_Library_set_include,vclopengl,\ $(eval $(call gb_Library_set_include,vclopengl,\
-I$(SRCDIR)/vcl/inc/ \
$$(INCLUDE) \ $$(INCLUDE) \
)) ))
...@@ -37,12 +38,28 @@ $(eval $(call gb_Library_use_libraries,vclopengl,\ ...@@ -37,12 +38,28 @@ $(eval $(call gb_Library_use_libraries,vclopengl,\
$(gb_UWINAPI) \ $(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,\ $(eval $(call gb_Library_add_exception_objects,vclopengl,\
vcl/osx/OpenGLWrapper \
vcl/source/opengl/OpenGLContext \ vcl/source/opengl/OpenGLContext \
vcl/source/opengl/OpenGLHelper \ vcl/source/opengl/OpenGLHelper \
vcl/source/window/openglwin \ vcl/source/window/openglwin \
)) ))
endif
ifeq ($(strip $(OS)),WNT) ifeq ($(strip $(OS)),WNT)
$(eval $(call gb_Library_use_system_win32_libs,vclopengl,\ $(eval $(call gb_Library_use_system_win32_libs,vclopengl,\
opengl32 \ opengl32 \
...@@ -52,6 +69,9 @@ $(eval $(call gb_Library_use_system_win32_libs,vclopengl,\ ...@@ -52,6 +69,9 @@ $(eval $(call gb_Library_use_system_win32_libs,vclopengl,\
else ifeq ($(OS),MACOSX) else ifeq ($(OS),MACOSX)
$(eval $(call gb_Library_use_system_darwin_frameworks,vclopengl,\ $(eval $(call gb_Library_use_system_darwin_frameworks,vclopengl,\
OpenGL \ OpenGL \
Cocoa \
Carbon \
CoreFoundation \
)) ))
else ifeq ($(OS),LINUX) else ifeq ($(OS),LINUX)
$(eval $(call gb_Library_add_libs,vclopengl,\ $(eval $(call gb_Library_add_libs,vclopengl,\
......
/* -*- 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: */
/* -*- 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: */
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
#include <vcl/bmpacc.hxx> #include <vcl/bmpacc.hxx>
#include <vcl/graph.hxx> #include <vcl/graph.hxx>
#include <premac.h>
#include "OpenGLWrapper.hxx"
#include <postmac.h>
using namespace com::sun::star; using namespace com::sun::star;
GLWindow::~GLWindow() GLWindow::~GLWindow()
...@@ -44,8 +48,7 @@ OpenGLContext::~OpenGLContext() ...@@ -44,8 +48,7 @@ OpenGLContext::~OpenGLContext()
ReleaseDC( m_aGLWin.hWnd, m_aGLWin.hDC ); ReleaseDC( m_aGLWin.hWnd, m_aGLWin.hDC );
} }
#elif defined( MACOSX ) #elif defined( MACOSX )
CGLSetCurrentContext(NULL); OpenGLWrapper::resetCurrent();
CGLDestroyContext(m_aGLWin.context);
#elif defined( IOS ) || defined( ANDROID ) #elif defined( IOS ) || defined( ANDROID )
// nothing // nothing
#elif defined( UNX ) #elif defined( UNX )
...@@ -485,29 +488,6 @@ bool OpenGLContext::ImplInit() ...@@ -485,29 +488,6 @@ bool OpenGLContext::ImplInit()
#elif defined( MACOSX ) #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 ) #elif defined( IOS )
...@@ -854,8 +834,6 @@ void OpenGLContext::makeCurrent() ...@@ -854,8 +834,6 @@ void OpenGLContext::makeCurrent()
SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent(): wglMakeCurrent failed: " << GetLastError()); SAL_WARN("vcl.opengl", "OpenGLContext::makeCurrent(): wglMakeCurrent failed: " << GetLastError());
} }
#elif defined( MACOSX ) #elif defined( MACOSX )
CGLError nError = CGLSetCurrentContext(m_aGLWin.context);
SAL_WARN_IF(nError != kCGLNoError, "vcl.opengl", "error in makeCurrent");
#elif defined( IOS ) || defined( ANDROID ) #elif defined( IOS ) || defined( ANDROID )
// nothing // nothing
#elif defined( UNX ) #elif defined( UNX )
...@@ -868,8 +846,6 @@ void OpenGLContext::resetCurrent() ...@@ -868,8 +846,6 @@ void OpenGLContext::resetCurrent()
#if defined( WNT ) #if defined( WNT )
wglMakeCurrent( m_aGLWin.hDC, 0 ); wglMakeCurrent( m_aGLWin.hDC, 0 );
#elif defined( MACOSX ) #elif defined( MACOSX )
CGLError nError = CGLSetCurrentContext(NULL);
SAL_WARN_IF(nError != kCGLNoError, "vcl.opengl", "error in makeCurrent");
#elif defined( IOS ) || defined( ANDROID ) #elif defined( IOS ) || defined( ANDROID )
// nothing // nothing
#elif defined( UNX ) #elif defined( UNX )
...@@ -882,7 +858,6 @@ void OpenGLContext::swapBuffers() ...@@ -882,7 +858,6 @@ void OpenGLContext::swapBuffers()
#if defined( WNT ) #if defined( WNT )
SwapBuffers(m_aGLWin.hDC); SwapBuffers(m_aGLWin.hDC);
#elif defined( MACOSX ) #elif defined( MACOSX )
CGLFlushDrawable(m_aGLWin.context);
#elif defined( IOS ) || defined( ANDROID ) #elif defined( IOS ) || defined( ANDROID )
// nothing // nothing
#elif defined( UNX ) #elif defined( UNX )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment