Commit | Line | Data |
---|---|---|
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 | |
2166f0fa SK |
16 | #ifndef _OpenGl_Window_Header |
17 | #define _OpenGl_Window_Header | |
18 | ||
3695b8c2 | 19 | #include <OpenGl_GlCore11.hxx> |
2166f0fa | 20 | #include <InterfaceGraphic_Aspect.hxx> |
58655684 | 21 | #include <OpenGl_Caps.hxx> |
2166f0fa | 22 | |
2166f0fa | 23 | #include <Handle_OpenGl_Context.hxx> |
3695b8c2 | 24 | #include <Handle_OpenGl_Window.hxx> |
73192b37 | 25 | #include <Aspect_DisplayConnection.hxx> |
3695b8c2 | 26 | |
27 | #include <MMgt_TShared.hxx> | |
2166f0fa SK |
28 | |
29 | //! This class represents low-level wrapper over window with GL context. | |
30 | //! The window itself should be provided to constructor. | |
31 | class OpenGl_Window : public MMgt_TShared | |
32 | { | |
33 | public: | |
34 | ||
35 | //! Main constructor - prepare GL context for specified window. | |
73192b37 | 36 | OpenGl_Window (const Handle(Aspect_DisplayConnection)& theDisplayConnection, |
2166f0fa | 37 | const CALL_DEF_WINDOW& theCWindow, |
5e27df78 | 38 | Aspect_RenderingContext theGContext, |
58655684 | 39 | const Handle(OpenGl_Caps)& theCaps, |
5e27df78 | 40 | const Handle(OpenGl_Context)& theShareCtx); |
2166f0fa SK |
41 | |
42 | //! Destructor | |
43 | virtual ~OpenGl_Window(); | |
44 | ||
45 | //! Resizes the window. | |
46 | void Resize (const CALL_DEF_WINDOW& theCWindow); | |
47 | ||
48 | //! Reads depth component for current scene into specified buffer. | |
49 | void ReadDepths (const Standard_Integer theX, const Standard_Integer theY, | |
50 | const Standard_Integer theWidth, const Standard_Integer theHeight, | |
51 | float* theDepths); | |
52 | ||
53 | void SetBackgroundColor (const Standard_ShortReal theR, | |
54 | const Standard_ShortReal theG, | |
55 | const Standard_ShortReal theB); | |
56 | ||
2166f0fa SK |
57 | Standard_Integer Width() const { return myWidth; } |
58 | Standard_Integer Height() const { return myHeight; } | |
59 | const TEL_COLOUR& BackgroundColor() const { return myBgColor; } | |
2166f0fa SK |
60 | |
61 | const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; } | |
62 | ||
2166f0fa SK |
63 | protected: |
64 | ||
65 | //! Activates GL context and setup viewport. | |
66 | void Init(); | |
67 | ||
68 | //! Makes GL context for this window active in current thread | |
69 | virtual Standard_Boolean Activate(); | |
70 | ||
71 | void EnableFeatures() const; | |
72 | void DisableFeatures() const; | |
73 | ||
74 | //! Draw directly to the FRONT buffer. Can cause artifacts on the screen. | |
75 | void MakeFrontBufCurrent() const; | |
76 | ||
77 | //! Draw to BACK buffer. Normal and default state. | |
78 | void MakeBackBufCurrent() const; | |
79 | ||
2166f0fa SK |
80 | protected: |
81 | ||
2166f0fa | 82 | Handle(OpenGl_Context) myGlContext; |
2166f0fa | 83 | Standard_Boolean myOwnGContext; //!< set to TRUE if GL context was not created by this class |
73192b37 | 84 | Standard_Integer myWidth; //!< window width |
85 | Standard_Integer myHeight; //!< window height | |
86 | TEL_COLOUR myBgColor; //!< background color | |
2166f0fa SK |
87 | |
88 | public: | |
89 | ||
90 | DEFINE_STANDARD_RTTI(OpenGl_Window) // Type definition | |
1c35b92f | 91 | DEFINE_STANDARD_ALLOC |
2166f0fa SK |
92 | |
93 | }; | |
94 | ||
95 | #endif //_OpenGl_Window_Header |