From b455fb9e158ee7990f107e9d67f2bac084a460c7 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 26 Jul 2014 11:16:35 -0400 Subject: [PATCH] load GL buffers --- src/Window.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Window.cc b/src/Window.cc index 9900f95..7db79bf 100644 --- a/src/Window.cc +++ b/src/Window.cc @@ -1,4 +1,5 @@ #include "gl3w.h" +#include "GLBuffer.h" #include "ruby.h" #include "Window.h" #include @@ -9,6 +10,7 @@ typedef struct { SDL_Window * sdl_window; + GLBufferRef rect_buffer; } Window; static VALUE ruby_class; @@ -30,6 +32,23 @@ static void Init_SDL() initialized = true; } +static void load_gl_buffers(Window * window) +{ + static const GLint rect_coords[4][2] = { + {0, 0}, + {1, 0}, + {0, 1}, + {1, 1}, + }; + + window->rect_buffer = new GLBuffer(); + if (!window->rect_buffer->create(GL_ARRAY_BUFFER, GL_STATIC_DRAW, + &rect_coords, sizeof(rect_coords))) + { + rb_raise(rb_eRuntimeError, "Failed to create rectangle VBO"); + } +} + static void Init_OpenGL() { static bool initialized = false; @@ -92,6 +111,8 @@ static VALUE Window_new(VALUE klass) Init_OpenGL(); + load_gl_buffers(window); + one_created = true; VALUE rv = Data_Wrap_Struct(ruby_class, NULL, Window_free, window);