VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/OpenGL/vtkWin32OpenGLRenderWindow.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkWin32OpenGLRenderWindow.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00032 #ifndef vtkWin32OpenGLRenderWindow_h
00033 #define vtkWin32OpenGLRenderWindow_h
00034 
00035 #include "vtkRenderingOpenGLModule.h" // For export macro
00036 #include "vtkOpenGLRenderWindow.h"
00037 
00038 class vtkIdList;
00039 
00040 class VTKRENDERINGOPENGL_EXPORT vtkWin32OpenGLRenderWindow : public vtkOpenGLRenderWindow
00041 {
00042 public:
00043   static vtkWin32OpenGLRenderWindow *New();
00044   vtkTypeMacro(vtkWin32OpenGLRenderWindow, vtkOpenGLRenderWindow);
00045   void PrintSelf(ostream& os, vtkIndent indent);
00046 
00048   virtual void Start(void);
00049 
00051   void Frame(void);
00052 
00054   virtual void WindowInitialize(void);
00055 
00060   virtual void Initialize(void);
00061 
00066   virtual void Finalize(void);
00067 
00069   virtual void SetFullScreen(int);
00070 
00072   virtual void WindowRemap(void);
00073 
00075   virtual void PrefFullScreen(void);
00076 
00078 
00079   virtual void SetSize(int width, int height);
00080   virtual void SetSize(int a[2]) { vtkOpenGLRenderWindow::SetSize(a); }
00082 
00084   virtual int *GetSize();
00085 
00087 
00088   virtual void SetPosition(int x, int y);
00089   virtual void SetPosition(int a[2]) { vtkOpenGLRenderWindow::SetPosition(a); }
00091 
00093   virtual int *GetScreenSize();
00094 
00096   virtual int *GetPosition();
00097 
00100   virtual void SetWindowName(const char*);
00101 
00103   void SetWindowInfo(char*);
00104 
00106   void SetNextWindowInfo(char*);
00107 
00109   void SetParentInfo(char*);
00110 
00111   //BTX
00112   virtual void *GetGenericDisplayId() { return (void*)this->ContextId; }
00113   virtual void *GetGenericWindowId()  { return (void*)this->WindowId; }
00114   virtual void *GetGenericParentId()  { return (void*)this->ParentId; }
00115   virtual void *GetGenericContext()   { return (void*)this->DeviceContext; }
00116   virtual void *GetGenericDrawable()  { return (void*)this->WindowId; }
00117   virtual void SetDisplayId(void*);
00118 
00120   virtual HWND GetWindowId();
00121 
00123 
00124   virtual void SetWindowId(HWND);
00125   void SetWindowId(void *foo) { this->SetWindowId((HWND)foo); }
00127 
00130   virtual bool InitializeFromCurrentContext();
00131 
00133 
00134   virtual void SetParentId(HWND);
00135   void SetParentId(void *foo) { this->SetParentId((HWND)foo); }
00137 
00139   void SetContextId(HGLRC);
00140 
00142   void SetDeviceContext(HDC);
00143 
00145   virtual void SetNextWindowId(HWND);
00146 
00149   virtual void SetNextWindowId(void *arg);
00150 
00151   //ETX
00152 
00157   virtual void SetStereoCapableWindow(int capable);
00158 
00160   void MakeCurrent();
00161 
00164   virtual bool IsCurrent();
00165 
00167   const char *ReportCapabilities();
00168 
00170   int SupportsOpenGL();
00171 
00173   int IsDirect();
00174 
00178   virtual  int GetEventPending();
00179 
00181 
00183   void SetupMemoryRendering(int x, int y, HDC prn);
00184   void SetupMemoryRendering(HBITMAP hbmp);
00185   void ResumeScreenRendering(void);
00186   HDC GetMemoryDC();
00187   unsigned char *GetMemoryData() { return this->MemoryData; }
00189 
00191 
00192   virtual void SetupPalette(HDC hDC);
00193   virtual void SetupPixelFormat(HDC hDC, DWORD dwFlags, int debug,
00194                                 int bpp = 16, int zbpp = 16);
00196 
00198   void Clean();
00199 
00201 
00203   void HideCursor();
00204   void ShowCursor();
00206 
00208   void SetCursorPosition(int x, int y);
00209 
00211   virtual void SetCurrentCursor(int);
00212 
00215   virtual void SetOffScreenRendering(int offscreen);
00216 
00217 protected:
00218   vtkWin32OpenGLRenderWindow();
00219   ~vtkWin32OpenGLRenderWindow();
00220 
00221   HINSTANCE ApplicationInstance;
00222   HPALETTE  Palette;
00223   HPALETTE  OldPalette;
00224   HGLRC     ContextId;
00225   HDC       DeviceContext;
00226   BOOL      MFChandledWindow;
00227   HWND      WindowId;
00228   HWND      ParentId;
00229   HWND      NextWindowId;
00230   int       OwnWindow;
00231   int       ScreenSize[2];
00232 
00233   // the following is used to support rendering into memory
00234   BITMAPINFO MemoryDataHeader;
00235   HBITMAP MemoryBuffer;
00236   unsigned char *MemoryData;    // the data in the DIBSection
00237   HDC MemoryHdc;
00238 
00239   int ScreenMapped;
00240   int ScreenWindowSize[2];
00241   HDC ScreenDeviceContext;
00242   int ScreenDoubleBuffer;
00243   HGLRC ScreenContextId;
00244 
00245   int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
00246 
00247   //BTX
00248   // message handler
00249   virtual LRESULT MessageProc(HWND hWnd, UINT message,
00250                               WPARAM wParam, LPARAM lParam);
00251 
00252   static LRESULT APIENTRY WndProc(HWND hWnd, UINT message,
00253                                   WPARAM wParam, LPARAM lParam);
00254   //ETX
00255   int CursorHidden;
00256   int ForceMakeCurrent;
00257 
00258   char   *Capabilities;
00259   int WindowIdReferenceCount;
00260   void ResizeWhileOffscreen(int xsize, int ysize);
00261   virtual void CreateAWindow();
00262   virtual void DestroyWindow();
00263   void InitializeApplication();
00264   void CleanUpOffScreenRendering(void);
00265   void CreateOffScreenDC(int xsize, int ysize, HDC aHdc);
00266   void CreateOffScreenDC(HBITMAP hbmp, HDC aHdc);
00267   void CreateOffScreenWindow(int width, int height);
00268   void SaveScreenRendering();
00269   void CleanUpRenderers();
00270 
00271 private:
00272   vtkWin32OpenGLRenderWindow(const vtkWin32OpenGLRenderWindow&);  // Not implemented.
00273   void operator=(const vtkWin32OpenGLRenderWindow&);  // Not implemented.
00274 };
00275 
00276 #endif