Window: add resize()

This commit is contained in:
Josh Holtrop 2014-07-27 13:14:30 -04:00
parent f2d3942f8a
commit 9c65624afc

View File

@ -14,6 +14,7 @@ typedef struct
} Window;
static VALUE ruby_class;
static VALUE window_instance;
static void Init_SDL()
{
@ -117,10 +118,22 @@ static VALUE Window_new(VALUE klass)
VALUE rv = Data_Wrap_Struct(ruby_class, NULL, Window_free, window);
rb_obj_call_init(rv, 0, NULL);
/* TODO: remove window_instance and map SDL_Window * to Window Ruby object
* to support multiple windows. */
window_instance = rv;
return rv;
}
static void resize()
{
GLint viewport_size[2];
Window * window;
Data_Get_Struct(window_instance, Window, window);
SDL_GetWindowSize(window->sdl_window, &viewport_size[0], &viewport_size[1]);
glViewport(0, 0, viewport_size[0], viewport_size[1]);
}
static VALUE Window_event_loop(VALUE klass)
{
SDL_Event event;
@ -142,7 +155,7 @@ static VALUE Window_event_loop(VALUE klass)
// draw();
break;
case SDL_WINDOWEVENT_RESIZED:
// resize();
resize();
// draw();
break;
}