finish off GLShader_new()

This commit is contained in:
Josh Holtrop 2014-07-22 20:24:24 -04:00
parent 864c5c2930
commit 43487eb415

View File

@ -80,11 +80,28 @@ static void GLShader_free(void * ptr)
static VALUE GLShader_new(VALUE klass, VALUE type, VALUE source)
{
GLShader * glshader = new GLShader();
GLenum shader_type;
#if 0
/* TODO */
glshader->id = create_shader();
#endif
if (type == ID2SYM(rb_intern("vertex")))
{
shader_type = GL_VERTEX_SHADER;
}
else if (type == ID2SYM(rb_intern("fragment")))
{
shader_type = GL_FRAGMENT_SHADER;
}
else
{
type = rb_funcall(type, rb_intern("inspect"), 0);
const char * type_cstr = StringValueCStr(type);
rb_raise(rb_eRuntimeError,
"Unknown shader type: %s",
type_cstr);
}
glshader->id = create_shader(shader_type,
RSTRING_PTR(source),
RSTRING_LEN(source));
return Data_Wrap_Struct(klass, NULL, GLShader_free, glshader);
}