VTK
vtkWin32OpenGLRenderWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkWin32OpenGLRenderWindow.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 =========================================================================*/
30 #ifndef vtkWin32OpenGLRenderWindow_h
31 #define vtkWin32OpenGLRenderWindow_h
32 
33 #include "vtkRenderingOpenGLModule.h" // For export macro
34 #include "vtkOpenGLRenderWindow.h"
35 
36 class vtkIdList;
37 
38 class VTKRENDERINGOPENGL_EXPORT vtkWin32OpenGLRenderWindow : public vtkOpenGLRenderWindow
39 {
40 public:
43  void PrintSelf(ostream& os, vtkIndent indent);
44 
48  virtual void Start(void);
49 
53  void Frame(void);
54 
58  virtual void WindowInitialize(void);
59 
66  virtual void Initialize(void);
67 
73  virtual void Finalize(void);
74 
78  virtual void SetFullScreen(int);
79 
83  virtual void WindowRemap(void);
84 
88  virtual void PrefFullScreen(void);
89 
93  virtual void SetSize(int width, int height);
94  virtual void SetSize(int a[2]) { vtkOpenGLRenderWindow::SetSize(a); }
95 
99  virtual int *GetSize();
100 
104  virtual void SetPosition(int x, int y);
105  virtual void SetPosition(int a[2]) { vtkOpenGLRenderWindow::SetPosition(a); }
106 
110  virtual int *GetScreenSize();
111 
115  virtual int *GetPosition();
116 
121  virtual void SetWindowName(const char*);
122 
126  void SetWindowInfo(char*);
127 
131  void SetNextWindowInfo(char*);
132 
136  void SetParentInfo(char*);
137 
138  virtual void *GetGenericDisplayId() { return (void*)this->ContextId; }
139  virtual void *GetGenericWindowId() { return (void*)this->WindowId; }
140  virtual void *GetGenericParentId() { return (void*)this->ParentId; }
141  virtual void *GetGenericContext() { return (void*)this->DeviceContext; }
142  virtual void *GetGenericDrawable() { return (void*)this->WindowId; }
143  virtual void SetDisplayId(void*);
144 
148  virtual HWND GetWindowId();
149 
153  virtual void SetWindowId(HWND);
154  void SetWindowId(void *foo) { this->SetWindowId((HWND)foo); }
155 
160  virtual bool InitializeFromCurrentContext();
161 
165  virtual void SetParentId(HWND);
166  void SetParentId(void *foo) { this->SetParentId((HWND)foo); }
167 
171  void SetContextId(HGLRC);
172 
176  void SetDeviceContext(HDC);
177 
181  virtual void SetNextWindowId(HWND);
182 
188  virtual void SetNextWindowId(void *arg);
189 
196  virtual void SetStereoCapableWindow(int capable);
197 
201  void MakeCurrent();
202 
206  virtual bool IsCurrent();
207 
211  const char *ReportCapabilities();
212 
216  int SupportsOpenGL();
217 
221  int IsDirect();
222 
228  virtual int GetEventPending();
229 
231 
236  void SetupMemoryRendering(int x, int y, HDC prn);
237  void SetupMemoryRendering(HBITMAP hbmp);
238  void ResumeScreenRendering(void);
239  HDC GetMemoryDC();
240  unsigned char *GetMemoryData() { return this->MemoryData; }
242 
244 
247  virtual void SetupPalette(HDC hDC);
248  virtual void SetupPixelFormat(HDC hDC, DWORD dwFlags, int debug,
249  int bpp = 16, int zbpp = 16);
251 
255  void Clean();
256 
258 
262  void HideCursor();
263  void ShowCursor();
265 
268  void SetCursorPosition(int x, int y);
269 
273  virtual void SetCurrentCursor(int);
274 
275  virtual bool DetectDPI();
276 
281  virtual void SetOffScreenRendering(int offscreen);
282 
283 protected:
286 
288  HPALETTE Palette;
289  HPALETTE OldPalette;
290  HGLRC ContextId;
293  HWND WindowId;
294  HWND ParentId;
297  int ScreenSize[2];
298 
299  // the following is used to support rendering into memory
300  BITMAPINFO MemoryDataHeader;
301  HBITMAP MemoryBuffer;
302  unsigned char *MemoryData; // the data in the DIBSection
304 
306  int ScreenWindowSize[2];
310 
311  int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
312 
313  // message handler
314  virtual LRESULT MessageProc(HWND hWnd, UINT message,
315  WPARAM wParam, LPARAM lParam);
316 
317  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message,
318  WPARAM wParam, LPARAM lParam);
319 
322 
325  void ResizeWhileOffscreen(int xsize, int ysize);
326  virtual void CreateAWindow();
327  virtual void DestroyWindow();
328  void InitializeApplication();
329  void CleanUpOffScreenRendering(void);
330  void CreateOffScreenDC(int xsize, int ysize, HDC aHdc);
331  void CreateOffScreenDC(HBITMAP hbmp, HDC aHdc);
332  void CreateOffScreenWindow(int width, int height);
333  void SaveScreenRendering();
334  void CleanUpRenderers();
335 
336 private:
337  vtkWin32OpenGLRenderWindow(const vtkWin32OpenGLRenderWindow&) VTK_DELETE_FUNCTION;
338  void operator=(const vtkWin32OpenGLRenderWindow&) VTK_DELETE_FUNCTION;
339 };
340 
341 #endif
OpenGL rendering window.
virtual void SetOffScreenRendering(int)
Create a window in memory instead of on the screen.
virtual void Finalize()=0
Finalize the rendering process.
unsigned char * GetMemoryData()
These methods can be used by MFC applications to support print preview and printing, or more general rendering into memory.
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...
virtual void SetPosition(int a[2])
Set/Get the position in screen coordinates of the rendering window.
void SetWindowId(void *foo)
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...
virtual int * GetScreenSize()=0
Get the current size of the screen in pixels.
virtual void * GetGenericDrawable()
Dummy stubs for vtkWindow API.
virtual void SetCurrentCursor(int)
Change the shape of the cursor.
virtual void SetNextWindowInfo(char *)=0
Dummy stubs for vtkWindow API.
virtual void SetFullScreen(int)=0
Turn on/off rendering full screen window size.
virtual int GetEventPending()=0
Check to see if a mouse button has been pressed.
virtual void * GetGenericParentId()
Dummy stubs for vtkWindow API.
virtual void * GetGenericContext()
Dummy stubs for vtkWindow API.
virtual void SetStereoCapableWindow(int 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:39
virtual void DestroyWindow()=0
Destroy a not-off-screen window.
void SetParentId(void *foo)
Dummy stubs for vtkWindow API.
list of point or cell ids
Definition: vtkIdList.h:36
void SetWindowInfo(char *) override=0
Dummy stubs for vtkWindow API.
virtual void * GetGenericDisplayId()
Dummy stubs for vtkWindow API.
int SupportsOpenGL() override
Does this render window support OpenGL? 0-false, 1-true.
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 int * GetPosition()
Set/Get the position in screen coordinates of the rendering window.
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:168
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 * GetGenericWindowId()
Dummy stubs for vtkWindow API.
void SetParentInfo(char *) override=0
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.
virtual void SetWindowName(const char *)
Get name of rendering window.
virtual void SetPosition(int, int)
Set/Get the position in screen coordinates of the rendering window.
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 SetSize(int a[2])
Set the size of the window in screen coordinates in pixels.
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...