X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=util.cpp;h=c18f00949d1e2d1bca75bd3945ac2fcbc82e6811;hp=b427625219964924db9a88a4f9336523abee7ac8;hb=a592c55caca0fb654bad4ec43b84c46abcee21c2;hpb=928743085b7f0f88b3e1b0e59e2d7ebec7816bd2 diff --git a/util.cpp b/util.cpp index b427625..c18f009 100644 --- a/util.cpp +++ b/util.cpp @@ -1,5 +1,12 @@ -#include +#define GL_GLEXT_PROTOTYPES 1 + +#include +#include +#include +#include + +#include #include "util.h" void hsv2rgb(float h, float s, float v, float *r, float *g, float *b) @@ -57,3 +64,27 @@ std::string read_file(const std::string &filename) return std::string(buf, len); } + +GLhandleARB compile_shader(const std::string &shader_src, GLenum type) +{ + GLhandleARB obj = glCreateShaderObjectARB(type); + const GLchar* source[] = { shader_src.data() }; + const GLint length[] = { shader_src.size() }; + glShaderSource(obj, 1, source, length); + glCompileShader(obj); + + GLchar info_log[4096]; + GLsizei log_length = sizeof(info_log) - 1; + glGetShaderInfoLog(obj, log_length, &log_length, info_log); + info_log[log_length] = 0; + printf("shader compile log: %s\n", info_log); + + GLint status; + glGetShaderiv(obj, GL_COMPILE_STATUS, &status); + if (status == GL_FALSE) { + exit(1); + } + + return obj; +} +