VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkUniformVariables.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 =========================================================================*/ 00029 #ifndef vtkUniformVariables_h 00030 #define vtkUniformVariables_h 00031 00032 #include "vtkRenderingOpenGLModule.h" // For export macro 00033 #include "vtkObject.h" 00034 00035 class vtkUniformVariablesMap; // internal 00036 00037 class VTKRENDERINGOPENGL_EXPORT vtkUniformVariables : public vtkObject 00038 { 00039 public: 00040 static vtkUniformVariables *New(); 00041 vtkTypeMacro(vtkUniformVariables,vtkObject); 00042 void PrintSelf(ostream &os, vtkIndent indent); 00043 00045 00048 void SetUniformi(const char *name, 00049 int numberOfComponents, 00050 int *value); 00052 00053 //BTX 00054 template<typename T> 00055 void SetUniformit(const char *name, 00056 int numberOfComponents, 00057 T *value); 00058 00059 template<typename T> 00060 void SetUniformit(const char *name, T value) 00061 { this->SetUniformit(name, 1, &value); } 00062 //ETX 00063 00065 00068 void SetUniformf(const char *name, 00069 int numberOfComponents, 00070 float *value); 00072 00073 //BTX 00074 template<typename T> 00075 void SetUniformft(const char *name, 00076 int numberOfComponents, 00077 T *value); 00078 00079 template<typename T> 00080 void SetUniformft(const char *name, T value) 00081 { this->SetUniformft(name, 1, &value); } 00082 //ETX 00083 00085 00090 void SetUniformiv(const char *name, 00091 int numberOfComponents, 00092 int numberOfElements, 00093 int *value); 00095 00097 00102 void SetUniformfv(const char *name, 00103 int numberOfComponents, 00104 int numberOfElements, 00105 float *value); 00107 00109 00112 void SetUniformMatrix(const char *name, 00113 int rows, 00114 int columns, 00115 float *value); 00117 00119 void RemoveUniform(const char *name); 00120 00122 void RemoveAllUniforms(); 00123 00125 00126 void Send(const char *name, 00127 int uniformIndex); 00129 00131 void Start(); 00132 00134 bool IsAtEnd(); 00135 00138 const char *GetCurrentName(); 00139 00142 void SendCurrentUniform(int uniformIndex); 00143 00145 void Next(); 00146 00149 void DeepCopy(vtkUniformVariables *other); 00150 00153 void Merge(vtkUniformVariables *other); 00154 00155 protected: 00156 vtkUniformVariables(); 00157 virtual ~vtkUniformVariables(); 00158 00159 private: 00160 vtkUniformVariables(const vtkUniformVariables&); // Not implemented. 00161 void operator=(const vtkUniformVariables&); // Not implemented. 00162 00163 vtkUniformVariablesMap *Map; 00164 }; 00165 00166 //BTX 00167 // ---------------------------------------------------------------------------- 00168 template<typename T> 00169 void vtkUniformVariables::SetUniformit(const char *name, 00170 int numberOfComponents, 00171 T *value) 00172 { 00173 int ivalues[4]; 00174 for (int i=0; i<numberOfComponents; ++i) 00175 { 00176 ivalues[i] = static_cast<int>(value[i]); 00177 } 00178 this->SetUniformi(name, numberOfComponents, ivalues); 00179 } 00180 00181 // ---------------------------------------------------------------------------- 00182 template<typename T> 00183 void vtkUniformVariables::SetUniformft(const char *name, 00184 int numberOfComponents, 00185 T *value) 00186 { 00187 float fvalues[4]; 00188 for (int i=0; i<numberOfComponents; ++i) 00189 { 00190 fvalues[i] = static_cast<float>(value[i]); 00191 } 00192 this->SetUniformf(name, numberOfComponents, fvalues); 00193 } 00194 //ETX 00195 00196 #endif