コード例 #1
0
ファイル: graphene-matrix.c プロジェクト: lunixbochs/graphene
/**
 * graphene_matrix_get_row:
 * @m: a #graphene_matrix_t
 * @index_: the index of the row vector, between 0 and 3
 * @res: (out caller-allocates): return location for the #graphene_vec4_t
 *   that is used to store the row vector
 *
 * Retrieves the given row vector at @index_ inside a matrix.
 *
 * Since: 1.0
 */
void
graphene_matrix_get_row (const graphene_matrix_t *m,
                         unsigned int             index_,
                         graphene_vec4_t         *res)
{
  switch (index_)
    {
    case 0:
      res->value = m->value.x;
      break;

    case 1:
      res->value = m->value.y;
      break;

    case 2:
      res->value = m->value.z;
      break;

    case 3:
      res->value = m->value.w;
      break;

    default:
      res->value = graphene_simd4f_init_zero ();
      break;
    }
}
コード例 #2
0
ファイル: graphene-vectors.c プロジェクト: pmdias/graphene
static void
init_static_vec2_once (void)
{
  static_vec2[VEC2_ZERO].value = graphene_simd4f_init_zero ();
  static_vec2[VEC2_ONE].value = graphene_simd4f_init (1.f, 1.f, 0.f, 0.f);
  static_vec2[VEC2_X_AXIS].value = graphene_simd4f_init (1.f, 0.f, 0.f, 0.f);
  static_vec2[VEC2_Y_AXIS].value = graphene_simd4f_init (0.f, 1.f, 0.f, 0.f);
}
コード例 #3
0
ファイル: graphene-vectors.c プロジェクト: pmdias/graphene
/**
 * graphene_vec3_normalize:
 * @v: a #graphene_vec3_t
 * @res: (out caller-allocates): return location for the normalized vector
 *
 * Normalizes the given #graphene_vec3_t.
 *
 * Since: 1.0
 */
void
graphene_vec3_normalize (const graphene_vec3_t *v,
                         graphene_vec3_t       *res)
{
  if (graphene_vec3_length (v) != 0.f)
    res->value = graphene_simd4f_normalize3 (v->value);
  else
    res->value = graphene_simd4f_init_zero ();
}
コード例 #4
0
ファイル: graphene-vectors.c プロジェクト: pmdias/graphene
static void
init_static_vec4_once (void)
{
  static_vec4[VEC4_ZERO].value = graphene_simd4f_init_zero ();
  static_vec4[VEC4_ONE].value = graphene_simd4f_splat (1.f);
  static_vec4[VEC4_X_AXIS].value = graphene_simd4f_init (1.f, 0.f, 0.f, 0.f);
  static_vec4[VEC4_Y_AXIS].value = graphene_simd4f_init (0.f, 1.f, 0.f, 0.f);
  static_vec4[VEC4_Z_AXIS].value = graphene_simd4f_init (0.f, 0.f, 1.f, 0.f);
  static_vec4[VEC4_W_AXIS].value = graphene_simd4f_init (0.f, 0.f, 0.f, 1.f);
}
コード例 #5
0
ファイル: graphene-simd4f.c プロジェクト: ebassi/graphene
/**
 * graphene_simd4f_init_zero:
 *
 * Initializes a #graphene_simd4f_t with 0 in all components.
 *
 * Returns: the initialized #graphene_simd4f_t
 *
 * Since: 1.0
 */
graphene_simd4f_t
(graphene_simd4f_init_zero) (void)
{
  return graphene_simd4f_init_zero ();
}