VTK
dox/Rendering/vtkCgShader.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkCgShader.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 
00092 #ifndef __vtkCgShader_h
00093 #define __vtkCgShader_h
00094 
00095 #include "vtkShader.h"
00096 
00097 class vtkActor;
00098 class vtkCamera;
00099 class vtkCgShaderInternals;
00100 class vtkLight;
00101 class vtkProperty;
00102 class vtkRenderer;
00103 
00104 // manages all shaders defined in the XML file
00105 // especially the part about sending things to the card
00106 class VTK_RENDERING_EXPORT vtkCgShader : public vtkShader
00107 {
00108 public:
00109   static vtkCgShader *New();
00110   vtkTypeMacro(vtkCgShader, vtkShader);
00111   void PrintSelf(ostream &os, vtkIndent indent);
00112  
00113   // Called to compile the shader code.
00114   // The vtkShaderProgram calls this method only when
00115   // vtkShader::IsCompiled() returns false.
00116   // The subclasses must only compile the code in this method.
00117   // Returns if the compile was successful.
00118   virtual int Compile();
00119 
00123   virtual void  Bind();
00124 
00127   virtual void Unbind();
00128 
00131   void ReportError();
00132 
00136   void ReleaseGraphicsResources(vtkWindow *);
00137 
00138 
00140 
00145   virtual void PassShaderVariables(vtkActor* actor, vtkRenderer* ren);
00146 //BTX
00147 protected:
00148   vtkCgShader();
00149   ~vtkCgShader();
00151 
00153 
00154   virtual void SetUniformParameter(const char* name, int numValues, const int* value) ;
00155   virtual void SetUniformParameter(const char* name, int numValues, const float* value) ;
00156   virtual void SetUniformParameter(const char* name, int numValues, const double* value);
00158 
00160 
00161   virtual void SetMatrixParameter(const char* name, int numValues, 
00162     int order, const float* value);
00163   virtual void SetMatrixParameter(const char* name, int numValues, 
00164     int order, const double* value);
00165   virtual void SetMatrixParameter(const char* name, const char* state_matix_type,
00166     const char* transform_type);
00168 
00169   virtual void SetSamplerParameter(const char* name, vtkTexture* texture,
00170                                    int);
00171 
00172   friend class vtkCgShaderDeviceAdapter;
00173 private:
00174   vtkCgShader(const vtkCgShader&); // Not Implemented
00175   void operator=(const vtkCgShader&); // Not Implemented
00176   
00177   vtkCgShaderInternals* Internals;
00178 //ETX
00179 };
00180 #endif //_vtkCgShader_h