Class: SFML::ContextSettings
- Inherits:
-
Object
- Object
- SFML::ContextSettings
- Defined in:
- ext/window/context_settings.c,
ext/window/context_settings.c
Overview
Settings requested when creating a Window or Context: depth/stencil buffer sizes, antialiasing level, requested OpenGL version, and attribute flags.
The +depth_bits+/+stencil_bits+/+antialiasing_level+/+major_version+/
minor_version accessors are generated through a shared C macro, so
(unlike this class's other accessors) they are documented here rather than
above their own definitions.
Instance Attribute Summary collapse
-
#antialiasing_level ⇒ Integer
Requested antialiasing level.
-
#depth_bits ⇒ Integer
Number of bits per pixel requested for the depth buffer.
-
#major_version ⇒ Integer
Requested OpenGL major version.
-
#minor_version ⇒ Integer
Requested OpenGL minor version.
-
#stencil_bits ⇒ Integer
Number of bits per pixel requested for the stencil buffer.
Instance Method Summary collapse
-
#attribute_flags ⇒ Array<Symbol>
Returns the context attribute flags as a list of symbols.
-
#attribute_flags=(value) ⇒ Integer, Array<Symbol>
Sets the context attribute flags from
value, an Integer bitmask or a Symbol/Array of:coreand:debug. -
#new(depth_bits = 0, stencil_bits = 0, antialiasing_level = 0, major_version) ⇒ ContextSettings
constructor
1, minor_version = 1, flags = :default, srgb_capable = false) -> ContextSettings.
-
#srgb_capable=(value) ⇒ Boolean
Requests sRGB-capable framebuffers when
valueistrue. -
#srgb_capable? ⇒ Boolean
Returns
trueif the context was created with sRGB-capable framebuffers.
Constructor Details
#new(depth_bits = 0, stencil_bits = 0, antialiasing_level = 0, major_version) ⇒ ContextSettings
1, minor_version = 1, flags = :default, srgb_capable = false) -> ContextSettings
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/window/context_settings.c', line 64
static VALUE ContextSettings_initialize(int argc, VALUE* argv, VALUE self) {
sfContextSettings settings = {0, 0, 0, 1, 1, sfContextDefault, false};
VALUE rb_depth, rb_stencil, rb_antialiasing, rb_major, rb_minor, rb_flags, rb_srgb;
rb_scan_args(argc, argv, "07", &rb_depth, &rb_stencil, &rb_antialiasing, &rb_major, &rb_minor,
&rb_flags, &rb_srgb);
if (!NIL_P(rb_depth)) {
settings.depthBits = (unsigned int)NUM2UINT(rb_depth);
}
if (!NIL_P(rb_stencil)) {
settings.stencilBits = (unsigned int)NUM2UINT(rb_stencil);
}
if (!NIL_P(rb_antialiasing)) {
settings.antiAliasingLevel = (unsigned int)NUM2UINT(rb_antialiasing);
}
if (!NIL_P(rb_major)) {
settings.majorVersion = (unsigned int)NUM2UINT(rb_major);
}
if (!NIL_P(rb_minor)) {
settings.minorVersion = (unsigned int)NUM2UINT(rb_minor);
}
if (!NIL_P(rb_flags)) {
uint32_t flags = 0;
if (RB_INTEGER_TYPE_P(rb_flags)) {
flags = (uint32_t)NUM2UINT(rb_flags);
} else if (SYMBOL_P(rb_flags) || RB_TYPE_P(rb_flags, T_STRING)) {
rb_flags = rb_ary_new_from_args(1, rb_flags);
}
if (RB_TYPE_P(rb_flags, T_ARRAY)) {
for (long i = 0; i < RARRAY_LEN(rb_flags); i++) {
VALUE entry = rb_ary_entry(rb_flags, i);
const char* name = context_flag_name(entry);
if (strcmp(name, "core") == 0) {
flags |= sfContextCore;
} else if (strcmp(name, "debug") == 0) {
flags |= sfContextDebug;
} else if (strcmp(name, "default") != 0) {
rb_raise(rb_eArgError, "unknown context attribute: %s", name);
}
}
}
settings.attributeFlags = flags;
}
if (!NIL_P(rb_srgb)) {
settings.sRgbCapable = RTEST(rb_srgb);
}
((ContextSettings*)Get_ContextSettings_Struct(self))->settings = settings;
return self;
}
|
Instance Attribute Details
#antialiasing_level ⇒ Integer
Requested antialiasing level.
#depth_bits ⇒ Integer
Number of bits per pixel requested for the depth buffer.
#major_version ⇒ Integer
Requested OpenGL major version.
#minor_version ⇒ Integer
Requested OpenGL minor version.
#stencil_bits ⇒ Integer
Number of bits per pixel requested for the stencil buffer.
Instance Method Details
#attribute_flags ⇒ Array<Symbol>
Returns the context attribute flags as a list of symbols.
#attribute_flags=(value) ⇒ Integer, Array<Symbol>
Sets the context attribute flags from value, an Integer bitmask or a
Symbol/Array of :core and :debug.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'ext/window/context_settings.c', line 183
static VALUE ContextSettings_set_attribute_flags(VALUE self, VALUE rb_value) {
ContextSettings* settings = Get_ContextSettings_Struct(self);
uint32_t flags = 0;
rb_check_frozen(self);
if (RB_INTEGER_TYPE_P(rb_value)) {
flags = (uint32_t)NUM2UINT(rb_value);
} else {
VALUE array = RB_TYPE_P(rb_value, T_ARRAY) ? rb_value : rb_ary_new_from_args(1, rb_value);
for (long i = 0; i < RARRAY_LEN(array); i++) {
VALUE entry = rb_ary_entry(array, i);
const char* name = context_flag_name(entry);
if (strcmp(name, "core") == 0) {
flags |= sfContextCore;
} else if (strcmp(name, "debug") == 0) {
flags |= sfContextDebug;
}
}
}
settings->settings.attributeFlags = flags;
return rb_value;
}
|
#srgb_capable=(value) ⇒ Boolean
Requests sRGB-capable framebuffers when value is true.
228 229 230 231 232 |
# File 'ext/window/context_settings.c', line 228
static VALUE ContextSettings_set_srgb(VALUE self, VALUE rb_value) {
rb_check_frozen(self);
((ContextSettings*)Get_ContextSettings_Struct(self))->settings.sRgbCapable = RTEST(rb_value);
return rb_value;
}
|
#srgb_capable? ⇒ Boolean
Returns true if the context was created with sRGB-capable framebuffers.
217 218 219 |
# File 'ext/window/context_settings.c', line 217
static VALUE ContextSettings_get_srgb(VALUE self) {
return BOOL2RB(((ContextSettings*)Get_ContextSettings_Struct(self))->settings.sRgbCapable);
}
|