0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / OpenGl / OpenGl_Window.hxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
5bd54bef 16#ifndef OpenGl_Window_HeaderFile
17#define OpenGl_Window_HeaderFile
2166f0fa 18
c357e426 19#include <Aspect_RenderingContext.hxx>
20#include <Aspect_Window.hxx>
3695b8c2 21#include <OpenGl_GlCore11.hxx>
58655684 22#include <OpenGl_Caps.hxx>
25e59720 23#include <Standard_Transient.hxx>
2166f0fa 24
a2e4f780 25#if defined(__APPLE__)
26 #import <TargetConditionals.h>
27#endif
28
29#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
30 #ifdef __OBJC__
31 @class UIView;
32 #else
33 struct UIView;
34 #endif
35#endif
36
c04c30b3 37class OpenGl_Context;
38class OpenGl_GraphicDriver;
39
25e59720 40DEFINE_STANDARD_HANDLE(OpenGl_Window,Standard_Transient)
c04c30b3 41
2166f0fa
SK
42//! This class represents low-level wrapper over window with GL context.
43//! The window itself should be provided to constructor.
25e59720 44class OpenGl_Window : public Standard_Transient
2166f0fa 45{
879768fb 46 DEFINE_STANDARD_RTTIEXT(OpenGl_Window, Standard_Transient)
2166f0fa
SK
47public:
48
879768fb 49 //! Empty constructor.
50 Standard_EXPORT OpenGl_Window();
51
52 //! Initialize the new window - prepare GL context for specified window.
53 //! Throws exception in case of failure.
54 Standard_EXPORT void Init (const Handle(OpenGl_GraphicDriver)& theDriver,
55 const Handle(Aspect_Window)& thePlatformWindow,
56 const Handle(Aspect_Window)& theSizeWindow,
57 Aspect_RenderingContext theGContext,
58 const Handle(OpenGl_Caps)& theCaps,
59 const Handle(OpenGl_Context)& theShareCtx);
2166f0fa
SK
60
61 //! Destructor
62e1beed 62 Standard_EXPORT virtual ~OpenGl_Window();
2166f0fa
SK
63
64 //! Resizes the window.
c357e426 65 Standard_EXPORT virtual void Resize();
2166f0fa 66
879768fb 67 //! Return platform window.
68 const Handle(Aspect_Window)& PlatformWindow() { return myPlatformWindow; }
2166f0fa 69
879768fb 70 //! Return window object defining dimensions.
71 const Handle(Aspect_Window)& SizeWindow() { return mySizeWindow; }
2166f0fa 72
879768fb 73 Standard_Integer Width() const { return mySize.x(); }
74 Standard_Integer Height() const { return mySize.y(); }
2166f0fa 75
879768fb 76 //! Return OpenGL context.
77 const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; }
2166f0fa
SK
78
79 //! Makes GL context for this window active in current thread
62e1beed 80 Standard_EXPORT virtual Standard_Boolean Activate();
2166f0fa 81
c357e426 82 //! Sets swap interval for this window according to the context's settings.
b40cdc2b 83 Standard_EXPORT void SetSwapInterval (Standard_Boolean theToForceNoSync);
2166f0fa 84
879768fb 85protected:
86
87 //! Activates GL context and setup viewport.
88 Standard_EXPORT void init();
89
2166f0fa
SK
90protected:
91
2166f0fa 92 Handle(OpenGl_Context) myGlContext;
879768fb 93 Standard_Boolean myOwnGContext; //!< set to TRUE if GL context was not created by this class
c357e426 94 Handle(Aspect_Window) myPlatformWindow; //!< software platform window wrapper
879768fb 95 Handle(Aspect_Window) mySizeWindow; //!< window object defining dimensions
a2e4f780 96#if defined(__APPLE__)
97#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
98 UIView* myUIView;
99#endif
879768fb 100 Graphic3d_Vec2i mySizePt; //!< window width x height in logical units
a2e4f780 101#endif
879768fb 102 Graphic3d_Vec2i mySize; //!< window width x height in pixels
2166f0fa 103
f978241f 104 Standard_Integer mySwapInterval;//!< last assigned swap interval (VSync) for this window
105
2166f0fa
SK
106};
107
108#endif //_OpenGl_Window_Header