VTK  9.0.1
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 =========================================================================*/
25 #ifndef vtkXOpenGLRenderWindow_h
26 #define vtkXOpenGLRenderWindow_h
27 
28 #include "vtkOpenGLRenderWindow.h"
29 #include "vtkRenderingOpenGL2Module.h" // For export macro
30 #include <X11/Xlib.h> // Needed for X types used in the public interface
31 #include <X11/Xutil.h> // Needed for X types used in the public interface
32 #include <stack> // for ivar
33 
34 class vtkIdList;
35 class vtkXOpenGLRenderWindowInternal;
36 
37 class VTKRENDERINGOPENGL2_EXPORT vtkXOpenGLRenderWindow : public vtkOpenGLRenderWindow
38 {
39 public:
40  static vtkXOpenGLRenderWindow* New();
42  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
47  void Start() override;
48 
52  void Frame() override;
53 
57  virtual void WindowInitialize();
58 
65  void Initialize() override;
66 
72  void Finalize() override;
73 
77  void SetFullScreen(vtkTypeBool) override;
78 
82  void WindowRemap() override;
83 
84  // Call X funcs to map unmap
85  void SetShowWindow(bool val) override;
86 
90  virtual void PrefFullScreen();
91 
100  void SetSize(int width, int height) override;
101  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
102 
107  void SetSizeNoXResize(int, int);
108 
110 
113  virtual Colormap GetDesiredColormap();
114  virtual Visual* GetDesiredVisual();
115  virtual XVisualInfo* GetDesiredVisualInfo();
116  virtual int GetDesiredDepth();
118 
125  void SetStereoCapableWindow(vtkTypeBool capable) override;
126 
130  void MakeCurrent() override;
131 
135  bool IsCurrent() override;
136 
142  void SetForceMakeCurrent() override;
143 
147  const char* ReportCapabilities() override;
148 
152  vtkTypeBool IsDirect() override;
153 
157  void* GetGenericDisplayId() override { return this->GetDisplayId(); }
158 
159  void* GetGenericWindowId() override;
160  void* GetGenericParentId() override { return reinterpret_cast<void*>(this->ParentId); }
161 
162  void* GetGenericContext() override;
163  void* GetGenericDrawable() override { return reinterpret_cast<void*>(this->WindowId); }
164 
169  int* GetScreenSize() VTK_SIZEHINT(2) override;
170 
175  int* GetPosition() VTK_SIZEHINT(2) override;
176 
180  Display* GetDisplayId();
181 
183 
187  void SetDisplayId(Display*);
188  void SetDisplayId(void*) override;
190 
194  Window GetParentId();
195 
197 
200  void SetParentId(Window);
201  void SetParentId(void*) override;
203 
207  Window GetWindowId();
208 
210 
213  void SetWindowId(Window);
214  void SetWindowId(void*) override;
216 
220  void SetNextWindowId(Window);
221 
227  void SetNextWindowId(void*) override;
228 
232  void SetWindowName(const char*) override;
233 
238  bool InitializeFromCurrentContext() override;
239 
243  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
244 
246 
251  void SetPosition(int x, int y) override;
252  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
254 
256 
260  void HideCursor() override;
261  void ShowCursor() override;
263 
267  void SetCurrentCursor(int) override;
268 
274  vtkTypeBool GetEventPending() override;
275 
279  void SetWindowInfo(const char* info) override;
280 
284  void SetNextWindowInfo(const char* info) override;
285 
289  void SetParentInfo(const char* info) override;
290 
295  void Render() override;
296 
298 
305  void PushContext() override;
306  void PopContext() override;
308 
318  bool SetSwapControl(int i) override;
319 
320 protected:
322  ~vtkXOpenGLRenderWindow() override;
323 
324  vtkXOpenGLRenderWindowInternal* Internal;
325 
326  Window ParentId;
327  Window WindowId;
328  Window NextWindowId;
329  Display* DisplayId;
330  Colormap ColorMap;
336 
337  std::stack<Display*> DisplayStack;
338  std::stack<Drawable> DrawableStack;
339  std::stack<void*> ContextStack;
340 
341  // we must keep track of the cursors we are using
342  Cursor XCCrosshair;
343  Cursor XCArrow;
344  Cursor XCSizeAll;
345  Cursor XCSizeNS;
346  Cursor XCSizeWE;
347  Cursor XCSizeNE;
348  Cursor XCSizeNW;
349  Cursor XCSizeSE;
350  Cursor XCSizeSW;
351  Cursor XCHand;
352 
353  void CreateAWindow() override;
354  void DestroyWindow() override;
355  void CloseDisplay();
356 
357 private:
359  void operator=(const vtkXOpenGLRenderWindow&) = delete;
360 };
361 
362 #endif
OpenGL rendering window.
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
virtual void SetFullScreen(vtkTypeBool)
Turn on/off rendering full screen window size.
vtkXOpenGLRenderWindowInternal * Internal
void * GetGenericContext() override
Dummy stubs for vtkWindow API.
virtual void WindowRemap()
Remap the rendering window.
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
void Start(void) override
Begin the rendering process.
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...
void Render() override
Handle opengl specific code and calls superclass.
virtual void SetNextWindowId(void *)
Dummy stubs for vtkWindow API.
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on...
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
void MakeCurrent() override
Attempt to make this window the current graphics context for the calling thread.
void SetWindowInfo(const char *) override
Dummy stubs for vtkWindow API.
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
virtual void SetPosition(int x, int y)
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
virtual void Finalize()
Finalize the rendering process.
virtual void SetShowWindow(bool)
Show or not Show the window.
OpenGL rendering window.
void SetParentId(void *) override
Dummy stubs for vtkWindow API.
std::stack< Display * > DisplayStack
int vtkTypeBool
Definition: vtkABI.h:69
virtual void SetStereoCapableWindow(vtkTypeBool capable)
Prescribe that the window be created in a stereo-capable mode.
virtual void SetNextWindowInfo(const char *)
Dummy stubs for vtkWindow API.
void SetSize(int a[2]) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
void SetWindowId(void *) override
Dummy stubs for vtkWindow API.
std::stack< void * > ContextStack
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
list of point or cell ids
Definition: vtkIdList.h:30
virtual void ShowCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void SetPosition(int a[2]) override
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:101
std::stack< Drawable > DrawableStack
virtual int * GetPosition()
Get the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual void PushContext()
Ability to push and pop this window&#39;s context as the current context.
#define VTK_SIZEHINT(...)
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void SetSize(int width, int height) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
virtual vtkTypeBool GetEventPending()
Check to see if a mouse button has been pressed.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetWindowName(const char *)
Get name of rendering window.
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
void SetParentInfo(const char *) override
Dummy stubs for vtkWindow API.
virtual void Initialize(void)
Initialize the rendering window.
virtual void CreateAWindow()=0
Create a not-off-screen window.
virtual vtkTypeBool IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
void * GetGenericDisplayId() override
Xwindow get set functions.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.