author | František Kučera <franta-hg@frantovo.cz> |
Sun, 03 Dec 2023 19:22:25 +0100 | |
branch | v_0 |
changeset 17 | f53a040bdc89 |
parent 6 | fd93a46db15b |
permissions | -rw-r--r-- |
0 | 1 |
/** |
2 |
* ShaderShark |
|
3 |
* Copyright © 2023 František Kučera (Frantovo.cz, GlobalCode.info) |
|
4 |
* |
|
5 |
* This program is free software: you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation, version 3 of the License. |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
*/ |
|
17 |
||
18 |
#pragma once |
|
19 |
||
5
ee4ba9f5a053
OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
20 |
#include <iostream> |
0 | 21 |
#include <string> |
22 |
#include <stdexcept> |
|
23 |
||
24 |
#include <epoxy/gl.h> |
|
25 |
#include <epoxy/glx.h> |
|
26 |
#include <GL/glu.h> |
|
27 |
||
28 |
#include <glm/glm.hpp> |
|
29 |
#include <glm/ext.hpp> |
|
30 |
||
5
ee4ba9f5a053
OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
31 |
#include "Shader.h" |
ee4ba9f5a053
OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
32 |
|
0 | 33 |
inline |
34 |
void quads(GLfloat tx, GLfloat ty, GLfloat x, GLfloat y, GLfloat z) { |
|
35 |
glTexCoord2f(tx, ty); |
|
36 |
glVertex3f(x, y, z); |
|
37 |
} |
|
38 |
||
39 |
inline |
|
5
ee4ba9f5a053
OOP for Shader and ShaderProgram
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
40 |
void checkError(std::ostream* out = nullptr) { |
0 | 41 |
GLenum code = glGetError(); |
42 |
if (code == GL_NO_ERROR) { |
|
43 |
if (out) *out << "GL check: OK" << std::endl; |
|
44 |
} else { |
|
45 |
const char* string = (const char*) gluErrorString(code); |
|
46 |
if (out) *out << "GL check: " << string << std::endl; |
|
47 |
else throw std::logic_error(std::string("GL error: ") + string); |
|
48 |
} |
|
49 |
} |
|
50 |
||
51 |
inline |
|
52 |
void dump(const char* name, const glm::vec3& value) { |
|
53 |
std::cerr << "dump: " << name << " = [" |
|
54 |
<< value.x << ", " |
|
55 |
<< value.y << ", " |
|
56 |
<< value.z << "]" << std::endl; |
|
57 |
} |