Method: CGLM::Mat4#sizes

Defined in:
ext/cglm/rb_cglm_cam.c

#sizes([fovy]) ⇒ Hash

Returns the sizes of the near and far planes of this perspective projection. The return value has the following format:

{ near: [width, height], far: [width, height] }

If fovy is omitted, it will be decomposed from the current matrix.

Returns:

  • (Hash)


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'ext/cglm/rb_cglm_cam.c', line 29

VALUE rb_cglm_cam_sizes(int argc, VALUE *argv, VALUE self) {
  VALUE fovy = Qnil;
  if (argc == 0) fovy = rb_cglm_cam_decomp_fovy(self);
  else fovy = argv[0];
  vec4 out;
  glm_persp_sizes(VAL2MAT4(self), NUM2FLT(fovy), out);
  VALUE n = rb_ary_new_from_args(2, DBL2NUM(out[0]), DBL2NUM(out[1]));
  VALUE f  = rb_ary_new_from_args(2, DBL2NUM(out[2]), DBL2NUM(out[3]));
  VALUE dest = rb_hash_new();
  rb_hash_aset(dest, ID2SYM(rb_intern("near")), n);
  rb_hash_aset(dest, ID2SYM(rb_intern("far")), f);
  return dest;
}