VTK  9.5.20250618
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
18#include "vtkRenderingOpenGL2Module.h" // For export macro
19#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
20#include <stack> // for ivar
21
22VTK_ABI_NAMESPACE_BEGIN
23class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkWebAssemblyOpenGLRenderWindow
25{
26public:
29 void PrintSelf(ostream& os, vtkIndent indent) override;
30
37 void Initialize() override;
38
44 void Finalize() override;
45
49 void SetFullScreen(vtkTypeBool) override;
50
52
55 void SetSize(int, int) override;
56 void SetSize(int a[2]) override { vtkOpenGLRenderWindow::SetSize(a); }
58
60
63 void SetPosition(int x, int y) override { vtkOpenGLRenderWindow::SetPosition(x, y); }
64 void SetPosition(int a[2]) override { vtkOpenGLRenderWindow::SetPosition(a); }
66
70 int* GetScreenSize() VTK_SIZEHINT(2) override;
71
75 int* GetPosition() VTK_SIZEHINT(2) override;
76
77 void* GetGenericDisplayId() override { return (void*)this->ContextId; }
78 void* GetGenericWindowId() override { return (void*)this->ContextId; }
79 void* GetGenericDrawable() override { return (void*)this->ContextId; }
80
84 void MakeCurrent() override;
85
89 void ReleaseCurrent() override;
90
94 bool IsCurrent() override;
95
99 void Clean();
100
102
109 void PushContext() override;
110 void PopContext() override;
112
122 bool SetSwapControl(int i) override;
123
128 int GetColorBufferSizes(int* rgba) override;
129
131
135 void HideCursor() override;
136 void ShowCursor() override;
138
142 vtkGetStringMacro(CanvasSelector);
143 vtkSetStringMacro(CanvasSelector);
144
150 {
151 Default,
152 LowPower,
153 HighPerformance
154 };
155
157
172
174
182 void PreferHighPerformanceAdapter() { PowerPreference = PowerPreferenceType::HighPerformance; }
183 void PreferLowPowerAdapter() { PowerPreference = PowerPreferenceType::LowPower; }
185
190 void SetUseOffScreenBuffers(bool) override {}
191
196 void SetShowWindow(bool) override {}
197
198protected:
201
202 unsigned long ContextId;
203 std::stack<unsigned long> ContextStack;
204 char* CanvasSelector = nullptr;
205 PowerPreferenceType PowerPreference = PowerPreferenceType::Default;
206
208 void CreateAWindow() override;
209 void DestroyWindow() override;
210
211private:
213 void operator=(const vtkWebAssemblyOpenGLRenderWindow&) = delete;
214};
215
216VTK_ABI_NAMESPACE_END
217#endif
a simple class to control print indentation
Definition vtkIndent.h:108
OpenGL rendering window.
void SetShowWindow(bool) override
Make the setter for ShowWindow no-op.
PowerPreferenceType
These enums have a one-one correspondence with the webgpu enums.
void Initialize() override
Initialize the rendering window.
static vtkWebAssemblyOpenGLRenderWindow * New()
void ReleaseCurrent() override
Release the current context.
vtkSetEnumMacro(PowerPreference, PowerPreferenceType)
Set/Get the power preference of the graphics adapter.
void SetSize(int, int) override
Set the size of the window in pixels.
bool IsCurrent() override
Tells if this window is the current OpenGL context for the calling thread.
void MakeCurrent() override
Make this windows OpenGL context the current context.
void SetUseOffScreenBuffers(bool) override
Make the setter for UseOffscreenBuffers no-op.
void SetSize(int a[2]) override
Set the size of the window in pixels.
bool SetSwapControl(int i) override
Set the number of vertical syncs required between frames.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
void PreferHighPerformanceAdapter()
Set preference for a high-performance or low-power device.
void Clean()
Clean up device contexts, rendering contexts, etc.
void PushContext() override
Ability to push and pop this window's context as the current context.
void CreateAWindow() override
Create a not-off-screen window.
void DestroyWindow() override
Destroy a not-off-screen window.
int * GetScreenSize() override
Get the current size of the screen in pixels.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetPosition(int a[2]) override
Set the position of the window.
void ShowCursor() override
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 x, int y) override
Set the position of the window.
void HideCursor() override
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void SetFullScreen(vtkTypeBool) override
Change the window to fill the entire screen.
int GetColorBufferSizes(int *rgba) override
Get the size of the color buffer.
void PreferLowPowerAdapter()
Set preference for a high-performance or low-power device.
vtkGetEnumMacro(PowerPreference, PowerPreferenceType)
Set/Get the power preference of the graphics adapter.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
void Finalize() override
Finalize the rendering window.
void PopContext() override
Ability to push and pop this window's context as the current context.
virtual void SetPosition(int x, int y)
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO