store GL programs as GLProgram pointers instead of GLuints

This commit is contained in:
Josh Holtrop 2014-07-29 20:27:06 -04:00
parent 914f08952b
commit 16ae435cbb
3 changed files with 9 additions and 10 deletions

View File

@ -134,10 +134,3 @@ void GLProgram_Init()
rb_define_method(ruby_class, "link", (VALUE(*)(...))GLProgram_link, 0); rb_define_method(ruby_class, "link", (VALUE(*)(...))GLProgram_link, 0);
rb_define_method(ruby_class, "load_uniform_location", (VALUE(*)(...))GLProgram_load_uniform_location, 1); rb_define_method(ruby_class, "load_uniform_location", (VALUE(*)(...))GLProgram_load_uniform_location, 1);
} }
GLuint GLProgram_GetID(VALUE program)
{
GLProgram * glprogram;
Data_Get_Struct(program, GLProgram, glprogram);
return glprogram->id;
}

View File

@ -21,6 +21,12 @@ struct GLProgram
}; };
void GLProgram_Init(); void GLProgram_Init();
GLuint GLProgram_GetID(VALUE program);
static inline GLProgram * GLProgram_FromRuby(VALUE glprogram_obj)
{
GLProgram * glprogram;
Data_Get_Struct(glprogram_obj, GLProgram, glprogram);
return glprogram;
}
#endif #endif

View File

@ -26,7 +26,7 @@ typedef struct
{ {
SDL_Window * sdl_window; SDL_Window * sdl_window;
GLBufferRef rect_buffer; GLBufferRef rect_buffer;
GLuint programs[PROGRAM_COUNT]; GLProgram * programs[PROGRAM_COUNT];
} Window; } Window;
static VALUE ruby_class; static VALUE ruby_class;
@ -159,7 +159,7 @@ static VALUE Window_new(VALUE klass)
ID2SYM(rb_intern(program_names[i]))); ID2SYM(rb_intern(program_names[i])));
if (RTEST(program)) if (RTEST(program))
{ {
window->programs[i] = GLProgram_GetID(program); window->programs[i] = GLProgram_FromRuby(program);
} }
else else
{ {