VTK
dox/Rendering/vtkOpenGLRenderWindow.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkOpenGLRenderWindow.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 =========================================================================*/
00027 #ifndef __vtkOpenGLRenderWindow_h
00028 #define __vtkOpenGLRenderWindow_h
00029 
00030 #include "vtkRenderWindow.h"
00031 
00032 #include "vtkOpenGL.h" // Needed for GLuint.
00033 
00034 class vtkIdList;
00035 class vtkOpenGLExtensionManager;
00036 class vtkOpenGLHardwareSupport;
00037 class vtkTextureUnitManager;
00038 
00039 class VTK_RENDERING_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow
00040 {
00041 protected:
00042   long OldMonitorSetting;
00043 
00044 public:
00045   vtkTypeMacro(vtkOpenGLRenderWindow,vtkRenderWindow);
00046   void PrintSelf(ostream& os, vtkIndent indent);
00047 
00049 
00050   static void SetGlobalMaximumNumberOfMultiSamples(int val);
00051   static int  GetGlobalMaximumNumberOfMultiSamples();
00053 
00055   virtual void StereoUpdate();
00056 
00058 
00059   virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front);
00060   virtual int GetPixelData(int x,int y,int x2,int y2, int front,
00061                            vtkUnsignedCharArray *data);
00062   virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data,
00063                            int front);
00064   virtual int SetPixelData(int x,int y,int x2,int y2,
00065                            vtkUnsignedCharArray *data, int front);
00067 
00069 
00070   virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front);
00071   virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front,
00072                                vtkFloatArray* data);
00073   virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data,
00074                                int front, int blend=0);
00075   virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data,
00076                                int front, int blend=0);
00077   virtual void ReleaseRGBAPixelData(float *data);
00078   virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2,
00079                                               int front);
00080   virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
00081                                    vtkUnsignedCharArray *data);
00082   virtual int SetRGBACharPixelData(int x, int y, int x2, int y2,
00083                                    unsigned char *data, int front,
00084                                    int blend=0);
00085   virtual int SetRGBACharPixelData(int x,int y,int x2,int y2,
00086                                    vtkUnsignedCharArray *data, int front,
00087                                    int blend=0);
00089 
00091 
00092   virtual float *GetZbufferData( int x1, int y1, int x2, int y2 );
00093   virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z );
00094   virtual int GetZbufferData( int x1, int y1, int x2, int y2,
00095                               vtkFloatArray* z );
00096   virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer );
00097   virtual int SetZbufferData( int x1, int y1, int x2, int y2,
00098                               vtkFloatArray *buffer );
00100 
00102   void RegisterTextureResource (GLuint id);
00103 
00105   int GetDepthBufferSize();
00106 
00109   int GetColorBufferSizes(int *rgba);
00110 
00112   virtual void OpenGLInit();
00113 
00119   unsigned int GetBackLeftBuffer();
00120 
00126   unsigned int GetBackRightBuffer();
00127 
00133   unsigned int GetFrontLeftBuffer();
00134 
00140   unsigned int GetFrontRightBuffer();
00141 
00147   unsigned int GetBackBuffer();
00148 
00154   unsigned int GetFrontBuffer();
00155 
00159   virtual void CheckGraphicError();
00160 
00162   virtual int HasGraphicError();
00163 
00165   virtual const char *GetLastGraphicErrorString();
00166 
00167 //BTX
00169 
00170   vtkGetMacro(ContextCreationTime, vtkTimeStamp);
00171 //ETX
00173 
00176   vtkOpenGLExtensionManager* GetExtensionManager();
00177 
00180   vtkOpenGLHardwareSupport* GetHardwareSupport();
00181 
00182   //BTX
00184 
00186   vtkTextureUnitManager *GetTextureUnitManager();
00187   //ETX
00189 
00192   virtual void WaitForCompletion();
00193   
00194 protected:
00195   vtkOpenGLRenderWindow();
00196   ~vtkOpenGLRenderWindow();
00197 
00198   vtkIdList *TextureResourceIds;
00199 
00200   int GetPixelData(int x,int y,int x2,int y2,int front, unsigned char* data);
00201   int GetRGBAPixelData(int x,int y,int x2,int y2, int front, float* data);
00202   int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
00203                            unsigned char* data);
00204 
00210   int CreateHardwareOffScreenWindow(int width, int height);
00211 
00215   void DestroyHardwareOffScreenWindow();
00216 
00218   int OffScreenUseFrameBuffer;
00219 
00221 
00222   int NumberOfFrameBuffers;
00223   unsigned int TextureObjects[4]; // really GLuint
00224   unsigned int FrameBufferObject; // really GLuint
00225   unsigned int DepthRenderBufferObject; // really GLuint
00227 
00229   virtual void CreateAWindow()=0;
00230 
00232   virtual void DestroyWindow()=0;
00233 
00235   void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
00236 
00237   unsigned int BackLeftBuffer;
00238   unsigned int BackRightBuffer;
00239   unsigned int FrontLeftBuffer;
00240   unsigned int FrontRightBuffer;
00241   unsigned int FrontBuffer;
00242   unsigned int BackBuffer;
00243 
00244   // Actual type is GLenum. Last value returned by glGetError().
00245   unsigned int LastGraphicError;
00246 
00247   vtkTimeStamp ContextCreationTime;
00248 
00249   vtkTextureUnitManager *TextureUnitManager;
00250 
00251 private:
00252   vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&);  // Not implemented.
00253   void operator=(const vtkOpenGLRenderWindow&);  // Not implemented.
00254 
00255   void SetExtensionManager(vtkOpenGLExtensionManager*);
00256   void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
00257 
00258   vtkOpenGLExtensionManager* ExtensionManager;
00259   vtkOpenGLHardwareSupport* HardwareSupport;
00260 };
00261 
00262 #endif