VTK
dox/Rendering/OpenGL/vtkGLSLShader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkGLSLShader.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 =========================================================================*/
00015 /*
00016  * Copyright 2003 Sandia Corporation.
00017  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00018  * license for use of this work by or on behalf of the
00019  * U.S. Government. Redistribution and use in source and binary forms, with
00020  * or without modification, are permitted provided that this Notice and any
00021  * statement of authorship are reproduced on all copies.
00022  */
00023 
00073 #ifndef __vtkGLSLShader_h
00074 #define __vtkGLSLShader_h
00075 
00076 #include "vtkRenderingOpenGLModule.h" // For export macro
00077 #include "vtkShader.h"
00078 
00079 class vtkActor;
00080 class vtkRenderer;
00081 class vtkProperty;
00082 class vtkLight;
00083 class vtkCamera;
00084 class vtkRenderWindow;
00085 
00086 // Manages all shaders defined in the XML file
00087 // especially the part about sending things to the card
00088 class VTKRENDERINGOPENGL_EXPORT vtkGLSLShader : public vtkShader
00089 {
00090 public:
00091   static vtkGLSLShader *New();
00092   vtkTypeMacro(vtkGLSLShader, vtkShader);
00093   void PrintSelf(ostream &os, vtkIndent indent);
00094 
00099   virtual int Compile();
00100 
00102   unsigned int GetHandle() { return this->Shader; }
00103 
00105 
00107   vtkSetMacro( Program, unsigned int );
00108   vtkGetMacro( Program, unsigned int );
00110 
00112 
00115   virtual void ReleaseGraphicsResources(vtkWindow *);
00116 protected:
00117   vtkGLSLShader();
00118   virtual ~vtkGLSLShader();
00120 
00121   // These are GLuints.
00122   unsigned int Program;
00123   unsigned int Shader;
00124 
00125   int IsShader();
00126   int IsCompiled();
00127 
00129   void LoadShader();
00130 
00132 
00133   virtual void SetUniformParameter(const char* name, int numValues, const int* value);
00134   virtual void SetUniformParameter(const char* name, int numValues, const float* value);
00135   virtual void SetUniformParameter(const char* name, int numValues, const double* value);
00137 
00139 
00140   virtual void SetMatrixParameter(const char* name, int numValues,
00141     int order, const float* value);
00142   virtual void SetMatrixParameter(const char* name, int numValues,
00143     int order, const double* value);
00144   virtual void SetMatrixParameter(const char* name, const char* state_matix_type,
00145     const char* transform_type);
00147 
00148   virtual void SetSamplerParameter(const char* name, vtkTexture* texture,
00149                                    int textureIndex);
00150 private:
00151   vtkGLSLShader(const vtkGLSLShader&); // Not Implemented
00152   void operator=(const vtkGLSLShader&); // Not Implemented
00153 
00154   int GetUniformLocation( const char* name );
00155 };
00156 #endif //__vtkGLSLShader_h