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 00033 #include "vtkOpenGL.h" // Needed for GLuint. 00034 00035 class vtkIdList; 00036 class vtkOpenGLExtensionManager; 00037 class vtkOpenGLHardwareSupport; 00038 class vtkTextureUnitManager; 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 00163 virtual void CheckGraphicError(); 00164 00166 virtual int HasGraphicError(); 00167 00169 virtual const char *GetLastGraphicErrorString(); 00170 00172 virtual unsigned long GetContextCreationTime(); 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 long OldMonitorSetting; 00199 vtkIdList *TextureResourceIds; 00200 00201 int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data); 00202 int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data); 00203 int GetRGBACharPixelData(int x, int y, int x2, int y2, int front, 00204 unsigned char* data); 00205 00211 int CreateHardwareOffScreenWindow(int width, int height); 00212 00216 void DestroyHardwareOffScreenWindow(); 00217 00219 int OffScreenUseFrameBuffer; 00220 00222 00223 int NumberOfFrameBuffers; 00224 unsigned int TextureObjects[4]; // really GLuint 00225 unsigned int FrameBufferObject; // really GLuint 00226 unsigned int DepthRenderBufferObject; // really GLuint 00228 00230 virtual void CreateAWindow() = 0; 00231 00233 virtual void DestroyWindow() = 0; 00234 00236 void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager); 00237 00238 unsigned int BackLeftBuffer; 00239 unsigned int BackRightBuffer; 00240 unsigned int FrontLeftBuffer; 00241 unsigned int FrontRightBuffer; 00242 unsigned int FrontBuffer; 00243 unsigned int BackBuffer; 00244 00245 // Actual type is GLenum. Last value returned by glGetError(). 00246 unsigned int LastGraphicError; 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