VTK
dox/Rendering/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 =========================================================================*/
00029 #ifndef __vtkWin32OpenGLRenderWindow_h
00030 #define __vtkWin32OpenGLRenderWindow_h
00031 
00032 #include "vtkOpenGLRenderWindow.h"
00033 
00034 class vtkIdList;
00035 
00036 class VTK_RENDERING_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   //BTX
00108   virtual void *GetGenericDisplayId() {return (void *)this->ContextId;};
00109   virtual void *GetGenericWindowId()  {return (void *)this->WindowId;};
00110   virtual void *GetGenericParentId()  {return (void *)this->ParentId;};
00111   virtual void *GetGenericContext()   {return (void *)this->DeviceContext;};
00112   virtual void *GetGenericDrawable()  {return (void *)this->WindowId;};
00113   virtual void SetDisplayId(void *);
00114 
00116 
00117   virtual HWND  GetWindowId();
00118   void  SetWindowId(void *foo) {this->SetWindowId((HWND)foo);};
00120 
00122   virtual void  SetWindowId(HWND);
00123   
00125 
00126   virtual void  SetParentId(HWND);
00127   void  SetParentId(void *foo) {this->SetParentId((HWND)foo);};
00129 
00130   void  SetContextId(HGLRC);    // hsr
00131   void  SetDeviceContext(HDC);  // hsr
00132 
00134   virtual void  SetNextWindowId(HWND);
00135 
00138   virtual void SetNextWindowId(void *arg);
00139 
00140   //ETX
00141 
00146   virtual void SetStereoCapableWindow(int capable);
00147 
00149   void MakeCurrent();
00150 
00153   virtual bool IsCurrent();
00154   
00156   const char *ReportCapabilities();
00157 
00159   int SupportsOpenGL();
00160 
00162   int IsDirect();
00163 
00167   virtual  int GetEventPending();
00168 
00170 
00172   void SetupMemoryRendering(int x, int y, HDC prn);
00173   void SetupMemoryRendering(HBITMAP hbmp);
00174   void ResumeScreenRendering(void);
00175   HDC GetMemoryDC();
00176   unsigned char *GetMemoryData(){return this->MemoryData;};  
00178 
00180 
00181   virtual void SetupPalette(HDC hDC);
00182   virtual void SetupPixelFormat(HDC hDC, DWORD dwFlags, int debug, 
00183                                 int bpp=16, int zbpp=16);
00185   
00187   void Clean();
00188 
00190 
00193   void HideCursor();
00194   void ShowCursor();
00195   void SetCursorPosition(int x, int y);
00197 
00199   virtual void SetCurrentCursor(int);
00200 
00203   virtual void SetOffScreenRendering(int offscreen);
00204 
00205 protected:
00206   vtkWin32OpenGLRenderWindow();
00207   ~vtkWin32OpenGLRenderWindow();
00208 
00209   HINSTANCE ApplicationInstance;
00210   HPALETTE  Palette;
00211   HPALETTE  OldPalette;
00212   HGLRC     ContextId;
00213   HDC       DeviceContext;
00214   BOOL      MFChandledWindow;
00215   HWND      WindowId;
00216   HWND      ParentId;
00217   HWND      NextWindowId;
00218   int       OwnWindow;
00219   int       ScreenSize[2];
00220 
00221   // the following is used to support rendering into memory
00222   BITMAPINFO MemoryDataHeader;
00223   HBITMAP MemoryBuffer;
00224   unsigned char *MemoryData;    // the data in the DIBSection
00225   HDC MemoryHdc;
00226 
00227   int ScreenMapped;
00228   int ScreenWindowSize[2];
00229   HDC ScreenDeviceContext;
00230   int ScreenDoubleBuffer;
00231   HGLRC ScreenContextId;
00232 
00233   int CreatingOffScreenWindow; // to avoid recursion (and memory leaks...)
00234   
00235   //BTX
00236   // message handler
00237   virtual LRESULT MessageProc(HWND hWnd, UINT message, 
00238                               WPARAM wParam, LPARAM lParam);
00239 
00240   static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, 
00241                                   WPARAM wParam, LPARAM lParam);
00242   //ETX
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
00266