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 =========================================================================*/
26 #ifndef vtkWin32OpenGL2RenderWindow_h
27 #define vtkWin32OpenGL2RenderWindow_h
28 
29 #include "vtkRenderingOpenGL2Module.h" // For export macro
30 #include "vtkOpenGLRenderWindow.h"
31 
32 #include "vtkWindows.h" // For windows API
33 
34 class vtkIdList;
35 
36 class VTKRENDERINGOPENGL2_EXPORT vtkWin32OpenGLRenderWindow : public vtkOpenGLRenderWindow
37 {
38 public:
41  void PrintSelf(ostream& os, vtkIndent indent);
42 
44  virtual void Start(void);
45 
47  void Frame(void);
48 
50  virtual void WindowInitialize(void);
51 
56  virtual void Initialize(void);
57 
62  virtual void Finalize(void);
63 
65  virtual void SetFullScreen(int);
66 
68  virtual void WindowRemap(void);
69 
71  virtual void PrefFullScreen(void);
72 
74 
75  virtual void SetSize(int,int);
76  virtual void SetSize(int a[2]) {vtkOpenGLRenderWindow::SetSize(a);};
78 
80  virtual int *GetSize();
81 
83 
84  virtual void SetPosition(int,int);
85  virtual void SetPosition(int a[2]) {vtkOpenGLRenderWindow::SetPosition(a);};
87 
89  virtual int *GetScreenSize();
90 
92  virtual int *GetPosition();
93 
96  virtual void SetWindowName(const char *);
97 
99  void SetWindowInfo(char *);
100 
102  void SetNextWindowInfo(char *);
103 
105  void SetParentInfo(char *);
106 
107  virtual void *GetGenericDisplayId() {return (void *)this->ContextId;};
108  virtual void *GetGenericWindowId() {return (void *)this->WindowId;};
109  virtual void *GetGenericParentId() {return (void *)this->ParentId;};
110  virtual void *GetGenericContext() {return (void *)this->DeviceContext;};
111  virtual void *GetGenericDrawable() {return (void *)this->WindowId;};
112  virtual void SetDisplayId(void *);
113 
115  virtual HWND GetWindowId();
116 
118 
119  virtual void SetWindowId(HWND);
120  void SetWindowId(void *foo) {this->SetWindowId((HWND)foo);};
122 
125  virtual bool InitializeFromCurrentContext();
126 
128 
129  virtual void SetParentId(HWND);
130  void SetParentId(void *foo) {this->SetParentId((HWND)foo);};
132 
133  void SetContextId(HGLRC); // hsr
134  void SetDeviceContext(HDC); // hsr
135 
137  virtual void SetNextWindowId(HWND);
138 
141  virtual void SetNextWindowId(void *arg);
142 
147  virtual void SetStereoCapableWindow(int capable);
148 
150  void MakeCurrent();
151 
154  virtual bool IsCurrent();
155 
157  const char *ReportCapabilities();
158 
160  int SupportsOpenGL();
161 
163  int IsDirect();
164 
168  virtual int GetEventPending();
169 
171 
173  void SetupMemoryRendering(int x, int y, HDC prn);
174  void SetupMemoryRendering(HBITMAP hbmp);
175  void ResumeScreenRendering(void);
176  HDC GetMemoryDC();
177  unsigned char *GetMemoryData(){return this->MemoryData;};
179 
181 
182  virtual void SetupPalette(HDC hDC);
183  virtual void SetupPixelFormatPaletteAndContext(
184  HDC hDC, DWORD dwFlags, int debug,
185  int bpp=16, int zbpp=16);
187 
189  void Clean();
190 
192 
195  void HideCursor();
196  void ShowCursor();
197  void SetCursorPosition(int x, int y);
199 
201  virtual void SetCurrentCursor(int);
202 
205  virtual void SetOffScreenRendering(int offscreen);
206 
207 protected:
210 
211  HINSTANCE ApplicationInstance;
212  HPALETTE Palette;
213  HPALETTE OldPalette;
214  HGLRC ContextId;
215  HDC DeviceContext;
216  BOOL MFChandledWindow;
217  HWND WindowId;
218  HWND ParentId;
219  HWND NextWindowId;
220  int OwnWindow;
221  int ScreenSize[2];
222 
223  // the following is used to support rendering into memory
224  BITMAPINFO MemoryDataHeader;
225  HBITMAP MemoryBuffer;
226  unsigned char *MemoryData; // the data in the DIBSection
227  HDC MemoryHdc;
228 
229  int ScreenMapped;
230  int ScreenWindowSize[2];
231  HDC ScreenDeviceContext;
232  int ScreenDoubleBuffer;
233  HGLRC ScreenContextId;
234 
235  int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
236 
237  // message handler
238  virtual LRESULT MessageProc(HWND hWnd, UINT message,
239  WPARAM wParam, LPARAM lParam);
240 
241  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message,
242  WPARAM wParam, LPARAM lParam);
243  int CursorHidden;
244  int ForceMakeCurrent;
245 
246  char *Capabilities;
247  int WindowIdReferenceCount;
248  void ResizeWhileOffscreen(int xsize, int ysize);
249  virtual void CreateAWindow();
250  virtual void DestroyWindow();
251  void InitializeApplication();
252  void CleanUpOffScreenRendering(void);
253  void CreateOffScreenDC(int xsize, int ysize, HDC aHdc);
254  void CreateOffScreenDC(HBITMAP hbmp, HDC aHdc);
255  void CreateOffScreenWindow(int width,int height);
256  void SaveScreenRendering();
257  void CleanUpRenderers();
258 
259 private:
260  vtkWin32OpenGLRenderWindow(const vtkWin32OpenGLRenderWindow&); // Not implemented.
261  void operator=(const vtkWin32OpenGLRenderWindow&); // Not implemented.
262 };
263 
264 
265 #endif
OpenGL rendering window.
virtual void SetOffScreenRendering(int)
virtual void Finalize()=0
virtual void SetWindowInfo(char *)=0
virtual void WindowRemap()=0
void PrintSelf(ostream &os, vtkIndent indent)
virtual void HideCursor()=0
static vtkRenderWindow * New()
virtual int * GetScreenSize()=0
virtual void SetWindowId(void *)=0
virtual void SetCurrentCursor(int)
virtual void SetNextWindowInfo(char *)=0
virtual void SetFullScreen(int)=0
const GLenum BOOL
Definition: vtkgl.h:11943
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:632
virtual int GetEventPending()=0
virtual void SetSize(int, int)
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316
GLsizei GLenum GLuint GLuint GLsizei GLchar * message
Definition: vtkgl.h:19240
virtual void SetStereoCapableWindow(int capable)
virtual const char * ReportCapabilities()
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
virtual int IsDirect()
virtual int SupportsOpenGL()
virtual void SetParentInfo(char *)=0
virtual bool IsCurrent()=0
virtual void SetParentId(void *)=0
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void DestroyWindow()=0
list of point or cell ids
Definition: vtkIdList.h:35
virtual void SetDisplayId(void *)=0
GLint GLint GLsizei width
Definition: vtkgl.h:11316
virtual void MakeCurrent()=0
virtual void SetNextWindowId(void *)=0
virtual void SetCursorPosition(int, int)
virtual int * GetPosition()
virtual void Frame()=0
virtual int * GetSize()
GLboolean GLboolean GLboolean GLboolean a
Definition: vtkgl.h:12312
virtual bool InitializeFromCurrentContext()
virtual void Start()=0
virtual void SetWindowName(const char *)
virtual void SetPosition(int, int)
virtual void CreateAWindow()=0
virtual void ShowCursor()=0
#define APIENTRY
Definition: vtkgl.h:34