]> git.localhorst.tv Git - blank.git/blobdiff - src/graphics/shader.cpp
move common exceptions to app/error
[blank.git] / src / graphics / shader.cpp
index 85f0184684eb791ba0f24c79a63c661a39378f1f..5a07143f13e21fa8ae28802a6c4a25827451ac4f 100644 (file)
@@ -9,7 +9,7 @@
 #include "ArrayTexture.hpp"
 #include "CubeMap.hpp"
 #include "Texture.hpp"
-#include "../app/init.hpp"
+#include "../app/error.hpp"
 
 #include <algorithm>
 #include <iostream>
 #include <glm/gtc/type_ptr.hpp>
 
 
-namespace {
-
-void gl_error(std::string msg) {
-       const GLubyte *errBegin = gluErrorString(glGetError());
-       if (errBegin && *errBegin != '\0') {
-               const GLubyte *errEnd = errBegin;
-               while (*errEnd != '\0') {
-                       ++errEnd;
-               }
-               msg += ": ";
-               msg.append(errBegin, errEnd);
-       }
-       throw std::runtime_error(msg);
-}
-
-}
-
 namespace blank {
 
 Shader::Shader(GLenum type)
 : handle(glCreateShader(type)) {
        if (handle == 0) {
-               gl_error("glCreateShader");
+               throw GLError("glCreateShader");
        }
 }
 
@@ -95,7 +78,7 @@ void Shader::AttachToProgram(GLuint id) const noexcept {
 Program::Program()
 : handle(glCreateProgram()) {
        if (handle == 0) {
-               gl_error("glCreateProgram");
+               throw GLError("glCreateProgram");
        }
 }