Class: SFML::StencilMode
- Inherits:
-
Object
- Object
- SFML::StencilMode
- Defined in:
- ext/graphics/stencil_mode.c,
ext/graphics/stencil_mode.c
Overview
Configures how the stencil buffer is used and updated when drawing, carried on RenderState#stencil_mode.
Instance Attribute Summary collapse
-
#comparison ⇒ Symbol
Returns the comparison used against the stencil buffer.
-
#mask ⇒ Integer
Returns the bitmask applied to the stencil values.
-
#reference ⇒ Integer
Returns the reference value compared against the stencil buffer.
-
#stencil_only ⇒ Boolean
Returns
trueif only the stencil buffer is written to. -
#update_operation ⇒ Symbol
Returns the operation applied when the stencil test passes or fails.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Returns
trueif the two objects are equal. -
#initialize(*args) ⇒ StencilMode
constructor
With no arguments, builds the default stencil mode (always passes, doesn't modify the stencil buffer).
Constructor Details
#new ⇒ StencilMode #new(comparison, update_operation, reference, mask, stencil_only) ⇒ StencilMode
With no arguments, builds the default stencil mode (always passes,
doesn't modify the stencil buffer). comparison and update_operation
accept either a Symbol (see #comparison and #update_operation) or the
matching CSFML Integer constant.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'ext/graphics/stencil_mode.c', line 105
static VALUE StencilMode_initialize(int argc, VALUE* argv, VALUE self) {
sfStencilMode mode = sfStencilMode_default;
if (argc == 5) {
mode.stencilComparison = comparison_from_rb(argv[0]);
mode.stencilUpdateOperation = operation_from_rb(argv[1]);
mode.stencilReference.value = (unsigned int)NUM2UINT(argv[2]);
mode.stencilMask.value = (unsigned int)NUM2UINT(argv[3]);
mode.stencilOnly = RTEST(argv[4]);
} else if (argc != 0) {
raise_invalid_arguments_excepted(5, argc);
}
((StencilMode*)Get_StencilMode_Struct(self))->mode = mode;
return self;
}
|
Instance Attribute Details
#comparison ⇒ Symbol
Returns the comparison used against the stencil buffer.
265 266 267 268 |
# File 'ext/graphics/stencil_mode.c', line 265
static VALUE StencilMode_get_comparison(VALUE self) {
return ID2SYM(rb_intern(
comparison_names[((StencilMode*)Get_StencilMode_Struct(self))->mode.stencilComparison]));
}
|
#mask ⇒ Integer
Returns the bitmask applied to the stencil values.
265 266 267 |
# File 'ext/graphics/stencil_mode.c', line 265
static VALUE StencilMode_get_mask(VALUE self) {
return UINT2NUM(((StencilMode*)Get_StencilMode_Struct(self))->mode.stencilMask.value);
}
|
#reference ⇒ Integer
Returns the reference value compared against the stencil buffer.
265 266 267 |
# File 'ext/graphics/stencil_mode.c', line 265
static VALUE StencilMode_get_reference(VALUE self) {
return UINT2NUM(((StencilMode*)Get_StencilMode_Struct(self))->mode.stencilReference.value);
}
|
#stencil_only ⇒ Boolean
Returns true if only the stencil buffer is written to.
265 266 267 |
# File 'ext/graphics/stencil_mode.c', line 265
static VALUE StencilMode_get_only(VALUE self) {
return BOOL2RB(((StencilMode*)Get_StencilMode_Struct(self))->mode.stencilOnly);
}
|
#update_operation ⇒ Symbol
Returns the operation applied when the stencil test passes or fails.
265 266 267 268 269 |
# File 'ext/graphics/stencil_mode.c', line 265
static VALUE StencilMode_get_operation(VALUE self) {
sfStencilMode mode = ((StencilMode*)Get_StencilMode_Struct(self))->mode;
return ID2SYM(rb_intern(operation_names[mode.stencilUpdateOperation]));
}
|
Instance Method Details
#==(other) ⇒ Boolean
Returns true if the two objects are equal.
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'ext/graphics/stencil_mode.c', line 249
static VALUE StencilMode_eql(VALUE self, VALUE rb_other) {
sfStencilMode a = ((StencilMode*)Get_StencilMode_Struct(self))->mode;
sfStencilMode b;
if (!rb_obj_is_kind_of(rb_other, rb_cStencilMode)) {
return Qfalse;
}
b = ((StencilMode*)Get_StencilMode_Struct(rb_other))->mode;
return BOOL2RB(a.stencilComparison == b.stencilComparison &&
a.stencilUpdateOperation == b.stencilUpdateOperation &&
a.stencilReference.value == b.stencilReference.value &&
a.stencilMask.value == b.stencilMask.value && a.stencilOnly == b.stencilOnly);
}
|