Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-15 08:26:01

0001 // Created on: 2011-09-20
0002 // Created by: Sergey ZERCHANINOV
0003 // Copyright (c) 2011-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef OpenGl_Window_HeaderFile
0017 #define OpenGl_Window_HeaderFile
0018 
0019 #include <Aspect_RenderingContext.hxx>
0020 #include <Aspect_Window.hxx>
0021 #include <OpenGl_GlCore11.hxx>
0022 #include <OpenGl_Caps.hxx>
0023 #include <Standard_Transient.hxx>
0024 
0025 #if defined(__APPLE__)
0026   #import <TargetConditionals.h>
0027 #endif
0028 
0029 #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0030   #ifdef __OBJC__
0031 @class UIView;
0032   #else
0033 struct UIView;
0034   #endif
0035 #endif
0036 
0037 class OpenGl_Context;
0038 class OpenGl_GraphicDriver;
0039 
0040 DEFINE_STANDARD_HANDLE(OpenGl_Window, Standard_Transient)
0041 
0042 //! This class represents low-level wrapper over window with GL context.
0043 //! The window itself should be provided to constructor.
0044 class OpenGl_Window : public Standard_Transient
0045 {
0046   DEFINE_STANDARD_RTTIEXT(OpenGl_Window, Standard_Transient)
0047 public:
0048   //! Empty constructor.
0049   Standard_EXPORT OpenGl_Window();
0050 
0051   //! Initialize the new window - prepare GL context for specified window.
0052   //! Throws exception in case of failure.
0053   Standard_EXPORT void Init(const Handle(OpenGl_GraphicDriver)& theDriver,
0054                             const Handle(Aspect_Window)&        thePlatformWindow,
0055                             const Handle(Aspect_Window)&        theSizeWindow,
0056                             Aspect_RenderingContext             theGContext,
0057                             const Handle(OpenGl_Caps)&          theCaps,
0058                             const Handle(OpenGl_Context)&       theShareCtx);
0059 
0060   //! Destructor
0061   Standard_EXPORT virtual ~OpenGl_Window();
0062 
0063   //! Resizes the window.
0064   Standard_EXPORT virtual void Resize();
0065 
0066   //! Return platform window.
0067   const Handle(Aspect_Window)& PlatformWindow() { return myPlatformWindow; }
0068 
0069   //! Return window object defining dimensions.
0070   const Handle(Aspect_Window)& SizeWindow() { return mySizeWindow; }
0071 
0072   Standard_Integer Width() const { return mySize.x(); }
0073 
0074   Standard_Integer Height() const { return mySize.y(); }
0075 
0076   //! Return OpenGL context.
0077   const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; }
0078 
0079   //! Makes GL context for this window active in current thread
0080   Standard_EXPORT virtual Standard_Boolean Activate();
0081 
0082   //! Sets swap interval for this window according to the context's settings.
0083   Standard_EXPORT void SetSwapInterval(Standard_Boolean theToForceNoSync);
0084 
0085 protected:
0086   //! Activates GL context and setup viewport.
0087   Standard_EXPORT void init();
0088 
0089 protected:
0090   Handle(OpenGl_Context) myGlContext;
0091   // clang-format off
0092   Standard_Boolean       myOwnGContext;    //!< set to TRUE if GL context was not created by this class
0093   // clang-format on
0094   Handle(Aspect_Window) myPlatformWindow; //!< software platform window wrapper
0095   Handle(Aspect_Window) mySizeWindow;     //!< window object defining dimensions
0096 #if defined(__APPLE__)
0097   #if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
0098   UIView* myUIView;
0099   #endif
0100   Graphic3d_Vec2i mySizePt; //!< window width x height in logical units
0101 #endif
0102   Graphic3d_Vec2i mySize; //!< window width x height in pixels
0103 
0104   Standard_Integer mySwapInterval; //!< last assigned swap interval (VSync) for this window
0105 };
0106 
0107 #endif //_OpenGl_Window_Header