Module: CGLM

Defined in:
lib/cglm.rb,
lib/cglm/aabb.rb,
lib/cglm/base.rb,
lib/cglm/mat3.rb,
lib/cglm/mat4.rb,
lib/cglm/quat.rb,
lib/cglm/vec3.rb,
lib/cglm/vec4.rb,
lib/cglm/plane.rb,
lib/cglm/sphere.rb,
lib/cglm/frustum.rb,
lib/cglm/version.rb,
lib/cglm/matrix_type.rb,
lib/cglm/vector_type.rb,
ext/cglm/rb_cglm.c

Defined Under Namespace

Modules: Easing, Euler Classes: AABB, Base, Frustum, Mat3, Mat4, MatrixType, Plane, Quat, Sphere, Vec3, Vec4, VectorType

Constant Summary collapse

VERSION =
"0.1.4"
LOG2E =
DBL2NUM(GLM_LOG2E)
LOG10E =
DBL2NUM(GLM_LOG10E)
LN2 =
DBL2NUM(GLM_LN2)
LN10 =
DBL2NUM(GLM_LN10)
PI =
DBL2NUM(GLM_PI)
PI_2 =
DBL2NUM(GLM_PI_2)
PI_4 =
DBL2NUM(GLM_PI_4)
ONE_OVER_PI =
DBL2NUM(GLM_1_PI)
TWO_OVER_PI =
DBL2NUM(GLM_2_PI)
TWO_OVER_SQRTPI =
DBL2NUM(GLM_2_SQRTPI)
SQRT2 =
DBL2NUM(GLM_SQRT2)
SQRT1_2 =
DBL2NUM(GLM_SQRT1_2)

Class Method Summary collapse

Class Method Details

.alloc(klass) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'ext/cglm/rb_cglm.c', line 20

VALUE rb_cglm_alloc_type(VALUE self, VALUE klass) {
  VALUE rsize  = rb_funcall(klass, rb_intern("size"), 0);
  VALUE ralign = rb_funcall(klass, rb_intern("alignment"), 0);
  size_t size  = NUM2SIZET(rsize);
  size_t align = NUM2SIZET(ralign);
  void *addr = ALIGNED_ALLOC(align, size);
  if (!addr)
    rb_raise(rb_eRuntimeError, "could not allocate %zu bytes with %zu alignment", size, align);
  return rb_funcall(rb_cPointer, rb_intern("new"), 2, PTR2NUM(addr), rsize);
}