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 
00168 
00169   vtkGetMacro(ContextCreationTime, vtkTimeStamp);
00171 //ETX
00172 
00175   vtkOpenGLExtensionManager* GetExtensionManager();
00176 
00179   vtkOpenGLHardwareSupport* GetHardwareSupport();
00180 
00181   //BTX
00183 
00185   vtkTextureUnitManager *GetTextureUnitManager();
00186   //ETX
00188 
00191   virtual void WaitForCompletion();
00192   
00193 protected:
00194   vtkOpenGLRenderWindow();
00195   ~vtkOpenGLRenderWindow();
00196 
00197   vtkIdList *TextureResourceIds;
00198 
00199   int GetPixelData(int x,int y,int x2,int y2,int front, unsigned char* data);
00200   int GetRGBAPixelData(int x,int y,int x2,int y2, int front, float* data);
00201   int GetRGBACharPixelData(int x,int y,int x2,int y2, int front,
00202                            unsigned char* data);
00203 
00209   int CreateHardwareOffScreenWindow(int width, int height);
00210 
00214   void DestroyHardwareOffScreenWindow();
00215 
00217   int OffScreenUseFrameBuffer;
00218 
00220 
00221   int NumberOfFrameBuffers;
00222   unsigned int TextureObjects[4]; // really GLuint
00223   unsigned int FrameBufferObject; // really GLuint
00224   unsigned int DepthRenderBufferObject; // really GLuint
00226 
00228   virtual void CreateAWindow()=0;
00229 
00231   virtual void DestroyWindow()=0;
00232 
00234   void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager);
00235 
00236   unsigned int BackLeftBuffer;
00237   unsigned int BackRightBuffer;
00238   unsigned int FrontLeftBuffer;
00239   unsigned int FrontRightBuffer;
00240   unsigned int FrontBuffer;
00241   unsigned int BackBuffer;
00242 
00243   // Actual type is GLenum. Last value returned by glGetError().
00244   unsigned int LastGraphicError;
00245 
00246   vtkTimeStamp ContextCreationTime;
00247 
00248   vtkTextureUnitManager *TextureUnitManager;
00249 
00250 private:
00251   vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&);  // Not implemented.
00252   void operator=(const vtkOpenGLRenderWindow&);  // Not implemented.
00253 
00254   void SetExtensionManager(vtkOpenGLExtensionManager*);
00255   void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow);
00256 
00257   vtkOpenGLExtensionManager* ExtensionManager;
00258   vtkOpenGLHardwareSupport* HardwareSupport;
00259 };
00260 
00261 #endif