]> git.localhorst.tv Git - blank.git/blobdiff - src/shader.cpp
add SDL2_image library
[blank.git] / src / shader.cpp
index 985b96e5faf9981374f776bffe74fbb25d6a0430..c42e6fcaabc272f0c06f4ea4203cad6d1bea6102 100644 (file)
@@ -1,6 +1,7 @@
 #include "shader.hpp"
 
 #include <algorithm>
+#include <iostream>
 #include <memory>
 #include <ostream>
 #include <stdexcept>
@@ -93,6 +94,19 @@ Program::~Program() {
 }
 
 
+const Shader &Program::LoadShader(GLenum type, const GLchar *src) {
+       shaders.emplace_back(type);
+       Shader &shader = shaders.back();
+       shader.Source(src);
+       shader.Compile();
+       if (!shader.Compiled()) {
+               shader.Log(std::cerr);
+               throw std::runtime_error("compile shader");
+       }
+       Attach(shader);
+       return shader;
+}
+
 void Program::Attach(Shader &shader) {
        shader.AttachToProgram(handle);
 }