0023394: Problem with BRepOffset_MakeOffset on a cylindrical face
[occt.git] / src / OpenGl / OpenGl_Window.hxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
3// Copyright (c) 2011-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
2166f0fa
SK
20
21#ifndef _OpenGl_Window_Header
22#define _OpenGl_Window_Header
23
24#include <Handle_OpenGl_Window.hxx>
25#include <MMgt_TShared.hxx>
26
27#include <InterfaceGraphic.hxx>
28#include <InterfaceGraphic_Aspect.hxx>
29#include <InterfaceGraphic_telem.hxx>
30
31#include <Handle_OpenGl_Display.hxx>
32#include <Handle_OpenGl_Context.hxx>
33
34//! This class represents low-level wrapper over window with GL context.
35//! The window itself should be provided to constructor.
36class OpenGl_Window : public MMgt_TShared
37{
38public:
39
40 //! Main constructor - prepare GL context for specified window.
41 OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
42 const CALL_DEF_WINDOW& theCWindow,
5e27df78 43 Aspect_RenderingContext theGContext,
44 const Handle(OpenGl_Context)& theShareCtx);
2166f0fa
SK
45
46 //! Destructor
47 virtual ~OpenGl_Window();
48
49 //! Resizes the window.
50 void Resize (const CALL_DEF_WINDOW& theCWindow);
51
52 //! Reads depth component for current scene into specified buffer.
53 void ReadDepths (const Standard_Integer theX, const Standard_Integer theY,
54 const Standard_Integer theWidth, const Standard_Integer theHeight,
55 float* theDepths);
56
57 void SetBackgroundColor (const Standard_ShortReal theR,
58 const Standard_ShortReal theG,
59 const Standard_ShortReal theB);
60
61 void EnablePolygonOffset() const;
62 void DisablePolygonOffset() const;
63
64 Standard_Integer Width() const { return myWidth; }
65 Standard_Integer Height() const { return myHeight; }
66 const TEL_COLOUR& BackgroundColor() const { return myBgColor; }
67 Standard_Boolean Dither() const { return myDither; }
68 Standard_Boolean BackDither() const { return myBackDither; }
69
70 const Handle(OpenGl_Display)& GetDisplay() const { return myDisplay; }
71
72 const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; }
73
5e27df78 74 //! This method will be removed in future version!
75 GLCONTEXT GetGContext() const;
2166f0fa
SK
76
77protected:
78
79 //! Activates GL context and setup viewport.
80 void Init();
81
82 //! Makes GL context for this window active in current thread
83 virtual Standard_Boolean Activate();
84
85 void EnableFeatures() const;
86 void DisableFeatures() const;
87
88 //! Draw directly to the FRONT buffer. Can cause artifacts on the screen.
89 void MakeFrontBufCurrent() const;
90
91 //! Draw to BACK buffer. Normal and default state.
92 void MakeBackBufCurrent() const;
93
94 //! Draw simultaneously to BACK and FRONT buffers. Abnormal usage.
95 void MakeFrontAndBackBufCurrent() const;
96
97protected:
98
99 Handle(OpenGl_Display) myDisplay;
2166f0fa 100 Handle(OpenGl_Context) myGlContext;
2166f0fa
SK
101 Standard_Boolean myOwnGContext; //!< set to TRUE if GL context was not created by this class
102#if (defined(_WIN32) || defined(__WIN32__))
2166f0fa
SK
103 BOOL mySysPalInUse;
104#endif
105
106 Standard_Integer myWidth; // WSWidth
107 Standard_Integer myHeight; // WSHeight
108 TEL_COLOUR myBgColor; // WSBackground
109 Standard_Boolean myDither;
110 Standard_Boolean myBackDither;
111
112public:
113
114 DEFINE_STANDARD_RTTI(OpenGl_Window) // Type definition
1c35b92f 115 DEFINE_STANDARD_ALLOC
2166f0fa
SK
116
117};
118
119#endif //_OpenGl_Window_Header