VTK  9.3.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 #include "vtkRenderingOpenGL2Module.h" // For export macro
20 #include <stack> // for ivar
21 
22 #include "vtkWindows.h" // For windows API
23 
24 VTK_ABI_NAMESPACE_BEGIN
25 class vtkIdList;
26 
27 class VTKRENDERINGOPENGL2_EXPORT vtkWin32OpenGLRenderWindow : public vtkOpenGLRenderWindow
28 {
29 public:
32  void PrintSelf(ostream& os, vtkIndent indent) override;
33 
37  void Frame() override;
38 
42  virtual void WindowInitialize();
43 
50  void Initialize() override;
51 
57  void Finalize() override;
58 
62  void SetFullScreen(vtkTypeBool) override;
63 
67  void WindowRemap() override;
68 
72  void SetShowWindow(bool val) override;
73 
77  virtual void PrefFullScreen();
78 
80 
88  void SetSize(int width, int height) override;
89  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
91 
96  int* GetSize() VTK_SIZEHINT(2) override;
97 
99 
104  void SetPosition(int x, int y) override;
105  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
107 
112  int* GetScreenSize() VTK_SIZEHINT(2) override;
113 
118  int* GetPosition() VTK_SIZEHINT(2) override;
119 
124  void SetWindowName(const char*) override;
125 
129  void SetIcon(vtkImageData* img) override;
130 
134  void SetWindowInfo(const char*) override;
135 
139  void SetNextWindowInfo(const char*) override;
140 
144  void SetParentInfo(const char*) override;
145 
146  void* GetGenericDisplayId() override { return (void*)this->ContextId; }
147  void* GetGenericWindowId() override { return (void*)this->WindowId; }
148  void* GetGenericParentId() override { return (void*)this->ParentId; }
149  void* GetGenericContext() override { return (void*)this->DeviceContext; }
150  void* GetGenericDrawable() override { return (void*)this->WindowId; }
151  void SetDisplayId(void*) override;
152 
156  HWND GetWindowId();
157 
159 
162  void SetWindowId(HWND);
163  void SetWindowId(void* foo) override { this->SetWindowId((HWND)foo); }
165 
170  bool InitializeFromCurrentContext() override;
171 
175  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
176 
178 
181  void SetParentId(HWND);
182  void SetParentId(void* foo) override { this->SetParentId((HWND)foo); }
184 
185  void SetContextId(HGLRC); // hsr
186  void SetDeviceContext(HDC); // hsr
187 
191  void SetNextWindowId(HWND);
192 
198  void SetNextWindowId(void* arg) override;
199 
206  void SetStereoCapableWindow(vtkTypeBool capable) override;
207 
211  void MakeCurrent() override;
212 
216  void ReleaseCurrent() override;
217 
221  bool IsCurrent() override;
222 
226  const char* ReportCapabilities() override;
227 
231  vtkTypeBool IsDirect() override;
232 
238  vtkTypeBool GetEventPending() override;
239 
241 
244  virtual void SetupPalette(HDC hDC);
245  virtual void SetupPixelFormatPaletteAndContext(
246  HDC hDC, DWORD dwFlags, int debug, int bpp = 16, int zbpp = 16);
248 
252  void Clean();
253 
255 
261  void HideCursor() override;
262  void ShowCursor() override;
263  void SetCursorPosition(int x, int y) override;
265 
269  void SetCurrentCursor(int) override;
270 
271  bool DetectDPI() override;
272 
274 
281  void PushContext() override;
282  void PopContext() override;
284 
294  bool SetSwapControl(int i) override;
295 
296 protected:
298  ~vtkWin32OpenGLRenderWindow() override;
299 
301  HPALETTE Palette;
302  HPALETTE OldPalette;
303  HGLRC ContextId;
306  HWND WindowId;
307  HWND ParentId;
313 
314  std::stack<HGLRC> ContextStack;
315  std::stack<HDC> DCStack;
316 
317  // message handler
318  virtual LRESULT MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
319 
320  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
323 
325  void ResizeWhileOffscreen(int xsize, int ysize);
326  void CreateAWindow() override;
327  void DestroyWindow() override;
328  void InitializeApplication();
329  void CleanUpRenderers();
330  void VTKRegisterClass();
331 
332 private:
334  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
335 };
336 
337 VTK_ABI_NAMESPACE_END
338 #endif
OpenGL rendering window.
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 HideCursor()
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
virtual void SetNextWindowId(void *)
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 void SetCurrentCursor(int)
Change the shape of the cursor.
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.
virtual void SetSize(int width, int height)
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
void SetWindowId(void *) override
Dummy stubs for vtkWindow API.
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:42
list of point or cell ids
Definition: vtkIdList.h:22
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...
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
virtual int * GetScreenSize()
Get the current size of the screen in pixels.
Definition: vtkWindow.h:94
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
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...
virtual void Initialize()
Initialize the rendering window.
virtual void MakeCurrent()
Make the window current.
Definition: vtkWindow.h:235
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:211
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:241
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 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.