GLProgram: define initialize in ruby, allow attaching shaders
This commit is contained in:
parent
bd188f9e83
commit
6a22ae4ad4
8
runtime/lib/gl_program.rb
Normal file
8
runtime/lib/gl_program.rb
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
class GLProgram
|
||||||
|
# @overload initialize(*shaders, options = {})
|
||||||
|
#
|
||||||
|
# @param shaders [Array<GLShader>] Shaders to attach to the program.
|
||||||
|
# @param options [Hash] Optional parameters.
|
||||||
|
def initialize(*args)
|
||||||
|
end
|
||||||
|
end
|
@ -4,6 +4,7 @@ end
|
|||||||
|
|
||||||
def load_lib_files
|
def load_lib_files
|
||||||
require "runtime"
|
require "runtime"
|
||||||
|
require "gl_program"
|
||||||
end
|
end
|
||||||
|
|
||||||
def main(argv)
|
def main(argv)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "GLProgram.h"
|
#include "GLProgram.h"
|
||||||
|
#include "GLShader.h"
|
||||||
#include "ruby.h"
|
#include "ruby.h"
|
||||||
#include "gl3w.h"
|
#include "gl3w.h"
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ static void GLProgram_free(void * ptr)
|
|||||||
delete program;
|
delete program;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE GLProgram_new(VALUE klass)
|
static VALUE GLProgram_new(int argc, VALUE * argv, VALUE klass)
|
||||||
{
|
{
|
||||||
GLProgram * glprogram = new GLProgram();
|
GLProgram * glprogram = new GLProgram();
|
||||||
|
|
||||||
@ -31,26 +32,29 @@ static VALUE GLProgram_new(VALUE klass)
|
|||||||
rb_raise(rb_eRuntimeError, "Error allocating GL program object");
|
rb_raise(rb_eRuntimeError, "Error allocating GL program object");
|
||||||
}
|
}
|
||||||
|
|
||||||
return Data_Wrap_Struct(klass, NULL, GLProgram_free, glprogram);
|
VALUE rv = Data_Wrap_Struct(klass, NULL, GLProgram_free, glprogram);
|
||||||
|
rb_obj_call_init(rv, argc, argv);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE GLProgram_attach_shader(VALUE self, VALUE gl_shader)
|
||||||
|
{
|
||||||
|
GLProgram * glprogram;
|
||||||
|
Data_Get_Struct(self, GLProgram, glprogram);
|
||||||
|
glAttachShader(glprogram->id, GLShader_id(gl_shader));
|
||||||
|
|
||||||
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLProgram_Init()
|
void GLProgram_Init()
|
||||||
{
|
{
|
||||||
ruby_class = rb_define_class("GLProgram", rb_cObject);
|
ruby_class = rb_define_class("GLProgram", rb_cObject);
|
||||||
rb_define_singleton_method(ruby_class, "new", (VALUE(*)(...))GLProgram_new, 0);
|
rb_define_singleton_method(ruby_class, "new", (VALUE(*)(...))GLProgram_new, -1);
|
||||||
rb_define_attr(ruby_class, "id", 0, 1);
|
rb_define_method(ruby_class, "attach_shader", (VALUE(*)(...))GLProgram_attach_shader, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
GLProgram & GLProgram::attach_shader(GLShaderRef shader)
|
|
||||||
{
|
|
||||||
if (m_id > 0u)
|
|
||||||
{
|
|
||||||
glAttachShader(m_id, shader->get_id());
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLProgram & GLProgram::bind_attribute(const char * attribute, GLuint index)
|
GLProgram & GLProgram::bind_attribute(const char * attribute, GLuint index)
|
||||||
{
|
{
|
||||||
if (m_id > 0u)
|
if (m_id > 0u)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user