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 "vtkRenderingOpenGLModule.h" // For export macro 00031 #include "vtkRenderWindow.h" 00032 #include "vtkOpenGL.h" // Needed for GLuint. 00033 00034 class vtkIdList; 00035 class vtkOpenGLExtensionManager; 00036 class vtkOpenGLHardwareSupport; 00037 class vtkTextureUnitManager; 00038 class vtkStdString; 00039 00040 class VTKRENDERINGOPENGL_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow 00041 { 00042 public: 00043 vtkTypeMacro(vtkOpenGLRenderWindow, vtkRenderWindow); 00044 void PrintSelf(ostream& os, vtkIndent indent); 00045 00047 00048 static void SetGlobalMaximumNumberOfMultiSamples(int val); 00049 static int GetGlobalMaximumNumberOfMultiSamples(); 00051 00053 virtual void StereoUpdate(); 00054 00056 00057 virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front); 00058 virtual int GetPixelData(int x,int y,int x2,int y2, int front, 00059 vtkUnsignedCharArray *data); 00060 virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data, 00061 int front); 00062 virtual int SetPixelData(int x,int y,int x2,int y2, 00063 vtkUnsignedCharArray *data, int front); 00065 00067 00068 virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front); 00069 virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front, 00070 vtkFloatArray* data); 00071 virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data, 00072 int front, int blend=0); 00073 virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data, 00074 int front, int blend=0); 00075 virtual void ReleaseRGBAPixelData(float *data); 00076 virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2, 00077 int front); 00078 virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front, 00079 vtkUnsignedCharArray *data); 00080 virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, 00081 unsigned char *data, int front, 00082 int blend=0); 00083 virtual int SetRGBACharPixelData(int x,int y,int x2,int y2, 00084 vtkUnsignedCharArray *data, int front, 00085 int blend=0); 00087 00089 00090 virtual float *GetZbufferData( int x1, int y1, int x2, int y2 ); 00091 virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z ); 00092 virtual int GetZbufferData( int x1, int y1, int x2, int y2, 00093 vtkFloatArray* z ); 00094 virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer ); 00095 virtual int SetZbufferData( int x1, int y1, int x2, int y2, 00096 vtkFloatArray *buffer ); 00098 00100 void RegisterTextureResource (GLuint id); 00101 00103 int GetDepthBufferSize(); 00104 00107 int GetColorBufferSizes(int *rgba); 00108 00110 virtual void OpenGLInit(); 00111 00112 // Initialize the state of OpenGL that VTK wants for this window 00113 virtual void OpenGLInitState(); 00114 00115 // Initialize VTK for rendering in a new OpenGL context 00116 virtual void OpenGLInitContext(); 00117 00123 unsigned int GetBackLeftBuffer(); 00124 00130 unsigned int GetBackRightBuffer(); 00131 00137 unsigned int GetFrontLeftBuffer(); 00138 00144 unsigned int GetFrontRightBuffer(); 00145 00151 unsigned int GetBackBuffer(); 00152 00158 unsigned int GetFrontBuffer(); 00159 00161 00162 VTK_LEGACY(virtual void CheckGraphicError()); 00163 VTK_LEGACY(virtual int HasGraphicError()); 00164 VTK_LEGACY(virtual const char *GetLastGraphicErrorString()); 00166 00168 virtual unsigned long GetContextCreationTime(); 00169 00172 vtkOpenGLExtensionManager* GetExtensionManager(); 00173 00176 vtkOpenGLHardwareSupport* GetHardwareSupport(); 00177 00178 //BTX 00180 00182 vtkTextureUnitManager *GetTextureUnitManager(); 00183 //ETX 00185 00188 virtual void WaitForCompletion(); 00189 00190 protected: 00191 vtkOpenGLRenderWindow(); 00192 ~vtkOpenGLRenderWindow(); 00193 00194 long OldMonitorSetting; 00195 vtkIdList *TextureResourceIds; 00196 00197 int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data); 00198 int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data); 00199 int GetRGBACharPixelData(int x, int y, int x2, int y2, int front, 00200 unsigned char* data); 00201 00207 int CreateHardwareOffScreenWindow(int width, int height); 00208 00212 void DestroyHardwareOffScreenWindow(); 00213 00215 int OffScreenUseFrameBuffer; 00216 00218 00219 int NumberOfFrameBuffers; 00220 unsigned int TextureObjects[4]; // really GLuint 00221 unsigned int FrameBufferObject; // really GLuint 00222 unsigned int DepthRenderBufferObject; // really GLuint 00224 00226 virtual void CreateAWindow() = 0; 00227 00229 virtual void DestroyWindow() = 0; 00230 00232 void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager); 00233 00234 unsigned int BackLeftBuffer; 00235 unsigned int BackRightBuffer; 00236 unsigned int FrontLeftBuffer; 00237 unsigned int FrontRightBuffer; 00238 unsigned int FrontBuffer; 00239 unsigned int BackBuffer; 00240 00241 #ifndef VTK_LEGACY_REMOVE 00242 00243 00244 unsigned int LastGraphicError; 00245 #endif 00246 00247 00249 int OwnContext; 00250 00251 vtkTimeStamp ContextCreationTime; 00252 00253 vtkTextureUnitManager *TextureUnitManager; 00254 00255 private: 00256 vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented. 00257 void operator=(const vtkOpenGLRenderWindow&); // Not implemented. 00258 00259 void SetExtensionManager(vtkOpenGLExtensionManager*); 00260 void SetHardwareSupport(vtkOpenGLHardwareSupport * renderWindow); 00261 00262 vtkOpenGLExtensionManager* ExtensionManager; 00263 vtkOpenGLHardwareSupport* HardwareSupport; 00264 }; 00265 00266 #endif