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(vtkTypeBool) 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(const char *) override;
128 
132  void SetNextWindowInfo(const char *) override;
133 
137  void SetParentInfo(const 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 
168  bool GetPlatformSupportsRenderWindowSharing() override { return true; };
169 
171 
174  void SetParentId(HWND);
175  void SetParentId(void *foo) override {this->SetParentId((HWND)foo);}
177 
178  void SetContextId(HGLRC); // hsr
179  void SetDeviceContext(HDC); // hsr
180 
184  void SetNextWindowId(HWND);
185 
191  void SetNextWindowId(void *arg) override;
192 
199  void SetStereoCapableWindow(vtkTypeBool capable) override;
200 
204  void MakeCurrent() override;
205 
209  bool IsCurrent() override;
210 
214  const char *ReportCapabilities() override;
215 
219  int IsDirect() override;
220 
226  int GetEventPending() override;
227 
229 
232  virtual void SetupPalette(HDC hDC);
233  virtual void SetupPixelFormatPaletteAndContext(
234  HDC hDC, DWORD dwFlags, int debug,
235  int bpp=16, int zbpp=16);
237 
241  void Clean();
242 
244 
250  void HideCursor() override;
251  void ShowCursor() override;
252  void SetCursorPosition(int x, int y) override;
254 
258  void SetCurrentCursor(int) override;
259 
260  bool DetectDPI() override;
261 
266  void SetOffScreenRendering(vtkTypeBool offscreen) override;
267 
269 
276  void PushContext() override;
277  void PopContext() override;
279 
289  bool SetSwapControl(int i) override;
290 
291 protected:
294 
296  HPALETTE Palette;
297  HPALETTE OldPalette;
298  HGLRC ContextId;
301  HWND WindowId;
302  HWND ParentId;
305  int ScreenSize[2];
306 
307  std::stack<HGLRC> ContextStack;
308  std::stack<HDC> DCStack;
309 
310  int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
311 
312  // message handler
313  virtual LRESULT MessageProc(HWND hWnd, UINT message,
314  WPARAM wParam, LPARAM lParam);
315 
316  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message,
317  WPARAM wParam, LPARAM lParam);
320 
322  void ResizeWhileOffscreen(int xsize, int ysize);
323  void CreateAWindow() override;
324  void DestroyWindow() override;
325  void InitializeApplication();
326  void CleanUpOffScreenRendering(void);
327  void CreateOffScreenWindow(int width,int height);
328  void CleanUpRenderers();
329  void VTKRegisterClass();
330 
331 private:
333  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
334 };
335 
336 
337 #endif
vtkWin32OpenGLRenderWindow::GetGenericContext
void * GetGenericContext() override
Definition: vtkWin32OpenGLRenderWindow.h:142
vtkOpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkOpenGLRenderWindow::SetSize
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
vtkWin32OpenGLRenderWindow
Definition: vtkWin32OpenGLRenderWindow.h:35
vtkRenderWindow::Start
virtual void Start()=0
Initialize the rendering process.
vtkWin32OpenGLRenderWindow::Palette
HPALETTE Palette
Definition: vtkWin32OpenGLRenderWindow.h:296
vtkWin32OpenGLRenderWindow::NextWindowId
HWND NextWindowId
Definition: vtkWin32OpenGLRenderWindow.h:303
vtkWin32OpenGLRenderWindow::SetWindowId
void SetWindowId(void *foo) override
Definition: vtkWin32OpenGLRenderWindow.h:156
vtkRenderWindow::ShowCursor
virtual void ShowCursor()=0
vtkOpenGLRenderWindow::SetSwapControl
virtual bool SetSwapControl(int)
Set the number of vertical syncs required between frames.
Definition: vtkOpenGLRenderWindow.h:424
vtkWindow::GetSize
virtual int * GetSize()
Set/Get the size of the window in screen coordinates in pixels.
vtkWin32OpenGLRenderWindow::WindowIdReferenceCount
int WindowIdReferenceCount
Definition: vtkWin32OpenGLRenderWindow.h:321
vtkWin32OpenGLRenderWindow::WindowId
HWND WindowId
Definition: vtkWin32OpenGLRenderWindow.h:301
vtkWin32OpenGLRenderWindow::ContextId
HGLRC ContextId
Definition: vtkWin32OpenGLRenderWindow.h:298
vtkRenderWindow::HideCursor
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...
vtkWin32OpenGLRenderWindow::ApplicationInstance
HINSTANCE ApplicationInstance
Definition: vtkWin32OpenGLRenderWindow.h:295
vtkRenderWindow::Finalize
virtual void Finalize()=0
Finalize the rendering process.
vtkRenderWindow::SetFullScreen
virtual void SetFullScreen(vtkTypeBool)=0
Turn on/off rendering full screen window size.
vtkWindow::SetOffScreenRendering
virtual void SetOffScreenRendering(vtkTypeBool)
Create a window in memory instead of on the screen.
vtkRenderWindow::SetDisplayId
void SetDisplayId(void *) override=0
Dummy stubs for vtkWindow API.
vtkWindow::GetScreenSize
virtual int * GetScreenSize()=0
Get the current size of the screen in pixels.
vtkRenderWindow::IsCurrent
virtual bool IsCurrent()=0
Tells if this window is the current graphics context for the calling thread.
vtkWin32OpenGLRenderWindow::SetParentId
void SetParentId(void *foo) override
Definition: vtkWin32OpenGLRenderWindow.h:175
vtkRenderWindow::SetWindowId
void SetWindowId(void *) override=0
vtkWindow::DetectDPI
virtual bool DetectDPI()
Attempt to detect and set the DPI of the display device by querying the system.
Definition: vtkWindow.h:168
vtkWin32OpenGLRenderWindow::SetSize
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
Definition: vtkWin32OpenGLRenderWindow.h:92
vtkRenderWindow::WindowRemap
virtual void WindowRemap()=0
Remap the rendering window.
vtkOpenGLRenderWindow::PopContext
virtual void PopContext()
Definition: vtkOpenGLRenderWindow.h:398
vtkRenderWindow::SetParentId
void SetParentId(void *) override=0
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkWin32OpenGLRenderWindow::ParentId
HWND ParentId
Definition: vtkWin32OpenGLRenderWindow.h:302
vtkWin32OpenGLRenderWindow::CreatingOffScreenWindow
int CreatingOffScreenWindow
Definition: vtkWin32OpenGLRenderWindow.h:310
vtkX3D::height
Definition: vtkX3D.h:254
vtkWin32OpenGLRenderWindow::OldPalette
HPALETTE OldPalette
Definition: vtkWin32OpenGLRenderWindow.h:297
vtkOpenGLRenderWindow::InitializeFromCurrentContext
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkWin32OpenGLRenderWindow::OwnWindow
int OwnWindow
Definition: vtkWin32OpenGLRenderWindow.h:304
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkWin32OpenGLRenderWindow::GetGenericWindowId
void * GetGenericWindowId() override
Definition: vtkWin32OpenGLRenderWindow.h:140
vtkWin32OpenGLRenderWindow::GetPlatformSupportsRenderWindowSharing
bool GetPlatformSupportsRenderWindowSharing() override
Does this platform support render window data sharing.
Definition: vtkWin32OpenGLRenderWindow.h:168
vtkRenderWindow::SetCurrentCursor
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
vtkRenderWindow::MakeCurrent
void MakeCurrent() override=0
Attempt to make this window the current graphics context for the calling thread.
vtkWin32OpenGLRenderWindow::DeviceContext
HDC DeviceContext
Definition: vtkWin32OpenGLRenderWindow.h:299
vtkRenderWindow::SetStereoCapableWindow
virtual void SetStereoCapableWindow(vtkTypeBool capable)
vtkWin32OpenGLRenderWindow::GetGenericParentId
void * GetGenericParentId() override
Definition: vtkWin32OpenGLRenderWindow.h:141
vtkOpenGLRenderWindow::ReportCapabilities
const char * ReportCapabilities() override
Get report of capabilities for the render window.
vtkRenderWindow::SetCursorPosition
virtual void SetCursorPosition(int, int)
Definition: vtkRenderWindow.h:201
vtkWin32OpenGLRenderWindow::DCStack
std::stack< HDC > DCStack
Definition: vtkWin32OpenGLRenderWindow.h:308
vtkOpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
vtkRenderWindow::IsDirect
virtual int IsDirect()
Is this render window using hardware acceleration? 0-false, 1-true.
Definition: vtkRenderWindow.h:628
vtkWin32OpenGLRenderWindow::CursorHidden
int CursorHidden
Definition: vtkWin32OpenGLRenderWindow.h:318
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:53
vtkWin32OpenGLRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Definition: vtkWin32OpenGLRenderWindow.h:143
vtkWindow::SetPosition
virtual void SetPosition(int, int)
vtkRenderWindow::Frame
virtual void Frame()=0
A termination method performed at the end of the rendering process to do things like swapping buffers...
vtkRenderWindow::SetNextWindowId
virtual void SetNextWindowId(void *)=0
vtkRenderWindow::New
static vtkRenderWindow * New()
Construct an instance of vtkRenderWindow with its screen size set to 300x300, borders turned on,...
vtkWin32OpenGLRenderWindow::ForceMakeCurrent
int ForceMakeCurrent
Definition: vtkWin32OpenGLRenderWindow.h:319
vtkOpenGLRenderWindow::PushContext
virtual void PushContext()
Ability to push and pop this window's context as the current context.
Definition: vtkOpenGLRenderWindow.h:397
vtkWin32OpenGLRenderWindow::MFChandledWindow
BOOL MFChandledWindow
Definition: vtkWin32OpenGLRenderWindow.h:300
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkRenderWindow::GetEventPending
virtual int GetEventPending()=0
Check to see if a mouse button has been pressed.
vtkOpenGLRenderWindow::Initialize
virtual void Initialize(void)
Initialize the rendering window.
Definition: vtkOpenGLRenderWindow.h:366
vtkOpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()=0
Create a not-off-screen window.
vtkWin32OpenGLRenderWindow::ContextStack
std::stack< HGLRC > ContextStack
Definition: vtkWin32OpenGLRenderWindow.h:307
vtkOpenGLRenderWindow.h