Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:36

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 
0049   //! Empty constructor.
0050   Standard_EXPORT OpenGl_Window();
0051 
0052   //! Initialize the new window - prepare GL context for specified window.
0053   //! Throws exception in case of failure.
0054   Standard_EXPORT void Init (const Handle(OpenGl_GraphicDriver)& theDriver,
0055                              const Handle(Aspect_Window)&  thePlatformWindow,
0056                              const Handle(Aspect_Window)&  theSizeWindow,
0057                              Aspect_RenderingContext       theGContext,
0058                              const Handle(OpenGl_Caps)&    theCaps,
0059                              const Handle(OpenGl_Context)& theShareCtx);
0060 
0061   //! Destructor
0062   Standard_EXPORT virtual ~OpenGl_Window();
0063 
0064   //! Resizes the window.
0065   Standard_EXPORT virtual void Resize();
0066 
0067   //! Return platform window.
0068   const Handle(Aspect_Window)& PlatformWindow() { return myPlatformWindow; }
0069 
0070   //! Return window object defining dimensions.
0071   const Handle(Aspect_Window)& SizeWindow() { return mySizeWindow; }
0072 
0073   Standard_Integer Width()  const { return mySize.x(); }
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 
0087   //! Activates GL context and setup viewport.
0088   Standard_EXPORT void init();
0089 
0090 protected:
0091 
0092   Handle(OpenGl_Context) myGlContext;
0093   Standard_Boolean       myOwnGContext;    //!< set to TRUE if GL context was not created by this class
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 
0108 #endif //_OpenGl_Window_Header