Class: Ray::ImageTarget
- Defined in:
- ext/image_target.c,
lib/ray/image_target.rb,
ext/image_target.c
Overview
Image targets are objects that allow to draw any drawable object on an image instead of doing on-screen rendering. Off-screen rendering can be useful to pre-render some objects.
Notice image targets modify the image they are drawing on directly. You may therefore not want to draw on a cached image, but rather on a copy thereof.
Class Method Summary collapse
-
.available? ⇒ true, false
Checks availability of image targets.
-
.unbind ⇒ Object
Unbinds any image target.
Instance Method Summary collapse
-
#bind ⇒ Object
Binds an image target to draw directly on it.
- #image ⇒ Object
-
#image=(img) ⇒ Object
Sets the image this object will draw on.
-
#initialize(image = nil) {|target| ... } ⇒ ImageTarget
constructor
A new instance of ImageTarget.
- #pretty_print(q) ⇒ Object
-
#update ⇒ Object
Updates the content of the image target.
Methods inherited from Target
#[], #clear, #clip, #default_view, #draw, #make_current, #rect, #shader, #size, #to_image, #turtle, #view, #view=, #viewport_for, #with_view
Methods included from PP
Constructor Details
#initialize(image = nil) {|target| ... } ⇒ ImageTarget
Returns a new instance of ImageTarget.
7 8 9 10 11 12 13 |
# File 'lib/ray/image_target.rb', line 7 def initialize(image = nil) self.image = image if image if block_given? yield self end end |
Class Method Details
.available? ⇒ true, false
Checks availability of image targets
Image targets are only part of OpenGL core since OpenGL 3 (although they may be supported as an extension in older versions).
101 102 103 |
# File 'ext/image_target.c', line 101 VALUE ray_image_target_available(VALUE self) { return say_image_target_is_available() ? Qtrue : Qfalse; } |
.unbind ⇒ Object
Unbinds any image target
This is rarely needed, as this method gets called automatically when a window is bound, and because windows and image targets do not share the same OpenGL context.
83 84 85 86 87 88 89 90 91 |
# File 'ext/image_target.c', line 83
VALUE ray_image_target_unbind(VALUE self) {
/*
* No need for an error when this is not supported, because it just means
* we don't need to unbind anything.
*/
if (say_image_target_is_available())
say_image_target_unbind();
return Qnil;
}
|
Instance Method Details
#bind ⇒ Object
Binds an image target to draw directly on it
This method is only useful when performing low-level OpenGL rendering. It is different from Target#make_current because it doesn’t use the target’s own OpenGL context. Instead, it will use the current context (ensuring there is one).
Notice binding the image target (and, therefore, making it the current target) clears the depth buffer of the image, so that everything will be rendered over what was already on the image.
71 72 73 74 |
# File 'ext/image_target.c', line 71 VALUE ray_image_target_bind(VALUE self) { say_image_target_bind(ray_rb2image_target(self)); return self; } |
#image ⇒ Object
39 40 41 |
# File 'ext/image_target.c', line 39 VALUE ray_image_target_image(VALUE self) { return rb_iv_get(self, "@image"); } |
#image=(img) ⇒ Object
31 32 33 34 35 36 |
# File 'ext/image_target.c', line 31
VALUE ray_image_target_set_image(VALUE self, VALUE img) {
rb_check_frozen(self);
say_image_target_set_image(ray_rb2image_target(self), ray_rb2image(img));
rb_iv_set(self, "@image", img);
return img;
}
|
#pretty_print(q) ⇒ Object
15 16 17 |
# File 'lib/ray/image_target.rb', line 15 def pretty_print(q) super q, ["image"] end |
#update ⇒ Object
54 55 56 57 |
# File 'ext/image_target.c', line 54 VALUE ray_image_target_update(VALUE self) { say_image_target_update(ray_rb2image_target(self)); return self; } |