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.

Returns:

  • (Hash)

    Available primitives.

ray_gl_primitives

Class Method Summary collapse

Class Method Details

.draw_arrays(primitive, first, count) ⇒ Object

Note:

Misusing this method can cause a crash.

Parameters:

  • primitive (Symbol)

    Primitive to draw. Must be one of the folowing: points, line_strip, line_loop, lines, triangle_strip, triangle_fan, triangles.

  • first (Integer)

    Identifier of the first vertex to draw.

  • count (Integer)

    Amount of vertices to draw.



16
17
18
19
20
21
22
23
# File 'ext/gl.c', line 16

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_elements(primitive, count, index) ⇒ Object

Parameters:

  • index

    First index from the element array.



31
32
33
34
35
36
37
38
# File 'ext/gl.c', line 31

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;
}

.multi_draw_arrays(primitive, first, count) ⇒ Object

Parameters:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'ext/gl.c', line 46

static
VALUE ray_gl_multi_draw_arrays(VALUE self, VALUE primitive, VALUE rb_first,
                               VALUE rb_count) {
  say_array *first = ray_rb2int_array(rb_first);
  say_array *count = ray_rb2int_array(rb_count);

  size_t size = say_array_get_size(first);

  if (size != say_array_get_size(count))
    rb_raise(rb_eArgError, "first and count arrays should have the same size");

  glMultiDrawArrays(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
                    say_array_get(first, 0), say_array_get(count, 0),
                    size);

  return Qnil;
}

.multi_draw_elements(primitive, count, index) ⇒ Object

Parameters:



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'ext/gl.c', line 71

static
VALUE ray_gl_multi_draw_elements(VALUE self, VALUE primitive, VALUE rb_count,
                                 VALUE rb_index) {
  say_array *index = ray_rb2int_array(rb_index);
  say_array *count = ray_rb2int_array(rb_count);

  size_t size = say_array_get_size(index);

  if (size != say_array_get_size(count))
    rb_raise(rb_eArgError, "index and count arrays should have the same size");

  glMultiDrawElements(NUM2INT(rb_hash_aref(ray_gl_primitives, primitive)),
                      say_array_get(count, 0),
                      GL_UNSIGNED_INT, (const GLvoid**)say_array_get(count, 0),
                      size);
  return Qnil;
}