VTK  9.0.20200808
vtkXOpenGLRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkXOpenGLRenderWindow.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
28 #ifndef vtkXOpenGLRenderWindow_h
29 #define vtkXOpenGLRenderWindow_h
30 
31 #include "vtkOpenGLRenderWindow.h"
32 #include "vtkRenderingOpenGL2Module.h" // For export macro
33 #include <X11/Xlib.h> // Needed for X types used in the public interface
34 #include <X11/Xutil.h> // Needed for X types used in the public interface
35 #include <stack> // for ivar
36 
37 class vtkIdList;
38 class vtkXOpenGLRenderWindowInternal;
39 
40 class VTKRENDERINGOPENGL2_EXPORT vtkXOpenGLRenderWindow : public vtkOpenGLRenderWindow
41 {
42 public:
43  static vtkXOpenGLRenderWindow* New();
45  void PrintSelf(ostream& os, vtkIndent indent) override;
46 
50  void Start() override;
51 
55  void Frame() override;
56 
60  virtual void WindowInitialize();
61 
68  void Initialize() override;
69 
75  void Finalize() override;
76 
80  void SetFullScreen(vtkTypeBool) override;
81 
85  void WindowRemap() override;
86 
87  // Call X funcs to map unmap
88  void SetShowWindow(bool val) override;
89 
93  virtual void PrefFullScreen();
94 
103  void SetSize(int width, int height) override;
104  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
105 
110  void SetSizeNoXResize(int, int);
111 
113 
116  virtual Colormap GetDesiredColormap();
117  virtual Visual* GetDesiredVisual();
118  virtual XVisualInfo* GetDesiredVisualInfo();
119  virtual int GetDesiredDepth();
121 
128  void SetStereoCapableWindow(vtkTypeBool capable) override;
129 
133  void MakeCurrent() override;
134 
138  bool IsCurrent() override;
139 
145  void SetForceMakeCurrent() override;
146 
150  const char* ReportCapabilities() override;
151 
155  vtkTypeBool IsDirect() override;
156 
160  void* GetGenericDisplayId() override { return this->GetDisplayId(); }
161 
162  void* GetGenericWindowId() override;
163  void* GetGenericParentId() override { return reinterpret_cast<void*>(this->ParentId); }
164 
165  void* GetGenericContext() override;
166  void* GetGenericDrawable() override { return reinterpret_cast<void*>(this->WindowId); }
167 
172  int* GetScreenSize() VTK_SIZEHINT(2) override;
173 
178  int* GetPosition() VTK_SIZEHINT(2) override;
179 
183  Display* GetDisplayId();
184 
186 
190  void SetDisplayId(Display*);
191  void SetDisplayId(void*) override;
193 
197  Window GetParentId();
198 
200 
203  void SetParentId(Window);
204  void SetParentId(void*) override;
206 
210  Window GetWindowId();
211 
213 
216  void SetWindowId(Window);
217  void SetWindowId(void*) override;
219 
223  void SetNextWindowId(Window);
224 
230  void SetNextWindowId(void*) override;
231 
235  void SetWindowName(const char*) override;
236 
241  void SetIcon(vtkImageData* img) override;
242 
247  bool InitializeFromCurrentContext() override;
248 
252  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
253 
255 
260  void SetPosition(int x, int y) override;
261  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
263 
265 
269  void HideCursor() override;
270  void ShowCursor() override;
272 
276  void SetCurrentCursor(int) override;
277 
283  vtkTypeBool GetEventPending() override;
284 
288  void SetWindowInfo(const char* info) override;
289 
293  void SetNextWindowInfo(const char* info) override;
294 
298  void SetParentInfo(const char* info) override;
299 
304  void Render() override;
305 
307 
314  void PushContext() override;
315  void PopContext() override;
317 
327  bool SetSwapControl(int i) override;
328 
329 protected:
331  ~vtkXOpenGLRenderWindow() override;
332 
333  vtkXOpenGLRenderWindowInternal* Internal;
334 
335  Window ParentId;
336  Window WindowId;
337  Window NextWindowId;
338  Display* DisplayId;
339  Colormap ColorMap;
345 
346  std::stack<Display*> DisplayStack;
347  std::stack<Drawable> DrawableStack;
348  std::stack<void*> ContextStack;
349 
350  // we must keep track of the cursors we are using
351  Cursor XCCrosshair;
352  Cursor XCArrow;
353  Cursor XCSizeAll;
354  Cursor XCSizeNS;
355  Cursor XCSizeWE;
356  Cursor XCSizeNE;
357  Cursor XCSizeNW;
358  Cursor XCSizeSE;
359  Cursor XCSizeSW;
360  Cursor XCHand;
361 
362  void CreateAWindow() override;
363  void DestroyWindow() override;
364  void CloseDisplay();
365 
366 private:
368  void operator=(const vtkXOpenGLRenderWindow&) = delete;
369 };
370 
371 #endif
vtkOpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkXOpenGLRenderWindow::DisplayId
Display * DisplayId
Definition: vtkXOpenGLRenderWindow.h:338
vtkXOpenGLRenderWindow::ColorMap
Colormap ColorMap
Definition: vtkXOpenGLRenderWindow.h:339
vtkXOpenGLRenderWindow::DisplayStack
std::stack< Display * > DisplayStack
Definition: vtkXOpenGLRenderWindow.h:346
vtkRenderWindow::SetWindowInfo
void SetWindowInfo(const char *) override
Definition: vtkRenderWindow.h:628
vtkOpenGLRenderWindow::SetSwapControl
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
Definition: vtkOpenGLRenderWindow.h:351
vtkWindow::SetPosition
virtual void SetPosition(int x, int y)
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
vtkXOpenGLRenderWindow::DrawableStack
std::stack< Drawable > DrawableStack
Definition: vtkXOpenGLRenderWindow.h:347
vtkXOpenGLRenderWindow::XCSizeSW
Cursor XCSizeSW
Definition: vtkXOpenGLRenderWindow.h:359
vtkRenderWindow::SetNextWindowInfo
virtual void SetNextWindowInfo(const char *)
Definition: vtkRenderWindow.h:629
vtkRenderWindow::SetForceMakeCurrent
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
Definition: vtkRenderWindow.h:679
vtkRenderWindow::WindowRemap
virtual void WindowRemap()
Remap the rendering window.
Definition: vtkRenderWindow.h:404
vtkOpenGLRenderWindow::PopContext
virtual void PopContext()
Definition: vtkOpenGLRenderWindow.h:334
vtkRenderWindow::ShowCursor
virtual void ShowCursor()
Definition: vtkRenderWindow.h:212
vtkRenderWindow::HideCursor
virtual void HideCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
Definition: vtkRenderWindow.h:211
vtkWindow::SetSize
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
vtkXOpenGLRenderWindow::XCSizeNS
Cursor XCSizeNS
Definition: vtkXOpenGLRenderWindow.h:354
vtkXOpenGLRenderWindow::WindowId
Window WindowId
Definition: vtkXOpenGLRenderWindow.h:336
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:45
vtkRenderWindow::Finalize
virtual void Finalize()
Finalize the rendering process.
Definition: vtkRenderWindow.h:177
vtkOpenGLRenderWindow::Render
void Render() override
Handle opengl specific code and calls superclass.
vtkXOpenGLRenderWindow::ForceMakeCurrent
vtkTypeBool ForceMakeCurrent
Definition: vtkXOpenGLRenderWindow.h:343
vtkX3D::height
Definition: vtkX3D.h:260
vtkXOpenGLRenderWindow::CursorHidden
vtkTypeBool CursorHidden
Definition: vtkXOpenGLRenderWindow.h:342
vtkRenderWindow::MakeCurrent
void MakeCurrent() override
Attempt to make this window the current graphics context for the calling thread.
Definition: vtkRenderWindow.h:656
vtkRenderWindow::IsDirect
virtual vtkTypeBool IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
Definition: vtkRenderWindow.h:694
vtkRenderWindow::GetEventPending
virtual vtkTypeBool GetEventPending()
Check to see if a mouse button has been pressed.
Definition: vtkRenderWindow.h:561
vtkImageData
topologically and geometrically regular array of data
Definition: vtkImageData.h:41
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkRenderWindow::SetCurrentCursor
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
vtkRenderWindow::SetParentInfo
void SetParentInfo(const char *) override
Definition: vtkRenderWindow.h:630
vtkWindow::GetScreenSize
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:105
vtkXOpenGLRenderWindow::XCHand
Cursor XCHand
Definition: vtkXOpenGLRenderWindow.h:360
vtkXOpenGLRenderWindow::XCCrosshair
Cursor XCCrosshair
Definition: vtkXOpenGLRenderWindow.h:351
vtkRenderWindow::SetStereoCapableWindow
virtual void SetStereoCapableWindow(vtkTypeBool capable)
vtkXOpenGLRenderWindow::XCArrow
Cursor XCArrow
Definition: vtkXOpenGLRenderWindow.h:352
vtkX3D::info
Definition: vtkX3D.h:382
vtkXOpenGLRenderWindow::ParentId
Window ParentId
Definition: vtkXOpenGLRenderWindow.h:335
vtkXOpenGLRenderWindow::GetGenericDisplayId
void * GetGenericDisplayId() override
Xwindow get set functions.
Definition: vtkXOpenGLRenderWindow.h:160
vtkOpenGLRenderWindow::ReportCapabilities
const char * ReportCapabilities() override
Get report of capabilities for the render window.
vtkXOpenGLRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Definition: vtkXOpenGLRenderWindow.h:166
vtkXOpenGLRenderWindow::ContextStack
std::stack< void * > ContextStack
Definition: vtkXOpenGLRenderWindow.h:348
vtkOpenGLRenderWindow::Frame
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
vtkXOpenGLRenderWindow::XCSizeNE
Cursor XCSizeNE
Definition: vtkXOpenGLRenderWindow.h:356
vtkXOpenGLRenderWindow::OwnDisplay
vtkTypeBool OwnDisplay
Definition: vtkXOpenGLRenderWindow.h:341
vtkXOpenGLRenderWindow::XCSizeSE
Cursor XCSizeSE
Definition: vtkXOpenGLRenderWindow.h:358
vtkXOpenGLRenderWindow::OwnWindow
vtkTypeBool OwnWindow
Definition: vtkXOpenGLRenderWindow.h:340
vtkXOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkXOpenGLRenderWindow.h:40
vtkRenderWindow::SetFullScreen
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
Definition: vtkRenderWindow.h:228
vtkXOpenGLRenderWindow::XCSizeAll
Cursor XCSizeAll
Definition: vtkXOpenGLRenderWindow.h:353
vtkOpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
vtkWindow::SetShowWindow
virtual void SetShowWindow(bool)
vtkXOpenGLRenderWindow::XCSizeWE
Cursor XCSizeWE
Definition: vtkXOpenGLRenderWindow.h:355
vtkXOpenGLRenderWindow::SetSize
void SetSize(int a[2]) override
Definition: vtkXOpenGLRenderWindow.h:104
vtkXOpenGLRenderWindow::UsingHardware
vtkTypeBool UsingHardware
Definition: vtkXOpenGLRenderWindow.h:344
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkXOpenGLRenderWindow::Internal
vtkXOpenGLRenderWindowInternal * Internal
Definition: vtkXOpenGLRenderWindow.h:333
vtkRenderWindow::GetGenericContext
void * GetGenericContext() override
Definition: vtkRenderWindow.h:626
vtkOpenGLRenderWindow::Start
void Start(void) override
Begin the rendering process.
vtkRenderWindow::IsCurrent
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
Definition: vtkRenderWindow.h:662
vtkRenderWindow::GetGenericWindowId
void * GetGenericWindowId() override
Definition: vtkRenderWindow.h:624
vtkXOpenGLRenderWindow::SetPosition
void SetPosition(int a[2]) override
Definition: vtkXOpenGLRenderWindow.h:261
vtkRenderWindow::New
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on,...
vtkXOpenGLRenderWindow::GetGenericParentId
void * GetGenericParentId() override
Definition: vtkXOpenGLRenderWindow.h:163
vtkXOpenGLRenderWindow::NextWindowId
Window NextWindowId
Definition: vtkXOpenGLRenderWindow.h:337
vtkOpenGLRenderWindow::PushContext
virtual void PushContext()
Ability to push and pop this window's context as the current context.
Definition: vtkOpenGLRenderWindow.h:333
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkOpenGLRenderWindow::Initialize
virtual void Initialize(void)
Initialize the rendering window.
Definition: vtkOpenGLRenderWindow.h:302
vtkOpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()=0
Create a not-off-screen window.
vtkOpenGLRenderWindow.h
vtkXOpenGLRenderWindow::XCSizeNW
Cursor XCSizeNW
Definition: vtkXOpenGLRenderWindow.h:357