equal
deleted
inserted
replaced
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 */ |
16 */ |
17 |
17 |
18 #pragma once |
18 #pragma once |
19 |
19 |
|
20 #include <iostream> |
20 #include <string> |
21 #include <string> |
21 #include <stdexcept> |
22 #include <stdexcept> |
22 |
23 |
23 #include <epoxy/gl.h> |
24 #include <epoxy/gl.h> |
24 #include <epoxy/glx.h> |
25 #include <epoxy/glx.h> |
25 #include <GL/glu.h> |
26 #include <GL/glu.h> |
26 |
27 |
27 #include <glm/glm.hpp> |
28 #include <glm/glm.hpp> |
28 #include <glm/ext.hpp> |
29 #include <glm/ext.hpp> |
29 |
30 |
|
31 #include "Shader.h" |
|
32 |
30 inline |
33 inline |
31 void quads(GLfloat tx, GLfloat ty, GLfloat x, GLfloat y, GLfloat z) { |
34 void quads(GLfloat tx, GLfloat ty, GLfloat x, GLfloat y, GLfloat z) { |
32 glTexCoord2f(tx, ty); |
35 glTexCoord2f(tx, ty); |
33 glVertex3f(x, y, z); |
36 glVertex3f(x, y, z); |
34 } |
37 } |
35 |
38 |
36 inline |
39 inline |
37 void checkError(std::ostream* out) { |
40 void checkError(std::ostream* out = nullptr) { |
38 GLenum code = glGetError(); |
41 GLenum code = glGetError(); |
39 if (code == GL_NO_ERROR) { |
42 if (code == GL_NO_ERROR) { |
40 if (out) *out << "GL check: OK" << std::endl; |
43 if (out) *out << "GL check: OK" << std::endl; |
41 } else { |
44 } else { |
42 const char* string = (const char*) gluErrorString(code); |
45 const char* string = (const char*) gluErrorString(code); |
44 else throw std::logic_error(std::string("GL error: ") + string); |
47 else throw std::logic_error(std::string("GL error: ") + string); |
45 } |
48 } |
46 } |
49 } |
47 |
50 |
48 inline |
51 inline |
49 GLenum toShaderType(const std::string& fileName) { |
52 Shader::Type toShaderType(const std::string& fileName) { |
50 if (fileName.ends_with(".vert")) return GL_VERTEX_SHADER; |
53 if (fileName.ends_with(".vert")) return Shader::Type::VERTEX; |
51 else if (fileName.ends_with(".frag")) return GL_FRAGMENT_SHADER; |
54 else if (fileName.ends_with(".frag")) return Shader::Type::FRAGMENT; |
52 else throw std::invalid_argument("Expecting *.vert or *.frag file"); |
55 else throw std::invalid_argument("Expecting *.vert or *.frag file"); |
53 } |
56 } |
54 |
57 |
55 inline |
58 inline |
56 void dump(const char* name, const glm::vec3& value) { |
59 void dump(const char* name, const glm::vec3& value) { |