VTK
vtkGLSLShader.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkGLSLShader.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 
73 #ifndef __vtkGLSLShader_h
74 #define __vtkGLSLShader_h
75 
76 #include "vtkRenderingOpenGLModule.h" // For export macro
77 #include "vtkShader.h"
78 
79 class vtkActor;
80 class vtkRenderer;
81 class vtkProperty;
82 class vtkLight;
83 class vtkCamera;
84 class vtkRenderWindow;
85 
86 // Manages all shaders defined in the XML file
87 // especially the part about sending things to the card
88 class VTKRENDERINGOPENGL_EXPORT vtkGLSLShader : public vtkShader
89 {
90 public:
91  static vtkGLSLShader *New();
92  vtkTypeMacro(vtkGLSLShader, vtkShader);
93  void PrintSelf(ostream &os, vtkIndent indent);
94 
99  virtual int Compile();
100 
102  unsigned int GetHandle() { return this->Shader; }
103 
105 
107  vtkSetMacro( Program, unsigned int );
108  vtkGetMacro( Program, unsigned int );
110 
112 
115  virtual void ReleaseGraphicsResources(vtkWindow *);
116 protected:
117  vtkGLSLShader();
118  virtual ~vtkGLSLShader();
120 
121  // These are GLuints.
122  unsigned int Program;
123  unsigned int Shader;
124 
125  int IsShader();
126  int IsCompiled();
127 
129  void LoadShader();
130 
132 
133  virtual void SetUniformParameter(const char* name, int numValues, const int* value);
134  virtual void SetUniformParameter(const char* name, int numValues, const float* value);
135  virtual void SetUniformParameter(const char* name, int numValues, const double* value);
137 
139 
140  virtual void SetMatrixParameter(const char* name, int numValues,
141  int order, const float* value);
142  virtual void SetMatrixParameter(const char* name, int numValues,
143  int order, const double* value);
144  virtual void SetMatrixParameter(const char* name, const char* state_matix_type,
145  const char* transform_type);
147 
148  virtual void SetSamplerParameter(const char* name, vtkTexture* texture,
149  int textureIndex);
150 private:
151  vtkGLSLShader(const vtkGLSLShader&); // Not Implemented
152  void operator=(const vtkGLSLShader&); // Not Implemented
153 
154  int GetUniformLocation( const char* name );
155 };
156 #endif //__vtkGLSLShader_h