-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvtkPRISMGlslShader.h
60 lines (47 loc) · 1.97 KB
/
vtkPRISMGlslShader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*=========================================================================
Ibis Neuronav
Copyright (c) Simon Drouin, Anna Kochanowska, Louis Collins.
All rights reserved.
See Copyright.txt or http://ibisneuronav.org/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Thanks to Simon Drouin for writing this class
#ifndef __GlslShader_h_
#define __GlslShader_h_
#include <string>
#include <vector>
#include "vtkObject.h"
class vtkMatrix4x4;
class GlslShader : public vtkObject
{
public:
GlslShader();
~GlslShader();
void AddShaderMemSource( const char * src );
void AddVertexShaderMemSource( const char * src );
void Reset();
bool Init();
std::string GetErrorMessage() { return m_errorMessage; }
bool UseProgram( bool use );
bool SetVariable( const char * name, int value );
bool SetVariable( const char * name, int count, int * values );
bool SetVariable( const char * name, float value );
bool SetVariable( const char * name, double value );
bool SetVariable( const char * name, int val1, int val2 ); // set a ivec2
bool SetVariable( const char * name, float val1, float val2 ); // set a vec2
bool SetVariable( const char * name, float val1, float val2, float val3 ); // set a vec3
bool SetVariable( const char * name, vtkMatrix4x4 * mat ); // set a mat4
protected:
bool CreateAndCompileShader( unsigned shaderType, unsigned & shaderId, std::vector< std::string > & memSources );
void Clear();
std::vector< std::string > m_memSources;
std::vector< std::string > m_vertexMemSources;
unsigned m_glslShader;
unsigned m_glslVertexShader;
unsigned m_glslProg;
bool m_init;
std::string m_errorMessage;
};
#endif