1 // Created on: 2012-11-12
2 // Created by: Kirill GAVRILOV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
18 #define GL_GLEXT_LEGACY // To prevent inclusion of system glext.h on Mac OS X 10.6.8
20 #import <Cocoa/Cocoa.h>
22 #include <OpenGl_GlCore11.hxx>
23 #include <OpenGl_Context.hxx>
25 #include <Standard_ProgramError.hxx>
27 // =======================================================================
28 // function : IsCurrent
30 // =======================================================================
31 Standard_Boolean OpenGl_Context::IsCurrent() const
33 return myGContext != NULL
34 && [NSOpenGLContext currentContext] == (NSOpenGLContext* )myGContext;
37 // =======================================================================
38 // function : MakeCurrent
40 // =======================================================================
41 Standard_Boolean OpenGl_Context::MakeCurrent()
43 if (myGContext == NULL)
45 Standard_ProgramError_Raise_if (myIsInitialized, "OpenGl_Context::Init() should be called before!");
46 return Standard_False;
49 [(NSOpenGLContext* )myGContext makeCurrentContext];
53 // =======================================================================
54 // function : SwapBuffers
56 // =======================================================================
57 void OpenGl_Context::SwapBuffers()
59 if (myGContext != NULL)
62 [(NSOpenGLContext* )myGContext flushBuffer];
66 // =======================================================================
69 // =======================================================================
70 Standard_Boolean OpenGl_Context::Init()
77 myGContext = [NSOpenGLContext currentContext];
78 if (myGContext == NULL)
80 return Standard_False;
84 myIsInitialized = Standard_True;