VTK
vtkShader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkShader.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 /*
16  * Copyright 2003 Sandia Corporation.
17  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
18  * license for use of this work by or on behalf of the
19  * U.S. Government. Redistribution and use in source and binary forms, with
20  * or without modification, are permitted provided that this Notice and any
21  * statement of authorship are reproduced on all copies.
22  */
23 
42 #ifndef __vtkShader_h
43 #define __vtkShader_h
44 
45 #include "vtkObject.h"
46 
47 class vtkActor;
48 class vtkCamera;
49 class vtkLight;
50 class vtkProperty;
51 class vtkRenderer;
52 class vtkShaderInternals;
53 class vtkTexture;
54 class vtkWindow;
55 class vtkXMLDataElement;
56 class vtkXMLShader;
57 
59 {
60 public:
61  vtkTypeMacro(vtkShader, vtkObject);
62  virtual void PrintSelf(ostream &os, vtkIndent indent);
63 
68  virtual int Compile() =0;
69 
73  virtual void PassShaderVariables(vtkActor* actor, vtkRenderer* ren);
74 
78  virtual void Bind() { }
79 
82  virtual void Unbind() { }
83 
87  virtual void ReleaseGraphicsResources(vtkWindow *) { }
88 
90 
92  void SetXMLShader(vtkXMLShader*);
93  vtkGetObjectMacro(XMLShader, vtkXMLShader);
95 
97  int HasShaderVariable(const char* name);
98 
100 
103  void AddShaderVariable(const char* name, int num_of_elements,
104  const int *values);
105  void AddShaderVariable(const char* name, int num_of_elements,
106  const float *values);
107  void AddShaderVariable(const char* name, int num_of_elements,
108  const double *values);
110 
113  int GetShaderVariableSize(const char* name);
114 
117  int GetShaderVariableType(const char* name);
118 
120 
123  int GetShaderVariable(const char* name, int* values);
124  int GetShaderVariable(const char* name, float* values);
125  int GetShaderVariable(const char* name, double* values);
127 
129 
131  int GetScope();
132 protected:
133  vtkShader();
134  ~vtkShader();
136 
138  vtkShaderInternals* Internals;
139 
140  //BTX
142  {
144  ColumnMajor
145  };
146  //ETX
147 
149 
151  virtual void SetShaderParameters(vtkActor*, vtkRenderer*,
154 
155 
157  void SetUniformParameter(vtkActor*, vtkRenderer*, vtkXMLDataElement*);
158 
160  void SetCameraParameter(vtkActor*, vtkRenderer*, vtkXMLDataElement*);
161 
163  void SetPropertyParameter(vtkActor*, vtkRenderer*, vtkXMLDataElement*);
164 
166  void SetLightParameter(vtkActor*, vtkRenderer*, vtkXMLDataElement*);
167 
169  void SetMatrixParameter(vtkActor*, vtkRenderer*, vtkXMLDataElement*);
170 
172  void SetSamplerParameter(vtkActor*, vtkRenderer*, vtkXMLDataElement*);
173 
175  void SetApplicationParameter(vtkXMLDataElement*);
176 
178 
180  virtual void SetUniformParameter(const char* name, int numValues,
181  const int* value) =0;
182  virtual void SetUniformParameter(const char* name, int numValues,
183  const float* value)=0;
184  virtual void SetUniformParameter(const char* name, int numValues,
185  const double* value)=0;
187 
189 
191  virtual void SetMatrixParameter(const char* name, int numValues,
192  int order, const float* value)=0;
193  virtual void SetMatrixParameter(const char* name, int numValues,
194  int order, const double* value)=0;
195  virtual void SetMatrixParameter(const char* name, const char* state_matix_type,
196  const char* transform_type)=0;
198 
199 
201 
206  virtual void SetSamplerParameter(const char* name, vtkTexture* texture,
207  int textureIndex)=0;
209 
211 private:
212  vtkShader(const vtkShader&); // Not Implemented
213  void operator=(const vtkShader&); // Not Implemented
214 };
215 #endif //__vtkShader_h