1 // File: OpenGl_Window.hxx
2 // Created: 20 September 2011
3 // Author: Sergey ZERCHANINOV
4 // Copyright: OPEN CASCADE 2011
6 #ifndef _OpenGl_Window_Header
7 #define _OpenGl_Window_Header
9 #include <Handle_OpenGl_Window.hxx>
10 #include <MMgt_TShared.hxx>
12 #include <InterfaceGraphic.hxx>
13 #include <InterfaceGraphic_Aspect.hxx>
14 #include <InterfaceGraphic_telem.hxx>
16 #include <Handle_OpenGl_Display.hxx>
17 #include <Handle_OpenGl_Context.hxx>
19 //! This class represents low-level wrapper over window with GL context.
20 //! The window itself should be provided to constructor.
21 class OpenGl_Window : public MMgt_TShared
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);
31 virtual ~OpenGl_Window();
33 //! Resizes the window.
34 void Resize (const CALL_DEF_WINDOW& theCWindow);
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,
41 void SetBackgroundColor (const Standard_ShortReal theR,
42 const Standard_ShortReal theG,
43 const Standard_ShortReal theB);
45 void EnablePolygonOffset() const;
46 void DisablePolygonOffset() const;
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; }
54 const Handle(OpenGl_Display)& GetDisplay() const { return myDisplay; }
56 const Handle(OpenGl_Context)& GetGlContext() const { return myGlContext; }
58 WINDOW GetWindow() const { return myWindow; }
59 GLCONTEXT GetGContext() const { return myGContext; }
63 //! Activates GL context and setup viewport.
66 //! Makes GL context for this window active in current thread
67 virtual Standard_Boolean Activate();
69 void EnableFeatures() const;
70 void DisableFeatures() const;
72 //! Draw directly to the FRONT buffer. Can cause artifacts on the screen.
73 void MakeFrontBufCurrent() const;
75 //! Draw to BACK buffer. Normal and default state.
76 void MakeBackBufCurrent() const;
78 //! Draw simultaneously to BACK and FRONT buffers. Abnormal usage.
79 void MakeFrontAndBackBufCurrent() const;
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__))
93 Standard_Integer myWidth; // WSWidth
94 Standard_Integer myHeight; // WSHeight
95 TEL_COLOUR myBgColor; // WSBackground
96 Standard_Boolean myDither;
97 Standard_Boolean myBackDither;
101 DEFINE_STANDARD_RTTI(OpenGl_Window) // Type definition
102 DEFINE_STANDARD_ALLOC
106 #endif //_OpenGl_Window_Header