AnimEngine
All Classes Namespaces Functions
GLSL.h
1 //
2 // Many useful helper functions for GLSL shaders - gleaned from various sources including orange book
3 // Created by zwood on 2/21/10.
4 // Modified by sueda 10/15/15.
5 // Modified by kjyager 11/20/17
6 //
7 
8 #pragma once
9 #ifndef __GLSL__
10 #define __GLSL__
11 
12 #include <glad/glad.h>
13 
15 // For printing out the current file and line number //
17 #include <sstream>
18 
19 template <typename T>
20 std::string NumberToString(T x)
21 {
22  std::ostringstream ss;
23  ss << x;
24  return ss.str();
25 }
26 
27 #define GET_FILE_LINE (std::string(__FILE__) + ":" + NumberToString(__LINE__)).c_str()
28 
30 namespace GLSL {
31 
32  void checkError(const char *str = 0);
33  void printProgramInfoLog(GLuint program);
34  void printShaderInfoLog(GLuint shader);
35  void checkVersion();
36  int textFileWrite(const char *filename, char *s);
37  char *textFileRead(const char *filename);
38  char *textFileRead(FILE* file);
39  GLint getAttribLocation(const GLuint program, const char varname[], bool verbose = true);
40  GLint getUniformLocation(const GLuint program, const char varname[], bool verbose = true);
41  void enableVertexAttribArray(const GLint handle);
42  void disableVertexAttribArray(const GLint handle);
43  void vertexAttribPointer(const GLint handle, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
44 
45  bool compileAndCheck(GLuint shader, bool verbose);
46  bool linkAndCheck(GLuint program, bool verbose);
47 }
48 
49 #endif
Definition: GLSL.cpp:14