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);
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 
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 
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);
176  HDC GetMemoryDC();
177  unsigned char *GetMemoryData(){return this->MemoryData;};
179 
181 
182  virtual void SetupPalette(HDC hDC);
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 
203  virtual bool DetectDPI();
204 
207  virtual void SetOffScreenRendering(int offscreen);
208 
209 protected:
212 
213  HINSTANCE ApplicationInstance;
214  HPALETTE Palette;
215  HPALETTE OldPalette;
216  HGLRC ContextId;
217  HDC DeviceContext;
218  BOOL MFChandledWindow;
219  HWND WindowId;
220  HWND ParentId;
221  HWND NextWindowId;
222  int OwnWindow;
223  int ScreenSize[2];
224 
225  // the following is used to support rendering into memory
226  BITMAPINFO MemoryDataHeader;
227  HBITMAP MemoryBuffer;
228  unsigned char *MemoryData; // the data in the DIBSection
229  HDC MemoryHdc;
230 
231  int ScreenMapped;
232  int ScreenWindowSize[2];
233  HDC ScreenDeviceContext;
234  int ScreenDoubleBuffer;
235  HGLRC ScreenContextId;
236 
237  int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
238 
239  // message handler
240  virtual LRESULT MessageProc(HWND hWnd, UINT message,
241  WPARAM wParam, LPARAM lParam);
242 
243  static LRESULT APIENTRY WndProc(HWND hWnd, UINT message,
244  WPARAM wParam, LPARAM lParam);
245  int CursorHidden;
246  int ForceMakeCurrent;
247 
248  char *Capabilities;
249  int WindowIdReferenceCount;
250  void ResizeWhileOffscreen(int xsize, int ysize);
251  virtual void CreateAWindow();
252  virtual void DestroyWindow();
255  void CreateOffScreenDC(int xsize, int ysize, HDC aHdc);
256  void CreateOffScreenDC(HBITMAP hbmp, HDC aHdc);
260 
261 private:
262  vtkWin32OpenGLRenderWindow(const vtkWin32OpenGLRenderWindow&); // Not implemented.
263  void operator=(const vtkWin32OpenGLRenderWindow&); // Not implemented.
264 };
265 
266 
267 #endif
vtkWin32OpenGLRenderWindow::GetGenericDrawable
virtual void * GetGenericDrawable()
Definition: vtkWin32OpenGLRenderWindow.h:111
vtkWin32OpenGLRenderWindow::InitializeApplication
void InitializeApplication()
vtkWin32OpenGLRenderWindow::PrefFullScreen
virtual void PrefFullScreen(void)
vtkWin32OpenGLRenderWindow::ResizeWhileOffscreen
void ResizeWhileOffscreen(int xsize, int ysize)
vtkWindow::SetSize
virtual void SetSize(int, int)
vtkWin32OpenGLRenderWindow::Initialize
virtual void Initialize(void)
vtkWin32OpenGLRenderWindow
OpenGL rendering window.
Definition: vtkWin32OpenGLRenderWindow.h:38
vtkWin32OpenGLRenderWindow::SetCurrentCursor
virtual void SetCurrentCursor(int)
vtkWin32OpenGLRenderWindow::SetNextWindowInfo
void SetNextWindowInfo(char *)
vtkWin32OpenGLRenderWindow::SupportsOpenGL
int SupportsOpenGL()
vtkWin32OpenGLRenderWindow::GetEventPending
virtual int GetEventPending()
vtkWin32OpenGLRenderWindow::GetGenericDisplayId
virtual void * GetGenericDisplayId()
Definition: vtkWin32OpenGLRenderWindow.h:107
vtkWin32OpenGLRenderWindow::ReportCapabilities
const char * ReportCapabilities()
vtkWin32OpenGLRenderWindow::GetGenericParentId
virtual void * GetGenericParentId()
Definition: vtkWin32OpenGLRenderWindow.h:109
vtkWin32OpenGLRenderWindow::SetDeviceContext
void SetDeviceContext(HDC)
vtkWin32OpenGLRenderWindow::SetStereoCapableWindow
virtual void SetStereoCapableWindow(int capable)
vtkWin32OpenGLRenderWindow::SetWindowId
void SetWindowId(void *foo)
Definition: vtkWin32OpenGLRenderWindow.h:120
vtkWin32OpenGLRenderWindow::SetWindowName
virtual void SetWindowName(const char *)
vtkWin32OpenGLRenderWindow::Frame
void Frame(void)
vtkWin32OpenGLRenderWindow::ResumeScreenRendering
void ResumeScreenRendering(void)
vtkTypeMacro
#define vtkTypeMacro(thisClass, superclass)
Definition: vtkSetGet.h:642
vtkWin32OpenGLRenderWindow::~vtkWin32OpenGLRenderWindow
~vtkWin32OpenGLRenderWindow()
vtkgl::x
GLint GLint GLint GLint GLint x
Definition: vtkgl.h:11318
vtkWin32OpenGLRenderWindow::GetMemoryDC
HDC GetMemoryDC()
vtkWin32OpenGLRenderWindow::IsDirect
int IsDirect()
vtkWin32OpenGLRenderWindow::SetNextWindowId
virtual void SetNextWindowId(void *arg)
vtkWin32OpenGLRenderWindow::WindowRemap
virtual void WindowRemap(void)
vtkWin32OpenGLRenderWindow::SetCursorPosition
void SetCursorPosition(int x, int y)
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)
vtkgl::message
GLsizei GLenum GLuint GLuint GLsizei GLchar * message
Definition: vtkgl.h:19240
vtkWin32OpenGLRenderWindow::SetupMemoryRendering
void SetupMemoryRendering(HBITMAP hbmp)
vtkWin32OpenGLRenderWindow::Start
virtual void Start(void)
vtkWin32OpenGLRenderWindow::GetSize
virtual int * GetSize()
vtkWin32OpenGLRenderWindow::SetParentId
virtual void SetParentId(HWND)
vtkWin32OpenGLRenderWindow::HideCursor
void HideCursor()
vtkWin32OpenGLRenderWindow::SetupMemoryRendering
void SetupMemoryRendering(int x, int y, HDC prn)
vtkWin32OpenGLRenderWindow::SetWindowId
virtual void SetWindowId(HWND)
vtkOpenGLRenderWindow.h
vtkWin32OpenGLRenderWindow::GetGenericContext
virtual void * GetGenericContext()
Definition: vtkWin32OpenGLRenderWindow.h:110
vtkgl::BOOL
const GLenum BOOL
Definition: vtkgl.h:11943
vtkWin32OpenGLRenderWindow::DetectDPI
virtual bool DetectDPI()
APIENTRY
#define APIENTRY
Definition: vtkgl.h:34
vtkWin32OpenGLRenderWindow::IsCurrent
virtual bool IsCurrent()
vtkWin32OpenGLRenderWindow::Clean
void Clean()
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:39
vtkWin32OpenGLRenderWindow::SetContextId
void SetContextId(HGLRC)
vtkWin32OpenGLRenderWindow::SetPosition
virtual void SetPosition(int, int)
vtkWin32OpenGLRenderWindow::Finalize
virtual void Finalize(void)
vtkWin32OpenGLRenderWindow::DestroyWindow
virtual void DestroyWindow()
vtkWin32OpenGLRenderWindow::SetOffScreenRendering
virtual void SetOffScreenRendering(int offscreen)
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:36
vtkWin32OpenGLRenderWindow::SetNextWindowId
virtual void SetNextWindowId(HWND)
vtkWin32OpenGLRenderWindow::SetFullScreen
virtual void SetFullScreen(int)
vtkWin32OpenGLRenderWindow::ShowCursor
void ShowCursor()
vtkWin32OpenGLRenderWindow::New
static vtkWin32OpenGLRenderWindow * New()
vtkWin32OpenGLRenderWindow::SetPosition
virtual void SetPosition(int a[2])
Definition: vtkWin32OpenGLRenderWindow.h:85
vtkWin32OpenGLRenderWindow::CreateOffScreenDC
void CreateOffScreenDC(int xsize, int ysize, HDC aHdc)
vtkgl::a
GLboolean GLboolean GLboolean GLboolean a
Definition: vtkgl.h:12312
vtkWin32OpenGLRenderWindow::CreateOffScreenWindow
void CreateOffScreenWindow(int width, int height)
vtkWin32OpenGLRenderWindow::CleanUpOffScreenRendering
void CleanUpOffScreenRendering(void)
vtkWin32OpenGLRenderWindow::SetSize
virtual void SetSize(int, int)
vtkgl::width
GLint GLint GLsizei width
Definition: vtkgl.h:11316
vtkWin32OpenGLRenderWindow::SetSize
virtual void SetSize(int a[2])
Definition: vtkWin32OpenGLRenderWindow.h:76
vtkWin32OpenGLRenderWindow::SetupPalette
virtual void SetupPalette(HDC hDC)
vtkWin32OpenGLRenderWindow::SetParentId
void SetParentId(void *foo)
Definition: vtkWin32OpenGLRenderWindow.h:130
vtkWin32OpenGLRenderWindow::GetWindowId
virtual HWND GetWindowId()
vtkWin32OpenGLRenderWindow::SetParentInfo
void SetParentInfo(char *)
vtkgl::y
GLint GLint GLint GLint GLint GLint y
Definition: vtkgl.h:11318
vtkWin32OpenGLRenderWindow::InitializeFromCurrentContext
virtual bool InitializeFromCurrentContext()
vtkWin32OpenGLRenderWindow::SaveScreenRendering
void SaveScreenRendering()
vtkWin32OpenGLRenderWindow::vtkWin32OpenGLRenderWindow
vtkWin32OpenGLRenderWindow()
vtkWin32OpenGLRenderWindow::MakeCurrent
void MakeCurrent()
vtkWin32OpenGLRenderWindow::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
vtkWin32OpenGLRenderWindow::CreateOffScreenDC
void CreateOffScreenDC(HBITMAP hbmp, HDC aHdc)
vtkWin32OpenGLRenderWindow::SetupPixelFormatPaletteAndContext
virtual void SetupPixelFormatPaletteAndContext(HDC hDC, DWORD dwFlags, int debug, int bpp=16, int zbpp=16)
vtkWin32OpenGLRenderWindow::GetMemoryData
unsigned char * GetMemoryData()
Definition: vtkWin32OpenGLRenderWindow.h:177
vtkWin32OpenGLRenderWindow::GetGenericWindowId
virtual void * GetGenericWindowId()
Definition: vtkWin32OpenGLRenderWindow.h:108
vtkWin32OpenGLRenderWindow::CleanUpRenderers
void CleanUpRenderers()
vtkOpenGLRenderWindow
OpenGL rendering window.
Definition: vtkOpenGLRenderWindow.h:41
vtkWindow::SetPosition
virtual void SetPosition(int, int)
vtkWin32OpenGLRenderWindow::GetPosition
virtual int * GetPosition()
vtkWin32OpenGLRenderWindow::SetDisplayId
virtual void SetDisplayId(void *)
vtkWin32OpenGLRenderWindow::CreateAWindow
virtual void CreateAWindow()
vtkWindows.h
vtkWin32OpenGLRenderWindow::SetWindowInfo
void SetWindowInfo(char *)
vtkWin32OpenGLRenderWindow::GetScreenSize
virtual int * GetScreenSize()
vtkWin32OpenGLRenderWindow::WindowInitialize
virtual void WindowInitialize(void)
vtkgl::height
GLint GLint GLsizei GLsizei height
Definition: vtkgl.h:11316