aboutsummaryrefslogtreecommitdiff
path: root/src/shader/util.h
diff options
context:
space:
mode:
authorAdrian Kummerlaender2018-05-26 13:20:47 +0200
committerAdrian Kummerlaender2018-05-26 13:21:40 +0200
commit34052b51e00c939a35294d7085cadb5111484dd3 (patch)
tree03a5b1e350e47e2aa8551393ef67b2124ad50ddb /src/shader/util.h
parentf728e4c8d202de241673a13ce61570b6acb4bba7 (diff)
downloadcomputicle-34052b51e00c939a35294d7085cadb5111484dd3.tar
computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.gz
computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.bz2
computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.lz
computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.xz
computicle-34052b51e00c939a35294d7085cadb5111484dd3.tar.zst
computicle-34052b51e00c939a35294d7085cadb5111484dd3.zip
Separate headers into compilation units
Diffstat (limited to 'src/shader/util.h')
-rw-r--r--src/shader/util.h43
1 files changed, 5 insertions, 38 deletions
diff --git a/src/shader/util.h b/src/shader/util.h
index 7aec674..31224e9 100644
--- a/src/shader/util.h
+++ b/src/shader/util.h
@@ -1,46 +1,13 @@
#pragma once
-#include <iostream>
+#include <string>
-namespace util {
-
-GLint getUniform(GLuint program, const std::string& name) {
- const GLint uniform = glGetUniformLocation(program, name.c_str());
- if ( uniform == -1 ) {
- std::cerr << "Could not bind uniform " << name << std::endl;
- }
- return uniform;
-}
-
-GLint compileShader(const std::string& source, GLenum type) {
- GLint shader = glCreateShader(type);
+#include <GL/glew.h>
- if ( !shader ) {
- std::cerr << "Cannot create a shader of type " << type << std::endl;
- exit(-1);
- }
-
- const char* source_data = source.c_str();
- const int source_length = source.size();
-
- glShaderSource(shader, 1, &source_data, &source_length);
- glCompileShader(shader);
+namespace util {
- GLint compiled;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
- if ( !compiled ) {
- std::cerr << "Cannot compile shader" << std::endl;
- GLint maxLength = 0;
- glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength);
- std::vector<GLchar> errorLog(maxLength);
- glGetShaderInfoLog(shader, maxLength, &maxLength, &errorLog[0]);
- for( auto c : errorLog ) {
- std::cerr << c;
- }
- std::cerr << std::endl;
- }
+GLint getUniform(GLuint program, const std::string& name);
- return shader;
-}
+GLint compileShader(const std::string& source, GLenum type);
}