VTK
|
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 00114 // Initialize the state of OpenGL that VTK wants for this window 00115 virtual void OpenGLInitState(); 00116 00117 // Initialize VTK for rendering in a new OpenGL context 00118 virtual void OpenGLInitContext(); 00119 00125 unsigned int GetBackLeftBuffer(); 00126 00132 unsigned int GetBackRightBuffer(); 00133 00139 unsigned int GetFrontLeftBuffer(); 00140 00146 unsigned int GetFrontRightBuffer(); 00147 00153 unsigned int GetBackBuffer(); 00154 00160 unsigned int GetFrontBuffer(); 00161 00165 virtual void CheckGraphicError(); 00166 00168 virtual int HasGraphicError(); 00169 00171 virtual const char *GetLastGraphicErrorString(); 00172 00174 virtual unsigned long GetContextCreationTime(); 00175 00178 vtkOpenGLExtensionManager* GetExtensionManager(); 00179 00182 vtkOpenGLHardwareSupport* GetHardwareSupport(); 00183 00184 //BTX 00186 00188 vtkTextureUnitManager *GetTextureUnitManager(); 00189 //ETX 00191 00194 virtual void WaitForCompletion(); 00195 00196 protected: 00197 vtkOpenGLRenderWindow(); 00198 ~vtkOpenGLRenderWindow(); 00199 00200 vtkIdList *TextureResourceIds; 00201 00202 int GetPixelData(int x,int y,int x2,int y2,int front, unsigned char* data); 00203 int GetRGBAPixelData(int x,int y,int x2,int y2, int front, float* data); 00204 int GetRGBACharPixelData(int x,int y,int x2,int y2, int front, 00205 unsigned char* data); 00206 00212 int CreateHardwareOffScreenWindow(int width, int height); 00213 00217 void DestroyHardwareOffScreenWindow(); 00218 00220 int OffScreenUseFrameBuffer; 00221 00223 00224 int NumberOfFrameBuffers; 00225 unsigned int TextureObjects[4]; // really GLuint 00226 unsigned int FrameBufferObject; // really GLuint 00227 unsigned int DepthRenderBufferObject; // really GLuint 00229 00231 virtual void CreateAWindow()=0; 00232 00234 virtual void DestroyWindow()=0; 00235 00237 void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager); 00238 00239 unsigned int BackLeftBuffer; 00240 unsigned int BackRightBuffer; 00241 unsigned int FrontLeftBuffer; 00242 unsigned int FrontRightBuffer; 00243 unsigned int FrontBuffer; 00244 unsigned int BackBuffer; 00245 00246 // Actual type is GLenum. Last value returned by glGetError(). 00247 unsigned int LastGraphicError; 00248 00249 vtkTimeStamp ContextCreationTime; 00250 00251 vtkTextureUnitManager *TextureUnitManager; 00252 00253 private: 00254 vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented. 00255 void operator=(const vtkOpenGLRenderWindow&); // Not implemented. 00256 00257 void SetExtensionManager(vtkOpenGLExtensionManager*); 00258 void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow); 00259 00260 vtkOpenGLExtensionManager* ExtensionManager; 00261 vtkOpenGLHardwareSupport* HardwareSupport; 00262 }; 00263 00264 #endif