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 
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);
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;
327  void CreateOffScreenWindow(int width,int height);
330 
331 private:
333  void operator=(const vtkWin32OpenGLRenderWindow&) = delete;
334 };
335 
336 
337 #endif
vtkWin32OpenGLRenderWindow::GetGenericContext
void * GetGenericContext() override
Definition: vtkWin32OpenGLRenderWindow.h:142
vtkWin32OpenGLRenderWindow::Frame
void Frame(void) override
End the rendering process and display the image.
vtkWin32OpenGLRenderWindow::InitializeApplication
void InitializeApplication()
vtkWin32OpenGLRenderWindow::PrefFullScreen
virtual void PrefFullScreen(void)
Set the preferred window size to full screen.
vtkOpenGLRenderWindow::SetSize
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
vtkWin32OpenGLRenderWindow::ResizeWhileOffscreen
void ResizeWhileOffscreen(int xsize, int ysize)
vtkWin32OpenGLRenderWindow::PopContext
void PopContext() override
vtkWin32OpenGLRenderWindow::ShowCursor
void ShowCursor() override
vtkWin32OpenGLRenderWindow::SetCurrentCursor
void SetCurrentCursor(int) override
Change the shape of the cursor.
vtkWin32OpenGLRenderWindow
Definition: vtkWin32OpenGLRenderWindow.h:36
vtkWin32OpenGLRenderWindow::ReportCapabilities
const char * ReportCapabilities() override
Get report of capabilities for the render window.
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
vtkWin32OpenGLRenderWindow::SetDeviceContext
void SetDeviceContext(HDC)
vtkWin32OpenGLRenderWindow::InitializeFromCurrentContext
bool InitializeFromCurrentContext() override
Initialize the render window from the information associated with the currently activated OpenGL cont...
vtkWin32OpenGLRenderWindow::SetFullScreen
void SetFullScreen(vtkTypeBool) override
Change the window to fill the entire screen.
vtkWin32OpenGLRenderWindow::SetSwapControl
bool SetSwapControl(int i) override
Set the number of vertical syncs required between frames.
vtkWin32OpenGLRenderWindow::WindowIdReferenceCount
int WindowIdReferenceCount
Definition: vtkWin32OpenGLRenderWindow.h:321
vtkWin32OpenGLRenderWindow::WindowId
HWND WindowId
Definition: vtkWin32OpenGLRenderWindow.h:301
vtkWin32OpenGLRenderWindow::~vtkWin32OpenGLRenderWindow
~vtkWin32OpenGLRenderWindow()
vtkWin32OpenGLRenderWindow::ContextId
HGLRC ContextId
Definition: vtkWin32OpenGLRenderWindow.h:298
vtkWin32OpenGLRenderWindow::ApplicationInstance
HINSTANCE ApplicationInstance
Definition: vtkWin32OpenGLRenderWindow.h:295
vtkWin32OpenGLRenderWindow::VTKRegisterClass
void VTKRegisterClass()
vtkWin32OpenGLRenderWindow::SetParentId
void SetParentId(void *foo) override
Definition: vtkWin32OpenGLRenderWindow.h:175
vtkWin32OpenGLRenderWindow::SetSize
void SetSize(int a[2]) override
Set the size of the window in screen coordinates in pixels.
Definition: vtkWin32OpenGLRenderWindow.h:92
vtkWin32OpenGLRenderWindow::WndProc
static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
vtkWin32OpenGLRenderWindow::MessageProc
virtual LRESULT MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
vtkWin32OpenGLRenderWindow::SetCursorPosition
void SetCursorPosition(int x, int y) override
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
vtkWin32OpenGLRenderWindow::GetEventPending
int GetEventPending() override
Check to see if a mouse button has been pressed or mouse wheel activated.
vtkX3D::height
@ height
Definition: vtkX3D.h:254
vtkWin32OpenGLRenderWindow::OldPalette
HPALETTE OldPalette
Definition: vtkWin32OpenGLRenderWindow.h:297
vtkWin32OpenGLRenderWindow::GetScreenSize
int * GetScreenSize() override
Get the current size of the screen in pixels.
vtkWin32OpenGLRenderWindow::Clean
void Clean()
Clean up device contexts, rendering contexts, etc.
vtkWin32OpenGLRenderWindow::SetStereoCapableWindow
void SetStereoCapableWindow(vtkTypeBool capable) override
Prescribe that the window be created in a stereo-capable mode.
vtkWin32OpenGLRenderWindow::SetDisplayId
void SetDisplayId(void *) override
Dummy stubs for vtkWindow API.
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkWin32OpenGLRenderWindow::SetContextId
void SetContextId(HGLRC)
vtkWin32OpenGLRenderWindow::OwnWindow
int OwnWindow
Definition: vtkWin32OpenGLRenderWindow.h:304
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:37
vtkWin32OpenGLRenderWindow::SetNextWindowId
void SetNextWindowId(void *arg) override
Set the window id of the new window once a WindowRemap is done.
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
vtkWin32OpenGLRenderWindow::DestroyWindow
void DestroyWindow() override
Destroy a not-off-screen window.
vtkWin32OpenGLRenderWindow::GetSize
int * GetSize() override
Get the current size of the window in pixels.
vtkWin32OpenGLRenderWindow::IsCurrent
bool IsCurrent() override
Tells if this window is the current OpenGL context for the calling thread.
vtkWin32OpenGLRenderWindow::IsDirect
int IsDirect() override
Is this render window using hardware acceleration? 0-false, 1-true.
vtkWin32OpenGLRenderWindow::DeviceContext
HDC DeviceContext
Definition: vtkWin32OpenGLRenderWindow.h:299
vtkWin32OpenGLRenderWindow::New
static vtkWin32OpenGLRenderWindow * New()
vtkWin32OpenGLRenderWindow::CreateAWindow
void CreateAWindow() override
Create a not-off-screen window.
vtkWin32OpenGLRenderWindow::CreateOffScreenWindow
void CreateOffScreenWindow(int width, int height)
vtkWin32OpenGLRenderWindow::CleanUpOffScreenRendering
void CleanUpOffScreenRendering(void)
vtkWin32OpenGLRenderWindow::GetWindowId
HWND GetWindowId()
Get the window id.
vtkWin32OpenGLRenderWindow::Finalize
void Finalize(void) override
Finalize the rendering window.
vtkWin32OpenGLRenderWindow::SetParentId
void SetParentId(HWND)
Set the window's parent id to a pre-existing window.
vtkWin32OpenGLRenderWindow::SetSize
void SetSize(int, int) override
Set the size of the window in pixels.
vtkWin32OpenGLRenderWindow::SetWindowId
void SetWindowId(HWND)
Set the window id to a pre-existing window.
vtkWin32OpenGLRenderWindow::WindowRemap
void WindowRemap(void) override
Remap the window.
vtkWin32OpenGLRenderWindow::SetupPalette
virtual void SetupPalette(HDC hDC)
Initialize OpenGL for this window.
vtkWin32OpenGLRenderWindow::GetGenericParentId
void * GetGenericParentId() override
Definition: vtkWin32OpenGLRenderWindow.h:141
vtkWin32OpenGLRenderWindow::DCStack
std::stack< HDC > DCStack
Definition: vtkWin32OpenGLRenderWindow.h:308
vtkWin32OpenGLRenderWindow::Start
void Start(void) override
Begin the rendering process.
vtkWin32OpenGLRenderWindow::Initialize
void Initialize(void) override
Initialize the rendering window.
vtkWin32OpenGLRenderWindow::vtkWin32OpenGLRenderWindow
vtkWin32OpenGLRenderWindow()
vtkWin32OpenGLRenderWindow::SetOffScreenRendering
void SetOffScreenRendering(vtkTypeBool offscreen) override
Override the default implementation so that we can actively switch between on and off screen renderin...
vtkWin32OpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkWin32OpenGLRenderWindow::SetupPixelFormatPaletteAndContext
virtual void SetupPixelFormatPaletteAndContext(HDC hDC, DWORD dwFlags, int debug, int bpp=16, int zbpp=16)
vtkWin32OpenGLRenderWindow::CursorHidden
int CursorHidden
Definition: vtkWin32OpenGLRenderWindow.h:318
vtkWin32OpenGLRenderWindow::CleanUpRenderers
void CleanUpRenderers()
vtkWin32OpenGLRenderWindow::HideCursor
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...
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:54
vtkWin32OpenGLRenderWindow::GetGenericDrawable
void * GetGenericDrawable() override
Definition: vtkWin32OpenGLRenderWindow.h:143
vtkWin32OpenGLRenderWindow::PushContext
void PushContext() override
Ability to push and pop this window's context as the current context.
vtkWin32OpenGLRenderWindow::MakeCurrent
void MakeCurrent() override
Make this windows OpenGL context the current context.
vtkWindow::SetPosition
virtual void SetPosition(int, int)
vtkWin32OpenGLRenderWindow::DetectDPI
bool DetectDPI() override
Attempt to detect and set the DPI of the display device by querying the system.
vtkWin32OpenGLRenderWindow::ForceMakeCurrent
int ForceMakeCurrent
Definition: vtkWin32OpenGLRenderWindow.h:319
vtkWin32OpenGLRenderWindow::MFChandledWindow
BOOL MFChandledWindow
Definition: vtkWin32OpenGLRenderWindow.h:300
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkWin32OpenGLRenderWindow::SetNextWindowId
void SetNextWindowId(HWND)
Set the window id of the new window once a WindowRemap is done.
vtkWin32OpenGLRenderWindow::WindowInitialize
virtual void WindowInitialize(void)
Create the window.
vtkWin32OpenGLRenderWindow::ContextStack
std::stack< HGLRC > ContextStack
Definition: vtkWin32OpenGLRenderWindow.h:307
vtkOpenGLRenderWindow.h