VTK  9.7.1
vtkWebAssemblyOpenGLRenderWindow.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
14 #ifndef vtkWebAssemblyOpenGLRenderWindow_h
15 #define vtkWebAssemblyOpenGLRenderWindow_h
16 
17 #include "vtkOpenGLRenderWindow.h"
18 #include "vtkRenderingOpenGL2Module.h" // For export macro
19 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
20 #include <stack> // for ivar
21 
22 VTK_ABI_NAMESPACE_BEGIN
24 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkWebAssemblyOpenGLRenderWindow
25  : public vtkOpenGLRenderWindow
26 {
27 public:
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
40  void Initialize() override;
41 
47  void Finalize() override;
48 
52  void SetFullScreen(vtkTypeBool) override;
53 
55 
58  void SetSize(int, int) override;
59  void SetSize(int a[2]) override { vtkOpenGLRenderWindow::SetSize(a); }
61 
63 
66  void SetPosition(int x, int y) override { vtkOpenGLRenderWindow::SetPosition(x, y); }
67  void SetPosition(int a[2]) override { vtkOpenGLRenderWindow::SetPosition(a); }
69 
73  int* GetScreenSize() VTK_SIZEHINT(2) override;
74 
78  int* GetPosition() VTK_SIZEHINT(2) override;
79 
80  void* GetGenericDisplayId() override { return (void*)this->ContextId; }
81  void* GetGenericWindowId() override { return (void*)this->ContextId; }
82  void* GetGenericDrawable() override { return (void*)this->ContextId; }
83 
87  void MakeCurrent() override;
88 
92  void ReleaseCurrent() override;
93 
97  bool IsCurrent() override;
98 
102  void Clean();
103 
105 
112  void PushContext() override;
113  void PopContext() override;
115 
125  bool SetSwapControl(int i) override;
126 
131  int GetColorBufferSizes(int* rgba) override;
132 
134 
138  void HideCursor() override;
139  void ShowCursor() override;
141 
145  vtkGetStringMacro(CanvasSelector);
146  vtkSetStringMacro(CanvasSelector);
147 
153  {
154  Default,
155  LowPower,
156  HighPerformance
157  };
158 
160 
172  vtkSetEnumMacro(PowerPreference, PowerPreferenceType);
173  vtkGetEnumMacro(PowerPreference, PowerPreferenceType);
175 
177 
185  void PreferHighPerformanceAdapter() { PowerPreference = PowerPreferenceType::HighPerformance; }
186  void PreferLowPowerAdapter() { PowerPreference = PowerPreferenceType::LowPower; }
188 
193  void SetUseOffScreenBuffers(bool) override {}
194 
199  void SetShowWindow(bool) override {}
200 
201 protected:
204 
205  unsigned long ContextId;
206  std::stack<unsigned long> ContextStack;
207  char* CanvasSelector = nullptr;
208  PowerPreferenceType PowerPreference = PowerPreferenceType::Default;
209 
210  void CleanUpRenderers();
211  void CreateAWindow() override;
212  void DestroyWindow() override;
213 
214 private:
216  void operator=(const vtkWebAssemblyOpenGLRenderWindow&) = delete;
217 };
218 
219 #define vtkWebAssemblyOpenGLRenderWindow_OVERRIDE_ATTRIBUTES \
220  vtkWebAssemblyOpenGLRenderWindow::CreateOverrideAttributes()
221 VTK_ABI_NAMESPACE_END
222 #endif
OpenGL rendering window.
Attribute for vtkObjectFactory overrides.
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.
void SetUseOffScreenBuffers(bool) override
Make the setter for UseOffscreenBuffers no-op.
void SetPosition(int x, int y) override
Set the position of the window.
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.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
int vtkTypeBool
Definition: vtkABI.h:64
void SetShowWindow(bool) override
Make the setter for ShowWindow no-op.
void PreferLowPowerAdapter()
Set preference for a high-performance or low-power device.
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)...
PowerPreferenceType
These enums have a one-one correspondence with the webgpu enums.
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:110
void Initialize() override
Initialize the rendering window.
static vtkOverrideAttribute * CreateOverrideAttributes()
int GetColorBufferSizes(int *rgba) override
Get the size of the color buffer.
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.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
#define VTK_SIZEHINT(...)
#define VTK_NEWINSTANCE
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
void SetPosition(int a[2]) override
Set the position of the window.
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.
void SetSize(int a[2]) override
Set the size of the window in pixels.
void PreferHighPerformanceAdapter()
Set preference for a high-performance or low-power device.
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
virtual void CreateAWindow()=0
Create a not-off-screen window.