VTK  9.7.1
vtkWin32OpenGLRenderWindow.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
15 #ifndef vtkWin32OpenGLRenderWindow_h
16 #define vtkWin32OpenGLRenderWindow_h
17 
18 #include "vtkOpenGLRenderWindow.h"
19 
20 #include "vtkRenderingOpenGL2Module.h" // For export macro
21 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
22 #include <stack> // for ivar
23 
24 #include "vtkWindows.h" // For windows API
25 
26 VTK_ABI_NAMESPACE_BEGIN
27 class vtkIdList;
28 
29 class VTKRENDERINGOPENGL2_EXPORT VTK_MARSHALAUTO vtkWin32OpenGLRenderWindow
30  : public vtkOpenGLRenderWindow
31 {
32 public:
35  void PrintSelf(ostream& os, vtkIndent indent) override;
36 
40  void Frame() override;
41 
45  virtual void WindowInitialize();
46 
53  void Initialize() override;
54 
60  void Finalize() override;
61 
65  void SetFullScreen(vtkTypeBool) override;
66 
70  void WindowRemap() override;
71 
75  void SetShowWindow(bool val) override;
76 
80  virtual void PrefFullScreen();
81 
83 
91  void SetSize(int width, int height) override;
92  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
94 
99  int* GetSize() VTK_SIZEHINT(2) override;
100 
102 
107  void SetPosition(int x, int y) override;
108  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
110 
115  int* GetScreenSize() VTK_SIZEHINT(2) override;
116 
121  int* GetPosition() VTK_SIZEHINT(2) override;
122 
127  void SetWindowName(const char*) override;
128 
132  void SetIcon(vtkImageData* img) override;
133 
137  void SetWindowInfo(const char*) override;
138 
142  void SetNextWindowInfo(const char*) override;
143 
147  void SetParentInfo(const char*) override;
148 
149  void* GetGenericDisplayId() override { return (void*)this->ContextId; }
150  void* GetGenericWindowId() override { return (void*)this->WindowId; }
151  void* GetGenericParentId() override { return (void*)this->ParentId; }
152  void* GetGenericContext() override { return (void*)this->DeviceContext; }
153  void* GetGenericDrawable() override { return (void*)this->WindowId; }
154  void SetDisplayId(void*) override;
155 
160  HWND GetWindowId();
161 
163 
167  void SetWindowId(HWND);
169  void SetWindowId(void* foo) override { this->SetWindowId((HWND)foo); }
171 
176  bool InitializeFromCurrentContext() override;
177 
181  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
182 
184 
187  void SetParentId(HWND);
188  void SetParentId(void* foo) override { this->SetParentId((HWND)foo); }
190 
191  void SetContextId(HGLRC); // hsr
192  void SetDeviceContext(HDC); // hsr
193 
197  void SetNextWindowId(HWND);
198 
204  void SetNextWindowId(void* arg) override;
205 
212  void SetStereoCapableWindow(vtkTypeBool capable) override;
213 
217  void MakeCurrent() override;
218 
222  void ReleaseCurrent() override;
223 
227  bool IsCurrent() override;
228 
232  const char* ReportCapabilities() override;
233 
237  vtkTypeBool IsDirect() override;
238 
244  vtkTypeBool GetEventPending() override;
245 
247 
250  virtual void SetupPalette(HDC hDC);
251  virtual void SetupPixelFormatPaletteAndContext(
252  HDC hDC, DWORD dwFlags, int debug, int bpp = 16, int zbpp = 16);
254 
258  void Clean();
259 
261 
267  void HideCursor() override;
268  void ShowCursor() override;
269  void SetCursorPosition(int x, int y) override;
271 
275  void SetCurrentCursor(int) override;
276 
277  bool DetectDPI() override;
278 
280 
287  void PushContext() override;
288  void PopContext() override;
290 
300  bool SetSwapControl(int i) override;
301 
302 protected:
304  ~vtkWin32OpenGLRenderWindow() override;
305 
307  HPALETTE Palette;
308  HPALETTE OldPalette;
309  HGLRC ContextId;
312  HWND WindowId;
313  HWND ParentId;
319 
320  std::stack<HGLRC> ContextStack;
321  std::stack<HDC> DCStack;
322 
323  // message handler
324  virtual LRESULT MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
325 
326  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
329 
331  void ResizeWhileOffscreen(int xsize, int ysize);
332  void CreateAWindow() override;
333  void DestroyWindow() override;
334  void InitializeApplication();
335  void CleanUpRenderers();
336  void VTKRegisterClass();
337 
338 private:
340  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
341 };
342 
343 VTK_ABI_NAMESPACE_END
344 #endif
OpenGL rendering window.
virtual void SetCursorPosition(int, int)
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:297
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.
virtual void WindowRemap()
Remap the rendering window.
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
virtual void SetNextWindowId(void *)
Dummy stubs for vtkWindow API.
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
virtual bool IsCurrent()
Tells if this window is the current graphics context for the calling thread.
virtual void Finalize()
Finalize the rendering process.
void SetSize(int a[2]) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
virtual void SetShowWindow(bool)
Show or not Show the window.
void SetParentId(void *) override
Dummy stubs for vtkWindow API.
static const std::string DEFAULT_BASE_WINDOW_NAME
int vtkTypeBool
Definition: vtkABI.h:64
virtual void SetStereoCapableWindow(vtkTypeBool capable)
Prescribe that the window be created in a stereo-capable mode.
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)...
a simple class to control print indentation
Definition: vtkIndent.h:28
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
topologically and geometrically regular array of data
Definition: vtkImageData.h:45
list of point or cell ids
Definition: vtkIdList.h:25
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:110
void Initialize() override
Initialize the rendering window.
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
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.
void SetPosition(int a[2]) override
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual bool DetectDPI()
Attempt to detect and set the DPI of the display device by querying the system.
Definition: vtkWindow.h:229
#define VTK_MARSHALEXCLUDE(reason)
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
void Frame() override
A termination method performed at the end of the rendering process to do things like swapping buffers...
virtual int * GetSize()
Get the size (width and height) of the rendering window in screen coordinates (in pixels)...
virtual vtkTypeBool GetEventPending()
Check to see if a mouse button has been pressed.
void * GetGenericContext() override
Dummy stubs for vtkWindow API.
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 SetWindowId(void *foo) override
Set the window id to a pre-existing window.
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
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
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 SetParentId(void *foo) override
Set the window's parent id to a pre-existing window.