VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Rendering/OpenGL2/vtkWin32OpenGLRenderWindow.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   Visualization Toolkit
00004 Module:    vtkWin32OpenGL2RenderWindow.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 =========================================================================*/
00026 #ifndef vtkWin32OpenGL2RenderWindow_h
00027 #define vtkWin32OpenGL2RenderWindow_h
00028 
00029 #include "vtkRenderingOpenGL2Module.h" // For export macro
00030 #include "vtkOpenGLRenderWindow.h"
00031 
00032 #include "vtkWindows.h" // For windows API
00033 
00034 class vtkIdList;
00035 
00036 class VTKRENDERINGOPENGL2_EXPORT vtkWin32OpenGLRenderWindow : public vtkOpenGLRenderWindow
00037 {
00038 public:
00039   static vtkWin32OpenGLRenderWindow *New();
00040   vtkTypeMacro(vtkWin32OpenGLRenderWindow,vtkOpenGLRenderWindow);
00041   void PrintSelf(ostream& os, vtkIndent indent);
00042 
00044   virtual void Start(void);
00045 
00047   void Frame(void);
00048 
00050   virtual void WindowInitialize(void);
00051 
00056   virtual void Initialize(void);
00057 
00062   virtual void Finalize(void);
00063 
00065   virtual void SetFullScreen(int);
00066 
00068   virtual void WindowRemap(void);
00069 
00071   virtual void PrefFullScreen(void);
00072 
00074 
00075   virtual void SetSize(int,int);
00076   virtual void SetSize(int a[2]) {vtkOpenGLRenderWindow::SetSize(a);};
00078 
00080   virtual int *GetSize();
00081 
00083 
00084   virtual void SetPosition(int,int);
00085   virtual void SetPosition(int a[2]) {vtkOpenGLRenderWindow::SetPosition(a);};
00087 
00089   virtual int *GetScreenSize();
00090 
00092   virtual int *GetPosition();
00093 
00096   virtual void SetWindowName(const char *);
00097 
00099   void SetWindowInfo(char *);
00100 
00102   void SetNextWindowInfo(char *);
00103 
00105   void SetParentInfo(char *);
00106 
00107   virtual void *GetGenericDisplayId() {return (void *)this->ContextId;};
00108   virtual void *GetGenericWindowId()  {return (void *)this->WindowId;};
00109   virtual void *GetGenericParentId()  {return (void *)this->ParentId;};
00110   virtual void *GetGenericContext()   {return (void *)this->DeviceContext;};
00111   virtual void *GetGenericDrawable()  {return (void *)this->WindowId;};
00112   virtual void SetDisplayId(void *);
00113 
00115   virtual HWND  GetWindowId();
00116 
00118 
00119   virtual void  SetWindowId(HWND);
00120   void  SetWindowId(void *foo) {this->SetWindowId((HWND)foo);};
00122 
00125   virtual bool InitializeFromCurrentContext();
00126 
00128 
00129   virtual void  SetParentId(HWND);
00130   void  SetParentId(void *foo) {this->SetParentId((HWND)foo);};
00132 
00133   void  SetContextId(HGLRC);    // hsr
00134   void  SetDeviceContext(HDC);  // hsr
00135 
00137   virtual void  SetNextWindowId(HWND);
00138 
00141   virtual void SetNextWindowId(void *arg);
00142 
00147   virtual void SetStereoCapableWindow(int capable);
00148 
00150   void MakeCurrent();
00151 
00154   virtual bool IsCurrent();
00155 
00157   const char *ReportCapabilities();
00158 
00160   int SupportsOpenGL();
00161 
00163   int IsDirect();
00164 
00168   virtual  int GetEventPending();
00169 
00171 
00173   void SetupMemoryRendering(int x, int y, HDC prn);
00174   void SetupMemoryRendering(HBITMAP hbmp);
00175   void ResumeScreenRendering(void);
00176   HDC GetMemoryDC();
00177   unsigned char *GetMemoryData(){return this->MemoryData;};
00179 
00181 
00182   virtual void SetupPalette(HDC hDC);
00183   virtual void SetupPixelFormatPaletteAndContext(
00184     HDC hDC, DWORD dwFlags, int debug,
00185     int bpp=16, int zbpp=16);
00187 
00189   void Clean();
00190 
00192 
00195   void HideCursor();
00196   void ShowCursor();
00197   void SetCursorPosition(int x, int y);
00199 
00201   virtual void SetCurrentCursor(int);
00202 
00205   virtual void SetOffScreenRendering(int offscreen);
00206 
00207 protected:
00208   vtkWin32OpenGLRenderWindow();
00209   ~vtkWin32OpenGLRenderWindow();
00210 
00211   HINSTANCE ApplicationInstance;
00212   HPALETTE  Palette;
00213   HPALETTE  OldPalette;
00214   HGLRC     ContextId;
00215   HDC       DeviceContext;
00216   BOOL      MFChandledWindow;
00217   HWND      WindowId;
00218   HWND      ParentId;
00219   HWND      NextWindowId;
00220   int       OwnWindow;
00221   int       ScreenSize[2];
00222 
00223   // the following is used to support rendering into memory
00224   BITMAPINFO MemoryDataHeader;
00225   HBITMAP MemoryBuffer;
00226   unsigned char *MemoryData;    // the data in the DIBSection
00227   HDC MemoryHdc;
00228 
00229   int ScreenMapped;
00230   int ScreenWindowSize[2];
00231   HDC ScreenDeviceContext;
00232   int ScreenDoubleBuffer;
00233   HGLRC ScreenContextId;
00234 
00235   int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
00236 
00237   // message handler
00238   virtual LRESULT MessageProc(HWND hWnd, UINT message,
00239                               WPARAM wParam, LPARAM lParam);
00240 
00241   static LRESULT APIENTRY WndProc(HWND hWnd, UINT message,
00242                                   WPARAM wParam, LPARAM lParam);
00243   int CursorHidden;
00244   int ForceMakeCurrent;
00245 
00246   char   *Capabilities;
00247   int WindowIdReferenceCount;
00248   void ResizeWhileOffscreen(int xsize, int ysize);
00249   virtual void CreateAWindow();
00250   virtual void DestroyWindow();
00251   void InitializeApplication();
00252   void CleanUpOffScreenRendering(void);
00253   void CreateOffScreenDC(int xsize, int ysize, HDC aHdc);
00254   void CreateOffScreenDC(HBITMAP hbmp, HDC aHdc);
00255   void CreateOffScreenWindow(int width,int height);
00256   void SaveScreenRendering();
00257   void CleanUpRenderers();
00258 
00259 private:
00260   vtkWin32OpenGLRenderWindow(const vtkWin32OpenGLRenderWindow&);  // Not implemented.
00261   void operator=(const vtkWin32OpenGLRenderWindow&);  // Not implemented.
00262 };
00263 
00264 
00265 #endif