VTK  9.2.6
vtkWin32OpenGLRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: Visualization Toolkit
4 Module: vtkWin32OpenGL2RenderWindow.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 =========================================================================*/
27 #ifndef vtkWin32OpenGLRenderWindow_h
28 #define vtkWin32OpenGLRenderWindow_h
29 
30 #include "vtkOpenGLRenderWindow.h"
31 #include "vtkRenderingOpenGL2Module.h" // For export macro
32 #include <stack> // for ivar
33 
34 #include "vtkWindows.h" // For windows API
35 
36 class vtkIdList;
37 
38 class VTKRENDERINGOPENGL2_EXPORT vtkWin32OpenGLRenderWindow : public vtkOpenGLRenderWindow
39 {
40 public:
43  void PrintSelf(ostream& os, vtkIndent indent) override;
44 
48  void Frame(void) override;
49 
53  virtual void WindowInitialize(void);
54 
61  void Initialize(void) override;
62 
68  void Finalize(void) override;
69 
73  void SetFullScreen(vtkTypeBool) override;
74 
78  void WindowRemap(void) override;
79 
83  void SetShowWindow(bool val) override;
84 
88  virtual void PrefFullScreen(void);
89 
91 
99  void SetSize(int width, int height) override;
100  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
102 
107  int* GetSize() VTK_SIZEHINT(2) override;
108 
110 
115  void SetPosition(int x, int y) override;
116  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
118 
123  int* GetScreenSize() VTK_SIZEHINT(2) override;
124 
129  int* GetPosition() VTK_SIZEHINT(2) override;
130 
135  void SetWindowName(const char*) override;
136 
140  void SetIcon(vtkImageData* img) override;
141 
145  void SetWindowInfo(const char*) override;
146 
150  void SetNextWindowInfo(const char*) override;
151 
155  void SetParentInfo(const char*) override;
156 
157  void* GetGenericDisplayId() override { return (void*)this->ContextId; }
158  void* GetGenericWindowId() override { return (void*)this->WindowId; }
159  void* GetGenericParentId() override { return (void*)this->ParentId; }
160  void* GetGenericContext() override { return (void*)this->DeviceContext; }
161  void* GetGenericDrawable() override { return (void*)this->WindowId; }
162  void SetDisplayId(void*) override;
163 
167  HWND GetWindowId();
168 
170 
173  void SetWindowId(HWND);
174  void SetWindowId(void* foo) override { this->SetWindowId((HWND)foo); }
176 
181  bool InitializeFromCurrentContext() override;
182 
186  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
187 
189 
192  void SetParentId(HWND);
193  void SetParentId(void* foo) override { this->SetParentId((HWND)foo); }
195 
196  void SetContextId(HGLRC); // hsr
197  void SetDeviceContext(HDC); // hsr
198 
202  void SetNextWindowId(HWND);
203 
209  void SetNextWindowId(void* arg) override;
210 
217  void SetStereoCapableWindow(vtkTypeBool capable) override;
218 
222  void MakeCurrent() override;
223 
227  void ReleaseCurrent() override;
228 
232  bool IsCurrent() override;
233 
237  const char* ReportCapabilities() override;
238 
242  vtkTypeBool IsDirect() override;
243 
249  vtkTypeBool GetEventPending() override;
250 
252 
255  virtual void SetupPalette(HDC hDC);
256  virtual void SetupPixelFormatPaletteAndContext(
257  HDC hDC, DWORD dwFlags, int debug, int bpp = 16, int zbpp = 16);
259 
263  void Clean();
264 
266 
272  void HideCursor() override;
273  void ShowCursor() override;
274  void SetCursorPosition(int x, int y) override;
276 
280  void SetCurrentCursor(int) override;
281 
282  bool DetectDPI() override;
283 
285 
292  void PushContext() override;
293  void PopContext() override;
295 
305  bool SetSwapControl(int i) override;
306 
307 protected:
309  ~vtkWin32OpenGLRenderWindow() override;
310 
312  HPALETTE Palette;
313  HPALETTE OldPalette;
314  HGLRC ContextId;
317  HWND WindowId;
318  HWND ParentId;
324 
325  std::stack<HGLRC> ContextStack;
326  std::stack<HDC> DCStack;
327 
328  // message handler
329  virtual LRESULT MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
330 
331  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
334 
336  void ResizeWhileOffscreen(int xsize, int ysize);
337  void CreateAWindow() override;
338  void DestroyWindow() override;
339  void InitializeApplication();
340  void CleanUpRenderers();
341  void VTKRegisterClass();
342 
343 private:
345  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
346 };
347 
348 #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:69
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:39
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
topologically and geometrically regular array of data
Definition: vtkImageData.h:53
list of point or cell ids
Definition: vtkIdList.h:33
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:105
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 MakeCurrent()
Make the window current.
Definition: vtkWindow.h:246
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:222
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:252
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 Initialize(void)
Initialize the rendering window.
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.