VTK  9.7.1
vtkXOpenGLRenderWindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
16 #ifndef vtkXOpenGLRenderWindow_h
17 #define vtkXOpenGLRenderWindow_h
18 
19 #include "vtkOpenGLRenderWindow.h"
20 #include "vtkRenderingOpenGL2Module.h" // For export macro
21 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
22 #include "vtkX11Functions.h" // Needed for X types used in the public interface
23 #include <stack> // for ivar
24 
25 VTK_ABI_NAMESPACE_BEGIN
26 class vtkIdList;
27 class vtkXOpenGLRenderWindowInternal;
28 
29 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkXOpenGLRenderWindow
30  : public vtkOpenGLRenderWindow
31 {
32 public:
33  static vtkXOpenGLRenderWindow* New();
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  void Start() override;
41 
45  void Frame() override;
46 
50  virtual void WindowInitialize();
51 
58  void Initialize() override;
59 
65  void Finalize() override;
66 
70  void SetFullScreen(vtkTypeBool) override;
71 
75  void WindowRemap() override;
76 
77  // Call X funcs to map unmap
78  void SetShowWindow(bool val) override;
79 
83  virtual void PrefFullScreen();
84 
97  void SetSize(int width, int height) override;
98  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
99 
101 
104  virtual Colormap GetDesiredColormap();
105  virtual Visual* GetDesiredVisual();
106  virtual vtkXVisualInfo* GetDesiredVisualInfo();
107  virtual int GetDesiredDepth();
109 
116  void SetStereoCapableWindow(vtkTypeBool capable) override;
117 
122  void SetCoverable(vtkTypeBool coverable) override;
123 
127  void MakeCurrent() override;
128 
132  bool IsCurrent() override;
133 
137  void ReleaseCurrent() override;
138 
144  void SetForceMakeCurrent() override;
145 
149  const char* ReportCapabilities() override;
150 
154  vtkTypeBool IsDirect() override;
155 
159  void* GetGenericDisplayId() override { return this->GetDisplayId(); }
160 
161  void* GetGenericWindowId() override;
162  void* GetGenericParentId() override { return reinterpret_cast<void*>(this->ParentId); }
163 
164  void* GetGenericContext() override;
165  void* GetGenericDrawable() override { return reinterpret_cast<void*>(this->WindowId); }
166 
167  void* GetGenericFBConfig();
168 
173  int* GetScreenSize() VTK_SIZEHINT(2) override;
174 
179  int* GetPosition() VTK_SIZEHINT(2) override;
180 
185  Display* GetDisplayId();
186 
190  bool EnsureDisplay() override;
191 
193 
198  void SetDisplayId(Display*);
200  void SetDisplayId(void*) override;
202 
207  Window GetParentId();
208 
210 
214  void SetParentId(Window);
216  void SetParentId(void*) override;
218 
223  Window GetWindowId();
224 
226 
230  void SetWindowId(Window);
232  void SetWindowId(void*) override;
234 
238  void SetNextWindowId(Window);
239 
245  void SetNextWindowId(void*) override;
246 
250  void SetWindowName(const char*) override;
251 
256  void SetIcon(vtkImageData* img) override;
257 
262  bool InitializeFromCurrentContext() override;
263 
267  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
268 
270 
275  void SetPosition(int x, int y) override;
276  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
278 
280 
284  void HideCursor() override;
285  void ShowCursor() override;
287 
291  void SetCurrentCursor(int) override;
292 
298  vtkTypeBool GetEventPending() override;
299 
303  void SetWindowInfo(const char* info) override;
304 
308  void SetNextWindowInfo(const char* info) override;
309 
313  void SetParentInfo(const char* info) override;
314 
319  void Render() override;
320 
322 
329  void PushContext() override;
330  void PopContext() override;
332 
342  bool SetSwapControl(int i) override;
343 
344 protected:
346  ~vtkXOpenGLRenderWindow() override;
347 
348  vtkXOpenGLRenderWindowInternal* Internal;
349 
350  Window ParentId;
351  Window WindowId;
352  Window NextWindowId;
353  Display* DisplayId;
354  Colormap ColorMap;
360 
361  std::stack<Display*> DisplayStack;
362  std::stack<Drawable> DrawableStack;
363  std::stack<void*> ContextStack;
364 
365  // we must keep track of the cursors we are using
366  Cursor XCCrosshair;
367  Cursor XCArrow;
368  Cursor XCSizeAll;
369  Cursor XCSizeNS;
370  Cursor XCSizeWE;
371  Cursor XCSizeNE;
372  Cursor XCSizeNW;
373  Cursor XCSizeSE;
374  Cursor XCSizeSW;
375  Cursor XCHand;
376  Cursor XCCustom;
377 
378  void CreateAWindow() override;
379  void DestroyWindow() override;
380  void CloseDisplay();
381 
382 private:
384  void operator=(const vtkXOpenGLRenderWindow&) = delete;
385 
389  bool EnsureGLX();
390 };
391 
392 VTK_ABI_NAMESPACE_END
393 #endif
OpenGL rendering window.
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
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: vtkWindow.h:295
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 Render() override
Handle opengl specific code and calls superclass.
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
void SetWindowInfo(const char *) override
Dummy stubs for vtkWindow API.
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.
std::stack< Display * > DisplayStack
int vtkTypeBool
Definition: vtkABI.h:64
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.
static vtkOpenGLRenderWindow * New()
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
void SetSize(int a[2]) override
Get the size (width and height) of the rendering window in screen coordinates (in pixels)...
std::stack< void * > ContextStack
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
virtual void SetCoverable(vtkTypeBool coverable)
Set/Get whether windows should be coverable (as opposed to always on top).
void Start() override
Begin the rendering process.
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
list of point or cell ids
Definition: vtkIdList.h:25
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:110
void Initialize() override
Initialize the rendering window.
std::stack< Drawable > DrawableStack
virtual void MakeCurrent()
Make the window current.
Definition: vtkWindow.h:255
virtual void PushContext()
Ability to push and pop this window's context as the current context.
#define VTK_SIZEHINT(...)
const char * ReportCapabilities() override
Get report of capabilities for the render window.
#define VTK_MARSHALEXCLUDE(reason)
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.
virtual void ReleaseCurrent()
Release the current context.
Definition: vtkWindow.h:261
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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...
Definition: vtkWindow.h:296
#define VTK_MARSHALAUTO
#define VTK_MARSHAL_EXCLUDE_REASON_NOT_SUPPORTED
void SetParentInfo(const char *) override
Dummy stubs for vtkWindow API.
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
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.