VTK  9.1.0
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 SetIcon(vtkImageData* img) override;
138 
142  void SetWindowInfo(const char*) override;
143 
147  void SetNextWindowInfo(const char*) override;
148 
152  void SetParentInfo(const char*) override;
153 
154  void* GetGenericDisplayId() override { return (void*)this->ContextId; }
155  void* GetGenericWindowId() override { return (void*)this->WindowId; }
156  void* GetGenericParentId() override { return (void*)this->ParentId; }
157  void* GetGenericContext() override { return (void*)this->DeviceContext; }
158  void* GetGenericDrawable() override { return (void*)this->WindowId; }
159  void SetDisplayId(void*) override;
160 
164  HWND GetWindowId();
165 
167 
170  void SetWindowId(HWND);
171  void SetWindowId(void* foo) override { this->SetWindowId((HWND)foo); }
173 
179 
183  bool GetPlatformSupportsRenderWindowSharing() override { return true; }
184 
186 
189  void SetParentId(HWND);
190  void SetParentId(void* foo) override { this->SetParentId((HWND)foo); }
192 
193  void SetContextId(HGLRC); // hsr
194  void SetDeviceContext(HDC); // hsr
195 
199  void SetNextWindowId(HWND);
200 
206  void SetNextWindowId(void* arg) override;
207 
214  void SetStereoCapableWindow(vtkTypeBool capable) override;
215 
219  void MakeCurrent() override;
220 
224  void ReleaseCurrent() override;
225 
229  bool IsCurrent() override;
230 
234  const char* ReportCapabilities() override;
235 
239  vtkTypeBool IsDirect() override;
240 
247 
249 
252  virtual void SetupPalette(HDC hDC);
254  HDC hDC, DWORD dwFlags, int debug, int bpp = 16, int zbpp = 16);
256 
260  void Clean();
261 
263 
269  void HideCursor() override;
270  void ShowCursor() override;
271  void SetCursorPosition(int x, int y) override;
273 
277  void SetCurrentCursor(int) override;
278 
279  bool DetectDPI() override;
280 
282 
289  void PushContext() override;
290  void PopContext() override;
292 
302  bool SetSwapControl(int i) override;
303 
304 protected:
307 
309  HPALETTE Palette;
310  HPALETTE OldPalette;
311  HGLRC ContextId;
314  HWND WindowId;
315  HWND ParentId;
321 
322  std::stack<HGLRC> ContextStack;
323  std::stack<HDC> DCStack;
324 
325  // message handler
326  virtual LRESULT MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
327 
328  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
331 
333  void ResizeWhileOffscreen(int xsize, int ysize);
334  void CreateAWindow() override;
335  void DestroyWindow() override;
339 
340 private:
342  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
343 };
344 
345 #endif
list of point or cell ids
Definition: vtkIdList.h:31
topologically and geometrically regular array of data
Definition: vtkImageData.h:48
a simple class to control print indentation
Definition: vtkIndent.h:34
OpenGL rendering window.
void DestroyWindow() override
Destroy a not-off-screen window.
void Clean()
Clean up device contexts, rendering contexts, etc.
static const std::string DEFAULT_BASE_WINDOW_NAME
virtual LRESULT MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
void SetWindowId(HWND)
Set the window id to a pre-existing window.
void SetWindowId(void *foo) override
Set the window id to a pre-existing window.
static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
void SetNextWindowId(void *arg) override
Set the window id of the new window once a WindowRemap is done.
virtual void PrefFullScreen(void)
Set the preferred window size to full screen.
void WindowRemap(void) override
Remap the window.
int * GetSize() override
Get the size (width and height) of the rendering window in screen coordinates (in pixels).
vtkTypeBool IsDirect() override
Is this render window using hardware acceleration? 0-false, 1-true.
void * GetGenericParentId() override
Dummy stubs for vtkWindow API.
~vtkWin32OpenGLRenderWindow() override
void Finalize(void) override
Finalize the rendering window.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool SetSwapControl(int i) override
Set the number of vertical syncs required between frames.
void SetFullScreen(vtkTypeBool) override
Change the window to fill the entire screen.
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 * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
vtkTypeBool GetEventPending() override
Check to see if a mouse button has been pressed or mouse wheel activated.
void SetShowWindow(bool val) override
Show or not Show the window.
HWND GetWindowId()
Get the window id.
void Frame(void) override
End the rendering process and display the image.
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 SetCursorPosition(int x, int y) override
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
bool DetectDPI() override
Attempt to detect and set the DPI of the display device by querying the system.
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
void PushContext() override
Ability to push and pop this window's context as the current context.
void SetCurrentCursor(int) override
Change the shape of the cursor.
virtual void WindowInitialize(void)
Create the window.
void SetSize(int a[2]) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
void SetStereoCapableWindow(vtkTypeBool capable) override
Prescribe that the window be created in a stereo-capable mode.
void PopContext() override
Ability to push and pop this window's context as the current context.
virtual void SetupPixelFormatPaletteAndContext(HDC hDC, DWORD dwFlags, int debug, int bpp=16, int zbpp=16)
Initialize OpenGL for this window.
void SetParentId(void *foo) override
Set the window's parent id to a pre-existing window.
void SetNextWindowId(HWND)
Set the window id of the new window once a WindowRemap is done.
const char * ReportCapabilities() override
Get report of capabilities for the render window.
static vtkWin32OpenGLRenderWindow * New()
bool IsCurrent() override
Tells if this window is the current OpenGL context for the calling thread.
int * GetScreenSize() override
Get the current size of the screen in pixels.
void * GetGenericContext() override
Dummy stubs for vtkWindow API.
void SetParentId(HWND)
Set the window's parent id to a pre-existing window.
void MakeCurrent() override
Make this windows OpenGL context the current context.
void SetPosition(int a[2]) override
Set the position (x and y) of the rendering window in screen coordinates (in pixels).
void SetSize(int width, int height) override
Set the size (width and height) of the rendering window in screen coordinates (in pixels).
void ResizeWhileOffscreen(int xsize, int ysize)
void Initialize(void) override
Initialize the rendering window.
void CreateAWindow() override
Create a not-off-screen window.
void ReleaseCurrent() override
Release the current context.
virtual void SetupPalette(HDC hDC)
Initialize OpenGL for this window.
@ height
Definition: vtkX3D.h:260
@ string
Definition: vtkX3D.h:496
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_SIZEHINT(...)