0022796: Possibility to display multi-line text in 3D
[occt.git] / src / OpenGl / OpenGl_Window.hxx
CommitLineData
2166f0fa
SK
1// File: OpenGl_Window.hxx
2// Created: 20 September 2011
3// Author: Sergey ZERCHANINOV
4// Copyright: OPEN CASCADE 2011
5
6#ifndef _OpenGl_Window_Header
7#define _OpenGl_Window_Header
8
9#include <Handle_OpenGl_Window.hxx>
10#include <MMgt_TShared.hxx>
11
12#include <InterfaceGraphic.hxx>
13#include <InterfaceGraphic_Aspect.hxx>
14#include <InterfaceGraphic_telem.hxx>
15
16#include <Handle_OpenGl_Display.hxx>
17#include <Handle_OpenGl_Context.hxx>
18
19//! This class represents low-level wrapper over window with GL context.
20//! The window itself should be provided to constructor.
21class OpenGl_Window : public MMgt_TShared
22{
23public:
24
25 //! Main constructor - prepare GL context for specified window.
26 OpenGl_Window (const Handle(OpenGl_Display)& theDisplay,
27 const CALL_DEF_WINDOW& theCWindow,
28 Aspect_RenderingContext theGContext);
29
30 //! Destructor
31 virtual ~OpenGl_Window();
32
33 //! Resizes the window.
34 void Resize (const CALL_DEF_WINDOW& theCWindow);
35
36 //! Reads depth component for current scene into specified buffer.
37 void ReadDepths (const Standard_Integer theX, const Standard_Integer theY,
38 const Standard_Integer theWidth, const Standard_Integer theHeight,
39 float* theDepths);
40
41 void SetBackgroundColor (const Standard_ShortReal theR,
42 const Standard_ShortReal theG,
43 const Standard_ShortReal theB);
44
45 void EnablePolygonOffset() const;
46 void DisablePolygonOffset() const;
47
48 Standard_Integer Width() const { return myWidth; }
49 Standard_Integer Height() const { return myHeight; }
50 const TEL_COLOUR& BackgroundColor() const { return myBgColor; }
51 Standard_Boolean Dither() const { return myDither; }
52 Standard_Boolean BackDither() const { return myBackDither; }
53
54 const Handle(OpenGl_Display)& GetDisplay() const { return myDisplay; }
55
56 const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; }
57
58 WINDOW GetWindow() const { return myWindow; }
59 GLCONTEXT GetGContext() const { return myGContext; }
60
61protected:
62
63 //! Activates GL context and setup viewport.
64 void Init();
65
66 //! Makes GL context for this window active in current thread
67 virtual Standard_Boolean Activate();
68
69 void EnableFeatures() const;
70 void DisableFeatures() const;
71
72 //! Draw directly to the FRONT buffer. Can cause artifacts on the screen.
73 void MakeFrontBufCurrent() const;
74
75 //! Draw to BACK buffer. Normal and default state.
76 void MakeBackBufCurrent() const;
77
78 //! Draw simultaneously to BACK and FRONT buffers. Abnormal usage.
79 void MakeFrontAndBackBufCurrent() const;
80
81protected:
82
83 Handle(OpenGl_Display) myDisplay;
84 WINDOW myWindow; //!< native window handle, system-specific
85 Handle(OpenGl_Context) myGlContext;
86 GLCONTEXT myGContext; //!< native GL context bound to this window, system-specific
87 Standard_Boolean myOwnGContext; //!< set to TRUE if GL context was not created by this class
88#if (defined(_WIN32) || defined(__WIN32__))
89 HDC myWindowDC;
90 BOOL mySysPalInUse;
91#endif
92
93 Standard_Integer myWidth; // WSWidth
94 Standard_Integer myHeight; // WSHeight
95 TEL_COLOUR myBgColor; // WSBackground
96 Standard_Boolean myDither;
97 Standard_Boolean myBackDither;
98
99public:
100
101 DEFINE_STANDARD_RTTI(OpenGl_Window) // Type definition
1c35b92f 102 DEFINE_STANDARD_ALLOC
2166f0fa
SK
103
104};
105
106#endif //_OpenGl_Window_Header