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 =========================================================================*/ 00024 #ifndef vtkOpenGLRenderWindow_h 00025 #define vtkOpenGLRenderWindow_h 00026 00027 #include "vtkRenderingOpenGL2Module.h" // For export macro 00028 #include "vtkRenderWindow.h" 00029 #include <map> // for ivar 00030 00031 #include "vtk_glew.h" // Needed for GLuint. 00032 00033 class vtkIdList; 00034 class vtkOpenGLHardwareSupport; 00035 class vtkTextureUnitManager; 00036 class vtkOpenGLShaderCache; 00037 class vtkStdString; 00038 class vtkTexture; 00039 class vtkTextureObject; 00040 class vtkShaderProgram; 00041 00042 namespace vtkgl 00043 { 00044 class VertexArrayObject; 00045 } 00046 00047 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderWindow : public vtkRenderWindow 00048 { 00049 public: 00050 vtkTypeMacro(vtkOpenGLRenderWindow, vtkRenderWindow); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00052 00054 00055 static void SetGlobalMaximumNumberOfMultiSamples(int val); 00056 static int GetGlobalMaximumNumberOfMultiSamples(); 00058 00060 virtual void StereoUpdate(); 00061 00063 00064 virtual unsigned char *GetPixelData(int x,int y,int x2,int y2,int front); 00065 virtual int GetPixelData(int x,int y,int x2,int y2, int front, 00066 vtkUnsignedCharArray *data); 00067 virtual int SetPixelData(int x,int y,int x2,int y2,unsigned char *data, 00068 int front); 00069 virtual int SetPixelData(int x,int y,int x2,int y2, 00070 vtkUnsignedCharArray *data, int front); 00072 00074 00075 virtual float *GetRGBAPixelData(int x,int y,int x2,int y2,int front); 00076 virtual int GetRGBAPixelData(int x,int y,int x2,int y2, int front, 00077 vtkFloatArray* data); 00078 virtual int SetRGBAPixelData(int x,int y,int x2,int y2, float *data, 00079 int front, int blend=0); 00080 virtual int SetRGBAPixelData(int x,int y,int x2,int y2, vtkFloatArray *data, 00081 int front, int blend=0); 00082 virtual void ReleaseRGBAPixelData(float *data); 00083 virtual unsigned char *GetRGBACharPixelData(int x,int y,int x2,int y2, 00084 int front); 00085 virtual int GetRGBACharPixelData(int x,int y,int x2,int y2, int front, 00086 vtkUnsignedCharArray *data); 00087 virtual int SetRGBACharPixelData(int x, int y, int x2, int y2, 00088 unsigned char *data, int front, 00089 int blend=0); 00090 virtual int SetRGBACharPixelData(int x,int y,int x2,int y2, 00091 vtkUnsignedCharArray *data, int front, 00092 int blend=0); 00094 00096 00097 virtual float *GetZbufferData( int x1, int y1, int x2, int y2 ); 00098 virtual int GetZbufferData( int x1, int y1, int x2, int y2, float* z ); 00099 virtual int GetZbufferData( int x1, int y1, int x2, int y2, 00100 vtkFloatArray* z ); 00101 virtual int SetZbufferData( int x1, int y1, int x2, int y2, float *buffer ); 00102 virtual int SetZbufferData( int x1, int y1, int x2, int y2, 00103 vtkFloatArray *buffer ); 00105 00106 00108 void ActivateTexture(vtkTextureObject *); 00109 00111 void DeactivateTexture(vtkTextureObject *); 00112 00114 int GetTextureUnitForTexture(vtkTextureObject *); 00115 00117 int GetDepthBufferSize(); 00118 00121 int GetColorBufferSizes(int *rgba); 00122 00124 virtual void OpenGLInit(); 00125 00126 // Initialize the state of OpenGL that VTK wants for this window 00127 virtual void OpenGLInitState(); 00128 00129 // Initialize VTK for rendering in a new OpenGL context 00130 virtual void OpenGLInitContext(); 00131 00133 00134 static bool GetContextSupportsOpenGL32(); 00135 void SetContextSupportsOpenGL32(bool val); 00137 00143 unsigned int GetBackLeftBuffer(); 00144 00150 unsigned int GetBackRightBuffer(); 00151 00157 unsigned int GetFrontLeftBuffer(); 00158 00164 unsigned int GetFrontRightBuffer(); 00165 00171 unsigned int GetBackBuffer(); 00172 00178 unsigned int GetFrontBuffer(); 00179 00181 00182 VTK_LEGACY(virtual void CheckGraphicError()); 00183 VTK_LEGACY(virtual int HasGraphicError()); 00184 VTK_LEGACY(virtual const char *GetLastGraphicErrorString()); 00186 00188 virtual unsigned long GetContextCreationTime(); 00189 00191 00192 vtkGetObjectMacro(ShaderCache,vtkOpenGLShaderCache); 00194 00197 vtkTextureUnitManager *GetTextureUnitManager(); 00198 00201 virtual void WaitForCompletion(); 00202 00204 00207 static void RenderQuad( 00208 float *verts, float *tcoords, 00209 vtkShaderProgram *program, vtkgl::VertexArrayObject *vao); 00211 00213 00214 virtual void DrawPixels(int x1, int y1, int x2, int y2, 00215 int numComponents, int dataType, void *data); 00217 00219 00221 virtual void DrawPixels( 00222 int dstXmin, int dstYmin, int dstXmax, int dstYmax, 00223 int srcXmin, int srcYmin, int srcXmax, int srcYmax, 00224 int srcWidth, int srcHeight, int numComponents, int dataType, void *data); 00226 00228 00230 virtual void DrawPixels( 00231 int srcWidth, int srcHeight, int numComponents, int dataType, void *data); 00233 00234 protected: 00235 vtkOpenGLRenderWindow(); 00236 ~vtkOpenGLRenderWindow(); 00237 00238 vtkOpenGLShaderCache *ShaderCache; 00239 00240 long OldMonitorSetting; 00241 00242 std::map<const vtkTextureObject *, int> TextureResourceIds; 00243 00244 int GetPixelData(int x, int y, int x2, int y2, int front, unsigned char* data); 00245 int GetRGBAPixelData(int x, int y, int x2, int y2, int front, float* data); 00246 int GetRGBACharPixelData(int x, int y, int x2, int y2, int front, 00247 unsigned char* data); 00248 00254 int CreateHardwareOffScreenWindow(int width, int height); 00255 00259 void DestroyHardwareOffScreenWindow(); 00260 00262 int OffScreenUseFrameBuffer; 00263 00265 00266 int NumberOfFrameBuffers; 00267 unsigned int TextureObjects[4]; // really GLuint 00268 unsigned int FrameBufferObject; // really GLuint 00269 unsigned int DepthRenderBufferObject; // really GLuint 00271 00273 virtual void CreateAWindow() = 0; 00274 00276 virtual void DestroyWindow() = 0; 00277 00279 virtual void ReleaseGraphicsResources(); 00280 00282 void SetTextureUnitManager(vtkTextureUnitManager *textureUnitManager); 00283 00284 unsigned int BackLeftBuffer; 00285 unsigned int BackRightBuffer; 00286 unsigned int FrontLeftBuffer; 00287 unsigned int FrontRightBuffer; 00288 unsigned int FrontBuffer; 00289 unsigned int BackBuffer; 00290 00291 #ifndef VTK_LEGACY_REMOVE 00292 00293 00294 unsigned int LastGraphicError; 00295 #endif 00296 00297 00299 int OwnContext; 00300 00301 vtkTimeStamp ContextCreationTime; 00302 00303 vtkTextureUnitManager *TextureUnitManager; 00304 00305 vtkTextureObject *DrawPixelsTextureObject; 00306 00307 bool Initialized; // ensure glewinit has been called 00308 00309 private: 00310 vtkOpenGLRenderWindow(const vtkOpenGLRenderWindow&); // Not implemented. 00311 void operator=(const vtkOpenGLRenderWindow&); // Not implemented. 00312 }; 00313 00314 #endif