-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglslprogram.h
executable file
·127 lines (109 loc) · 2.85 KB
/
glslprogram.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef GLSLPROGRAM_H
#define GLSLPROGRAM_H
#include <ctype.h>
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#ifdef WIN32
#include <windows.h>
#endif
//#include "glew.h"
//#include <GL/gl.h>
//#include <GL/glu.h>
/* TODO to make this work for opengl 3.X feature */
#include <OpenGL/gl3.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
//#include "glut.h"
#include <map>
#include <stdarg.h>
#ifndef GL_COMPUTE_SHADER
#define GL_COMPUTE_SHADER 0x91B9
#endif
inline int GetOSU( int flag )
{
int i;
glGetIntegerv( flag, &i );
return i;
}
void CheckGlErrors( const char* );
class GLSLProgram
{
private:
std::map<char *, int> AttributeLocs;
char * Cfile;
unsigned int Cshader;
char * Ffile;
unsigned int Fshader;
char * Gfile;
GLuint Gshader;
bool IncludeGstap;
GLenum InputTopology;
GLenum OutputTopology;
GLuint Program;
char * TCfile;
GLuint TCshader;
char * TEfile;
GLuint TEshader;
std::map<char *, int> UniformLocs;
bool Valid;
char * Vfile;
GLuint Vshader;
bool Verbose;
static int CurrentProgram;
void AttachShader( GLuint );
bool CanDoBinaryFiles;
bool CanDoComputeShaders;
bool CanDoFragmentShaders;
bool CanDoGeometryShaders;
bool CanDoTessControlShaders;
bool CanDoTessEvaluationShaders;
bool CanDoVertexShaders;
int CompileShader( GLuint );
bool CreateHelper( char *, ... );
int GetAttributeLocation( char * );
int GetUniformLocation( char * );
public:
GLSLProgram( );
bool Create( char *, char * = NULL, char * = NULL, char * = NULL, char * = NULL, char * = NULL );
void DispatchCompute( GLuint, GLuint = 1, GLuint = 1 );
bool IsExtensionSupported( const char * );
bool IsNotValid( );
bool IsValid( );
void LoadBinaryFile( char * );
void LoadProgramBinary( const char *, GLenum );
void SaveBinaryFile( char * );
void SaveProgramBinary( const char *, GLenum * );
void SetAttributeVariable( char *, int );
void SetAttributeVariable( char *, float );
void SetAttributeVariable( char *, float, float, float );
void SetAttributeVariable( char *, float[3] );
#ifdef VEC3_H
void SetAttributeVariable( char *, Vec3& );
#endif
#ifdef VERTEX_ARRAY_H
void SetAttributeVariable( char *, VertexArray&, GLenum );
#endif
#ifdef VERTEX_BUFFER_OBJECT_H
void SetAttributeVariable( char *, VertexBufferObject&, GLenum );
#endif
void SetGstap( bool );
void SetInputTopology( GLenum );
void SetOutputTopology( GLenum );
void SetUniformVariable( char *, int );
void SetUniformVariable( char *, float );
void SetUniformVariable( char *, float, float, float );
void SetUniformVariable( char *, float[3] );
#ifdef VEC3_H
void SetUniformVariable( char *, Vec3& );
#endif
#ifdef MATRIX4_H
void SetUniformVariable( char *, Matrix4& );
#endif
void SetVerbose( bool );
void Use( );
void Use( GLuint );
void UseFixedFunction( );
void WriteBinary( const char * );
};
#endif // #ifndef GLSLPROGRAM_H