VTK
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 "vtkRenderingOpenGL2Module.h" // For export macro
28 #include <stack> // for ivar
29 #include "vtkOpenGLRenderWindow.h"
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 Start(void) override;
46 
50  void Frame(void) override;
51 
55  virtual void WindowInitialize(void);
56 
63  void Initialize(void) override;
64 
70  void Finalize(void) override;
71 
75  void SetFullScreen(int) override;
76 
80  void WindowRemap(void) override;
81 
85  virtual void PrefFullScreen(void);
86 
88 
91  void SetSize(int,int) override;
92  void SetSize(int a[2]) override {vtkOpenGLRenderWindow::SetSize(a);};
94 
98  int *GetSize() VTK_SIZEHINT(2) override;
99 
101 
104  void SetPosition(int,int) override;
105  void SetPosition(int a[2]) override {vtkOpenGLRenderWindow::SetPosition(a);}
107 
111  int *GetScreenSize() VTK_SIZEHINT(2) override;
112 
116  int *GetPosition() VTK_SIZEHINT(2) override;
117 
122  void SetWindowName(const char *) override;
123 
127  void SetWindowInfo(char *) override;
128 
132  void SetNextWindowInfo(char *) override;
133 
137  void SetParentInfo(char *) override;
138 
139  void *GetGenericDisplayId() override {return (void *)this->ContextId;}
140  void *GetGenericWindowId() override {return (void *)this->WindowId;}
141  void *GetGenericParentId() override {return (void *)this->ParentId;}
142  void *GetGenericContext() override {return (void *)this->DeviceContext;}
143  void *GetGenericDrawable() override {return (void *)this->WindowId;}
144  void SetDisplayId(void *) override;
145 
149  HWND GetWindowId();
150 
152 
155  void SetWindowId(HWND);
156  void SetWindowId(void *foo) override {this->SetWindowId((HWND)foo);}
158 
163  bool InitializeFromCurrentContext() override;
164 
166 
169  void SetParentId(HWND);
170  void SetParentId(void *foo) override {this->SetParentId((HWND)foo);}
172 
173  void SetContextId(HGLRC); // hsr
174  void SetDeviceContext(HDC); // hsr
175 
179  void SetNextWindowId(HWND);
180 
186  void SetNextWindowId(void *arg) override;
187 
194  void SetStereoCapableWindow(int capable) override;
195 
199  void MakeCurrent() override;
200 
204  bool IsCurrent() override;
205 
209  const char *ReportCapabilities() override;
210 
214  int IsDirect() override;
215 
221  int GetEventPending() override;
222 
224 
227  virtual void SetupPalette(HDC hDC);
228  virtual void SetupPixelFormatPaletteAndContext(
229  HDC hDC, DWORD dwFlags, int debug,
230  int bpp=16, int zbpp=16);
232 
236  void Clean();
237 
239 
245  void HideCursor() override;
246  void ShowCursor() override;
247  void SetCursorPosition(int x, int y) override;
249 
253  void SetCurrentCursor(int) override;
254 
255  bool DetectDPI() override;
256 
261  void SetOffScreenRendering(int offscreen) override;
262 
264 
271  void PushContext() override;
272  void PopContext() override;
274 
284  bool SetSwapControl(int i) override;
285 
286 protected:
289 
291  HPALETTE Palette;
292  HPALETTE OldPalette;
293  HGLRC ContextId;
296  HWND WindowId;
297  HWND ParentId;
300  int ScreenSize[2];
301 
302  std::stack<HGLRC> ContextStack;
303  std::stack<HDC> DCStack;
304 
305  int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
306 
307  // message handler
308  virtual LRESULT MessageProc(HWND hWnd, UINT message,
309  WPARAM wParam, LPARAM lParam);
310 
311  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message,
312  WPARAM wParam, LPARAM lParam);
315 
317  void ResizeWhileOffscreen(int xsize, int ysize);
318  void CreateAWindow() override;
319  void DestroyWindow() override;
320  void InitializeApplication();
321  void CleanUpOffScreenRendering(void);
322  void CreateOffScreenWindow(int width,int height);
323  void CleanUpRenderers();
324  void VTKRegisterClass();
325 
326 private:
328  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
329 };
330 
331 
332 #endif
OpenGL rendering window.
virtual void Finalize()=0
Finalize the rendering process.
virtual void WindowRemap()=0
Remap the rendering window.
virtual void HideCursor()=0
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
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 int * GetScreenSize()=0
Get the current size of the screen in pixels.
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
void SetSize(int a[2]) override
Set the size of the window in pixels.
virtual int GetEventPending()=0
Check to see if a mouse button has been pressed.
virtual void SetStereoCapableWindow(vtkTypeBool capable)
Prescribe that the window be created in a stereo-capable mode.
virtual int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
virtual bool IsCurrent()=0
Tells if this window is the current graphics context for the calling thread.
void SetWindowId(void *) override=0
Dummy stubs for vtkWindow API.
void SetDisplayId(void *) override=0
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
void * GetGenericWindowId() override
Dummy stubs for vtkWindow API.
virtual void SetNextWindowId(void *)=0
Dummy stubs for vtkWindow API.
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 SetOffScreenRendering(vtkTypeBool)
Create a window in memory instead of on the screen.
virtual void PushContext()
Ability to push and pop this window's context as the current context.
#define VTK_SIZEHINT(...)
virtual void Frame()=0
A termination method performed at the end of the rendering process to do things like swapping buffers...
const char * ReportCapabilities() override
Get report of capabilities for the render window.
virtual bool DetectDPI()
Attempt to detect and set the DPI of the display device by querying the system.
Definition: vtkWindow.h:165
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
void * GetGenericDrawable() override
Dummy stubs for vtkWindow API.
void SetParentId(void *) override=0
Dummy stubs for vtkWindow API.
virtual int * GetSize()
Set/Get the size of the window in screen coordinates in pixels.
virtual void SetFullScreen(vtkTypeBool)=0
Turn on/off rendering full screen window size.
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.
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
virtual void Start()=0
Initialize the rendering process.
void SetWindowId(void *foo) override
Set the window id to a pre-existing window.
virtual void SetPosition(int, int)
Set/Get the position in screen coordinates of the rendering 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.
void MakeCurrent() override=0
Attempt to make this window the current graphics context for the calling thread.
virtual void ShowCursor()=0
Hide or Show the mouse cursor, it is nice to be able to hide the default cursor if you want VTK to di...
void SetParentId(void *foo) override
Set the window's parent id to a pre-existing window.