VTK  9.0.1
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 =========================================================================*/
24 #ifndef vtkWin32OpenGLRenderWindow_h
25 #define vtkWin32OpenGLRenderWindow_h
26 
27 #include "vtkOpenGLRenderWindow.h"
28 #include "vtkRenderingOpenGL2Module.h" // For export macro
29 #include <stack> // for ivar
30 
31 #include "vtkWindows.h" // For windows API
32 
33 class vtkIdList;
34 
35 class VTKRENDERINGOPENGL2_EXPORT vtkWin32OpenGLRenderWindow : public vtkOpenGLRenderWindow
36 {
37 public:
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
45  void Frame(void) override;
46 
50  virtual void WindowInitialize(void);
51 
58  void Initialize(void) override;
59 
65  void Finalize(void) override;
66 
70  void SetFullScreen(vtkTypeBool) override;
71 
75  void WindowRemap(void) override;
76 
80  void SetShowWindow(bool val) override;
81 
85  virtual void PrefFullScreen(void);
86 
88 
96  void SetSize(int width, int height) override;
97  void SetSize(int a[2]) override { this->SetSize(a[0], a[1]); }
99 
104  int* GetSize() VTK_SIZEHINT(2) override;
105 
107 
112  void SetPosition(int x, int y) override;
113  void SetPosition(int a[2]) override { this->SetPosition(a[0], a[1]); }
115 
120  int* GetScreenSize() VTK_SIZEHINT(2) override;
121 
126  int* GetPosition() VTK_SIZEHINT(2) override;
127 
132  void SetWindowName(const char*) 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 
159  HWND GetWindowId();
160 
162 
165  void SetWindowId(HWND);
166  void SetWindowId(void* foo) override { this->SetWindowId((HWND)foo); }
168 
173  bool InitializeFromCurrentContext() override;
174 
178  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
179 
181 
184  void SetParentId(HWND);
185  void SetParentId(void* foo) override { this->SetParentId((HWND)foo); }
187 
188  void SetContextId(HGLRC); // hsr
189  void SetDeviceContext(HDC); // hsr
190 
194  void SetNextWindowId(HWND);
195 
201  void SetNextWindowId(void* arg) override;
202 
209  void SetStereoCapableWindow(vtkTypeBool capable) override;
210 
214  void MakeCurrent() override;
215 
219  bool IsCurrent() override;
220 
224  const char* ReportCapabilities() override;
225 
229  vtkTypeBool IsDirect() override;
230 
236  vtkTypeBool GetEventPending() override;
237 
239 
242  virtual void SetupPalette(HDC hDC);
243  virtual void SetupPixelFormatPaletteAndContext(
244  HDC hDC, DWORD dwFlags, int debug, int bpp = 16, int zbpp = 16);
246 
250  void Clean();
251 
253 
259  void HideCursor() override;
260  void ShowCursor() override;
261  void SetCursorPosition(int x, int y) override;
263 
267  void SetCurrentCursor(int) override;
268 
269  bool DetectDPI() override;
270 
272 
279  void PushContext() override;
280  void PopContext() override;
282 
292  bool SetSwapControl(int i) override;
293 
294 protected:
296  ~vtkWin32OpenGLRenderWindow() override;
297 
299  HPALETTE Palette;
300  HPALETTE OldPalette;
301  HGLRC ContextId;
304  HWND WindowId;
305  HWND ParentId;
308 
309  std::stack<HGLRC> ContextStack;
310  std::stack<HDC> DCStack;
311 
312  // message handler
313  virtual LRESULT MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
314 
315  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
318 
320  void ResizeWhileOffscreen(int xsize, int ysize);
321  void CreateAWindow() override;
322  void DestroyWindow() override;
323  void InitializeApplication();
324  void CleanUpRenderers();
325  void VTKRegisterClass();
326 
327 private:
329  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
330 };
331 
332 #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...
void MakeCurrent() override
Attempt to make this window the current graphics context for the calling thread.
void SetWindowInfo(const char *) override
Dummy stubs for vtkWindow API.
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
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 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.
int vtkTypeBool
Definition: vtkABI.h:69
virtual void SetStereoCapableWindow(vtkTypeBool capable)
Prescribe that the window be created in a stereo-capable mode.
virtual void SetNextWindowInfo(const char *)
Dummy stubs for vtkWindow API.
void SetWindowId(void *) override
Dummy stubs for vtkWindow API.
a simple class to control print indentation
Definition: vtkIndent.h:33
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
list of point or cell ids
Definition: vtkIdList.h:30
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:101
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 int * GetPosition()
Get the position (x and y) of the rendering window in screen coordinates (in pixels).
virtual void PushContext()
Ability to push and pop this window&#39;s context as the current context.
#define VTK_SIZEHINT(...)
void * GetGenericDisplayId() override
Dummy stubs for vtkWindow API.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
void SetSize(int width, int height) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels)...
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:212
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.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetWindowName(const char *)
Get name of rendering window.
void SetWindowId(void *foo) override
Set the window id to a pre-existing window.
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
void SetParentInfo(const char *) 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&#39;s parent id to a pre-existing window.