Module: Ray::GL
- Defined in:
- lib/ray/gl/vertex.rb,
lib/ray/gl/int_array.rb,
ext/gl.c
Defined Under Namespace
Classes: Buffer, IndexBuffer, IntArray, Vertex
Constant Summary
collapse
- Primitives =
Returns Available primitives.
ray_gl_primitives
Class Method Summary
collapse
-
.callback=(proc) ⇒ Object
Sets the proc called by OpenGL for debugging purpose The given proc will be called upon some events (errors or warnings about performance and undifined behaviors) with the following arguments:.
-
.core_profile=(val) ⇒ Object
-
.core_profile? ⇒ Bollean
True when a core OpenGL profile must be used.
-
.debug=(val) ⇒ Object
-
.debug? ⇒ true, false
True if debugging mode is enabled.
-
.depth_size ⇒ Integer
Size of the depth buffer, in bits.
-
.depth_size=(val) ⇒ Object
-
.draw_arrays(primitive, first, count) ⇒ Object
-
.draw_arrays_instanced(primitive, first, count, instance_count) ⇒ Object
-
.draw_elements(primitive, count, index) ⇒ Object
-
.draw_elements_instanced(primitive, count, index, instance_count) ⇒ Object
-
.ensure_context ⇒ Object
Ensures an OpenGL context is active for the current thread.
-
.has_callback? ⇒ True, False
True if a callback proc can be set.
-
.major_version ⇒ Integer
-
.major_version=(val) ⇒ Object
-
.minor_version ⇒ Integer
-
.minor_version=(val) ⇒ Object
-
.multi_draw_arrays(primitive, first, count) ⇒ Object
-
.multi_draw_elements(primitive, count, index) ⇒ Object
-
.stencil_size ⇒ Integer
Size of the stencil buffer, in bits.
-
.stencil_size=(val) ⇒ Object
Class Method Details
.callback=(proc) ⇒ Object
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
# File 'ext/gl.c', line 301
static
VALUE ray_gl_set_callback(VALUE self, VALUE proc) {
say_context_ensure();
if (!glDebugMessageCallbackARB)
rb_raise(rb_eRuntimeError, "setting the debug proc isn't supported");
rb_iv_set(rb_path2class("Ray::GL"), "@callback", proc);
if (RTEST(proc))
glDebugMessageCallbackARB(ray_gl_debug_proc, NULL);
else
glDebugMessageCallbackARB(NULL, NULL);
return proc;
}
|
.core_profile=(val) ⇒ Object
188
189
190
191
192
|
# File 'ext/gl.c', line 188
static
VALUE ray_gl_set_core_profile(VALUE self, VALUE val) {
say_context_get_config()->core_profile = RTEST(val);
return val;
}
|
.core_profile? ⇒ Bollean
Returns True when a core OpenGL profile must be used.
154
155
156
157
|
# File 'ext/gl.c', line 154
static
VALUE ray_gl_core_profile(VALUE self) {
return say_context_get_config()->core_profile ? Qtrue : Qfalse;
}
|
.debug=(val) ⇒ Object
201
202
203
204
205
|
# File 'ext/gl.c', line 201
static
VALUE ray_gl_set_debug(VALUE self, VALUE val) {
say_context_get_config()->debug = RTEST(val);
return val;
}
|
.debug? ⇒ true, false
Returns True if debugging mode is enabled.
195
196
197
198
|
# File 'ext/gl.c', line 195
static
VALUE ray_gl_debug(VALUE self) {
return say_context_get_config()->debug ? Qtrue : Qfalse;
}
|
.depth_size ⇒ Integer
Returns Size of the depth buffer, in bits.
130
131
132
133
|
# File 'ext/gl.c', line 130
static
VALUE ray_gl_depth_size(VALUE self) {
return ULONG2NUM(say_context_get_config()->depth_size);
}
|
.depth_size=(val) ⇒ Object
160
161
162
163
164
|
# File 'ext/gl.c', line 160
static
VALUE ray_gl_set_depth_size(VALUE self, VALUE val) {
say_context_get_config()->depth_size = NUM2ULONG(val);
return val;
}
|
.draw_arrays(primitive, first, count) ⇒ Object
15
16
17
18
19
20
21
|
# File 'ext/gl.c', line 15
static
VALUE ray_gl_draw_arrays(VALUE self, VALUE primitive, VALUE first,
VALUE count) {
glDrawArrays(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
NUM2ULONG(first), NUM2ULONG(count));
return Qnil;
}
|
.draw_arrays_instanced(primitive, first, count, instance_count) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'ext/gl.c', line 45
static
VALUE ray_gl_draw_arrays_instanced(VALUE self, VALUE primitive, VALUE first,
VALUE count, VALUE instance_count) {
say_context_ensure();
if (glDrawArraysInstanced) {
glDrawArraysInstanced(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
NUM2ULONG(first), NUM2ULONG(count),
NUM2ULONG(instance_count));
}
else
rb_raise(rb_eRuntimeError, "GL_ARB_draw_instanced is not supported");
return Qnil;
}
|
.draw_elements(primitive, count, index) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'ext/gl.c', line 29
static
VALUE ray_gl_draw_elements(VALUE self, VALUE primitive, VALUE count,
VALUE index) {
glDrawElements(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
NUM2ULONG(count),
GL_UNSIGNED_INT, (void*)NUM2ULONG(index));
return Qnil;
}
|
.draw_elements_instanced(primitive, count, index, instance_count) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'ext/gl.c', line 67
static
VALUE ray_gl_draw_elements_instanced(VALUE self, VALUE primitive, VALUE count,
VALUE index, VALUE instance_count) {
say_context_ensure();
if (glDrawElementsInstanced) {
glDrawElementsInstanced(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
NUM2ULONG(count),
GL_UNSIGNED_INT, (void*)NUM2ULONG(index),
NUM2ULONG(instance_count));
}
else
rb_raise(rb_eRuntimeError, "GL_ARB_draw_instanced is not supported");
return Qnil;
}
|
.ensure_context ⇒ Object
Ensures an OpenGL context is active for the current thread
320
321
322
323
324
|
# File 'ext/gl.c', line 320
static
VALUE ray_gl_ensure_context(VALUE self) {
say_context_ensure();
return Qnil;
}
|
.has_callback? ⇒ True, False
Returns True if a callback proc can be set.
267
268
269
270
271
|
# File 'ext/gl.c', line 267
static
VALUE ray_gl_has_callback(VALUE self) {
say_context_ensure();
return glDebugMessageCallbackARB ? Qtrue : Qfalse;
}
|
.major_version ⇒ Integer
Returns Major version number. Ignored if less than 3.
142
143
144
145
|
# File 'ext/gl.c', line 142
static
VALUE ray_gl_major_version(VALUE self) {
return ULONG2NUM(say_context_get_config()->major_version);
}
|
.major_version=(val) ⇒ Object
174
175
176
177
178
|
# File 'ext/gl.c', line 174
static
VALUE ray_gl_set_major_version(VALUE self, VALUE val) {
say_context_get_config()->major_version = NUM2ULONG(val);
return val;
}
|
.minor_version ⇒ Integer
Returns Minor version number.
148
149
150
151
|
# File 'ext/gl.c', line 148
static
VALUE ray_gl_minor_version(VALUE self) {
return ULONG2NUM(say_context_get_config()->minor_version);
}
|
.minor_version=(val) ⇒ Object
181
182
183
184
185
|
# File 'ext/gl.c', line 181
static
VALUE ray_gl_set_minor_version(VALUE self, VALUE val) {
say_context_get_config()->minor_version = NUM2ULONG(val);
return val;
}
|
.multi_draw_arrays(primitive, first, count) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'ext/gl.c', line 90
static
VALUE ray_gl_multi_draw_arrays(VALUE self, VALUE primitive, VALUE rb_first,
VALUE rb_count) {
mo_array *first = ray_rb2int_array(rb_first);
mo_array *count = ray_rb2int_array(rb_count);
if (first->size != count->size)
rb_raise(rb_eArgError, "first and count arrays should have the same size");
glMultiDrawArrays(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
mo_array_at(first, 0), mo_array_at(count, 0),
first->size);
return Qnil;
}
|
.multi_draw_elements(primitive, count, index) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'ext/gl.c', line 113
static
VALUE ray_gl_multi_draw_elements(VALUE self, VALUE primitive, VALUE rb_count,
VALUE rb_index) {
mo_array *index = ray_rb2int_array(rb_index);
mo_array *count = ray_rb2int_array(rb_count);
if (index->size != count->size)
rb_raise(rb_eArgError, "index and count arrays should have the same size");
glMultiDrawElements(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
mo_array_at(count, 0),
GL_UNSIGNED_INT, (const GLvoid**)mo_array_at(index, 0),
index->size);
return Qnil;
}
|
.stencil_size ⇒ Integer
Returns Size of the stencil buffer, in bits.
136
137
138
139
|
# File 'ext/gl.c', line 136
static
VALUE ray_gl_stencil_size(VALUE self) {
return ULONG2NUM(say_context_get_config()->stencil_size);
}
|
.stencil_size=(val) ⇒ Object
167
168
169
170
171
|
# File 'ext/gl.c', line 167
static
VALUE ray_gl_set_stencil_size(VALUE self, VALUE val) {
say_context_get_config()->stencil_size = NUM2ULONG(val);
return val;
}
|