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 "vtkShader.h"
77 
78 class vtkActor;
79 class vtkRenderer;
80 class vtkProperty;
81 class vtkLight;
82 class vtkCamera;
83 class vtkRenderWindow;
84 
85 // Manages all shaders defined in the XML file
86 // especially the part about sending things to the card
88 {
89 public:
90  static vtkGLSLShader *New();
91  vtkTypeMacro(vtkGLSLShader, vtkShader);
92  void PrintSelf(ostream &os, vtkIndent indent);
93 
98  virtual int Compile();
99 
101  unsigned int GetHandle() { return this->Shader; }
102 
104 
106  vtkSetMacro( Program, unsigned int );
107  vtkGetMacro( Program, unsigned int );
109 
111 
114  virtual void ReleaseGraphicsResources(vtkWindow *);
115 protected:
116  vtkGLSLShader();
117  virtual ~vtkGLSLShader();
119 
120  // These are GLuints.
121  unsigned int Program;
122  unsigned int Shader;
123 
124  int IsShader();
125  int IsCompiled();
126 
128  void LoadShader();
129 
131 
132  virtual void SetUniformParameter(const char* name, int numValues, const int* value);
133  virtual void SetUniformParameter(const char* name, int numValues, const float* value);
134  virtual void SetUniformParameter(const char* name, int numValues, const double* value);
136 
138 
139  virtual void SetMatrixParameter(const char* name, int numValues,
140  int order, const float* value);
141  virtual void SetMatrixParameter(const char* name, int numValues,
142  int order, const double* value);
143  virtual void SetMatrixParameter(const char* name, const char* state_matix_type,
144  const char* transform_type);
146 
147  virtual void SetSamplerParameter(const char* name, vtkTexture* texture,
148  int textureIndex);
149 private:
150  vtkGLSLShader(const vtkGLSLShader&); // Not Implemented
151  void operator=(const vtkGLSLShader&); // Not Implemented
152 
153  int GetUniformLocation( const char* name );
154 };
155 #endif //__vtkGLSLShader_h