VTK
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 "vtkRenderingOpenGL2Module.h" // For export macro
29 #include <stack> // for ivar
30 #include "vtkOpenGLRenderWindow.h"
31 #include <X11/Xlib.h> // Needed for X types used in the public interface
32 #include <X11/Xutil.h> // Needed for X types used in the public interface
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 
87  virtual void PrefFullScreen();
88 
92  void SetSize(int,int) override;
93  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
94 
96 
99  virtual Colormap GetDesiredColormap();
100  virtual Visual *GetDesiredVisual();
101  virtual XVisualInfo *GetDesiredVisualInfo();
102  virtual int GetDesiredDepth();
104 
111  void SetStereoCapableWindow(vtkTypeBool capable) override;
112 
116  void MakeCurrent() override;
117 
121  bool IsCurrent() override;
122 
128  void SetForceMakeCurrent() override;
129 
133  const char *ReportCapabilities() override;
134 
138  int IsDirect() override;
139 
143  void *GetGenericDisplayId() override
144  {
145  return this->GetDisplayId();
146  }
147 
148  void *GetGenericWindowId() override;
149  void *GetGenericParentId() override
150  {
151  return reinterpret_cast<void *>(this->ParentId);
152  }
153 
154  void *GetGenericContext() override;
155  void *GetGenericDrawable() override
156  {
157  return reinterpret_cast<void *>(this->WindowId);
158  }
159 
163  int *GetScreenSize() VTK_SIZEHINT(2) override;
164 
168  int *GetPosition() VTK_SIZEHINT(2) override;
169 
173  Display *GetDisplayId();
174 
176 
180  void SetDisplayId(Display *);
181  void SetDisplayId(void *) override;
183 
187  Window GetParentId();
188 
190 
193  void SetParentId(Window);
194  void SetParentId(void *) override;
196 
200  Window GetWindowId();
201 
203 
206  void SetWindowId(Window);
207  void SetWindowId(void *) override;
209 
213  void SetNextWindowId(Window);
214 
220  void SetNextWindowId(void *) override;
221 
225  void SetWindowName(const char *) override;
226 
231  bool InitializeFromCurrentContext() override;
232 
236  bool GetPlatformSupportsRenderWindowSharing() override { return true; };
237 
239 
242  void SetPosition(int,int) override;
243  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
245 
247 
251  void HideCursor() override;
252  void ShowCursor() override;
254 
258  void SetCurrentCursor(int) override;
259 
265  int GetEventPending() override;
266 
270  void SetWindowInfo(const char *info) override;
271 
275  void SetNextWindowInfo(const char *info) override;
276 
280  void SetParentInfo(const char *info) override;
281 
286  void Render() override;
287 
291  void SetOffScreenRendering(vtkTypeBool i) override;
292 
294 
301  void PushContext() override;
302  void PopContext() override;
304 
314  bool SetSwapControl(int i) override;
315 
316 protected:
318  ~vtkXOpenGLRenderWindow() override;
319 
320  vtkXOpenGLRenderWindowInternal *Internal;
321 
322  Window ParentId;
323  Window WindowId;
324  Window NextWindowId;
325  Display *DisplayId;
326  Colormap ColorMap;
329  int ScreenSize[2];
333 
334  std::stack<Display *> DisplayStack;
335  std::stack<Drawable> DrawableStack;
336  std::stack<void *> ContextStack;
337 
338  // we must keep track of the cursors we are using
339  Cursor XCCrosshair;
340  Cursor XCArrow;
341  Cursor XCSizeAll;
342  Cursor XCSizeNS;
343  Cursor XCSizeWE;
344  Cursor XCSizeNE;
345  Cursor XCSizeNW;
346  Cursor XCSizeSE;
347  Cursor XCSizeSW;
348  Cursor XCHand;
349 
350 
351  void CreateAWindow() override;
352  void DestroyWindow() override;
353  void CreateOffScreenWindow(int width, int height);
354  void DestroyOffScreenWindow();
355  void ResizeOffScreenWindow(int width, int height);
356  void CloseDisplay();
357 
358 
359 private:
361  void operator=(const vtkXOpenGLRenderWindow&) = delete;
362 };
363 
364 
365 
366 #endif
OpenGL rendering window.
virtual void Finalize()=0
Finalize the rendering process.
virtual void SetForceMakeCurrent()
If called, allow MakeCurrent() to skip cache-check when called.
virtual void WindowRemap()=0
Remap the rendering window.
vtkXOpenGLRenderWindowInternal * Internal
virtual void HideCursor()=0
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.
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...
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
virtual int * GetScreenSize()=0
Get the current size of the screen in pixels.
void * GetGenericContext() override=0
Dummy stubs for vtkWindow API.
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
void SetWindowInfo(const char *) override=0
Dummy stubs for vtkWindow API.
OpenGL rendering window.
virtual int GetEventPending()=0
Check to see if a mouse button has been pressed.
int vtkTypeBool
Definition: vtkABI.h:69
virtual void SetStereoCapableWindow(vtkTypeBool capable)
Prescribe that the window be created in a stereo-capable mode.
virtual int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
virtual bool IsCurrent()=0
Tells if this window is the current graphics context for the calling thread.
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
void SetWindowId(void *) override=0
Dummy stubs for vtkWindow API.
void SetDisplayId(void *) override=0
Dummy stubs for vtkWindow API.
a simple class to control print indentation
Definition: vtkIndent.h:39
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
std::stack< Display * > DisplayStack
list of point or cell ids
Definition: vtkIdList.h:36
void SetPosition(int a[2]) override
Move the window to a new position on the display.
std::stack< Drawable > DrawableStack
void SetParentInfo(const char *) override=0
Dummy stubs for vtkWindow API.
virtual void SetNextWindowId(void *)=0
Dummy stubs for vtkWindow API.
virtual void SetOffScreenRendering(vtkTypeBool)
Create a window in memory instead of on the screen.
virtual int * GetPosition()
Set/Get the position in screen coordinates of the rendering window.
virtual void PushContext()
Ability to push and pop this window&#39;s context as the current context.
#define VTK_SIZEHINT(...)
virtual void Frame()=0
A termination method performed at the end of the rendering process to do things like swapping buffers...
const char * ReportCapabilities() override
Get report of capabilities for the render window.
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
void SetParentId(void *) override=0
Dummy stubs for vtkWindow API.
virtual void SetFullScreen(vtkTypeBool)=0
Turn on/off rendering full screen window size.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetNextWindowInfo(const char *)=0
Dummy stubs for vtkWindow API.
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
std::stack< void * > ContextStack
virtual void Start()=0
Initialize the rendering process.
virtual void SetWindowName(const char *)
Get name of rendering window.
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
void * GetGenericWindowId() override=0
Dummy stubs for vtkWindow API.
virtual void SetPosition(int, int)
Set/Get the position in screen coordinates of the rendering window.
virtual void Initialize(void)
Initialize the rendering window.
virtual void CreateAWindow()=0
Create a not-off-screen window.
void MakeCurrent() override=0
Attempt to make this window the current graphics context for the calling thread.
virtual void ShowCursor()=0
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void * GetGenericDisplayId() override
Xwindow get set functions.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.