Class: Ray::BufferRenderer
- Inherits:
-
Object
- Object
- Ray::BufferRenderer
- Defined in:
- ext/buffer_renderer.c,
lib/ray/buffer_renderer.rb,
ext/buffer_renderer.c
Overview
Buffer renderers are a way to draw many drawable quickly, assuming they are not updated too often. It makes things quite faster if you have many drawables that won’t need to be updated for a loong time.
It simply uses drawables to fill its own buffer, and ask those drawables to draw themselves from it.
Instance Method Summary collapse
-
#clear ⇒ Object
Removes all the drawables from the renderer.
- #drawables ⇒ Object
-
#initialize(type, vtype) ⇒ Object
constructor
Creates a new buffer renderer.
-
#push(object) ⇒ Object
(also: #<<)
Adds a drawable to render.
-
#update ⇒ Object
Upadates the buffer.
Constructor Details
#initialize(type, vtype) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'ext/buffer_renderer.c', line 59
static
VALUE ray_buffer_renderer_init(VALUE self, VALUE type, VALUE vtype) {
rb_iv_set(self, "@drawables", rb_ary_new());
say_buffer_renderer **ptr;
Data_Get_Struct(self, say_buffer_renderer*, ptr);
*ptr = say_buffer_renderer_create(ray_buf_type(type),
ray_get_vtype(vtype));
return self;
}
|
Instance Method Details
#clear ⇒ Object
Removes all the drawables from the renderer.
73 74 75 76 77 78 |
# File 'ext/buffer_renderer.c', line 73 static VALUE ray_buffer_renderer_clear(VALUE self) { say_buffer_renderer_clear(ray_rb2buf_renderer(self)); rb_ary_clear(rb_iv_get(self, "@drawables")); return self; } |
#drawables ⇒ Object
5 6 7 |
# File 'lib/ray/buffer_renderer.rb', line 5 def drawables @drawables.dup # don't let evil users touch this! end |
#push(object) ⇒ Object Also known as: <<
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'ext/buffer_renderer.c', line 87
static
VALUE ray_buffer_renderer_push(VALUE self, VALUE obj) {
rb_check_frozen(self);
if (!say_buffer_renderer_push(ray_rb2buf_renderer(self),
ray_rb2drawable(obj))) {
rb_raise(rb_eRuntimeError, "%s", say_error_get_last());
}
rb_ary_push(rb_iv_get(self, "@drawables"), obj);
return self;
}
|
#update ⇒ Object
Upadates the buffer
102 103 104 105 106 |
# File 'ext/buffer_renderer.c', line 102 static VALUE ray_buffer_renderer_update(VALUE self) { say_buffer_renderer_update(ray_rb2buf_renderer(self)); return self; } |