rasterizer.c
static int
transform_vertex(pig_t * p, frag_t * f, vertex_t * a)
{
  vec x, tmp;
  int clipped;

  /* Apply transformations */
  x.x = a->x; x.y = a->y; x.z = a->z; x.w = 1.0f;
  vec_mul(&tmp, &x, p->m_mvp);

  /* Clipping, return 0 if the vertex is outside the view volume */
  clipped = -tmp.w <= tmp.x && tmp.x <= tmp.w &&
            -tmp.w <= tmp.y && tmp.y <= tmp.w &&
            -tmp.w <= tmp.z && tmp.z <= tmp.w &&
            0 < tmp.w;

  /* Get the normalized device coordinates */
  tmp.x /= tmp.w;
  tmp.y /= tmp.w;
  tmp.z /= tmp.w;

  /* Window coordinates */
  f->x = p->width * (tmp.x + 1.0f) / 2;
  f->y = p->height * (tmp.y + 1.0f) / 2;
  f->z = tmp.z;

  /* Copy vertex attributes */
  f->r = a->r;
  f->g = a->g;
  f->b = a->b;
  f->u = a->u;
  f->v = a->v;

  return clipped;
}
/**
 * Computes the window-space coordinate of a vertex
 * Returns a non-zero value if the vertex is not clipped
 */
Computes the window-space coordinate of a vertex
Returns a non-zero value if the vertex is not clipped
Computes the window - space coordinate of a vertex Returns a non - zero value if the vertex is not clipped
static int
transform_vertex(pig_t * p, frag_t * f, vertex_t * a)
{
  vec x, tmp;
  int clipped;
  x.x = a->x; x.y = a->y; x.z = a->z; x.w = 1.0f;
  vec_mul(&tmp, &x, p->m_mvp);
  clipped = -tmp.w <= tmp.x && tmp.x <= tmp.w &&
            -tmp.w <= tmp.y && tmp.y <= tmp.w &&
            -tmp.w <= tmp.z && tmp.z <= tmp.w &&
            0 < tmp.w;
  tmp.x /= tmp.w;
  tmp.y /= tmp.w;
  tmp.z /= tmp.w;
  f->x = p->width * (tmp.x + 1.0f) / 2;
  f->y = p->height * (tmp.y + 1.0f) / 2;
  f->z = tmp.z;
  f->r = a->r;
  f->g = a->g;
  f->b = a->b;
  f->u = a->u;
  f->v = a->v;
  return clipped;
}
static int transform_vertex ( pig_t * p , frag_t * f , vertex_t * a ) { vec x , tmp ; int clipped ; x . x = a -> x ; x . y = a -> y ; x . z = a -> z ; x . w = 1.0f ; vec_mul ( & tmp , & x , p -> m_mvp ) ; clipped = - tmp . w <= tmp . x && tmp . x <= tmp . w && - tmp . w <= tmp . y && tmp . y <= tmp . w && - tmp . w <= tmp . z && tmp . z <= tmp . w && 0 < tmp . w ; tmp . x /= tmp . w ; tmp . y /= tmp . w ; tmp . z /= tmp . w ; f -> x = p -> width * ( tmp . x + 1.0f ) / 2 ; f -> y = p -> height * ( tmp . y + 1.0f ) / 2 ; f -> z = tmp . z ; f -> r = a -> r ; f -> g = a -> g ; f -> b = a -> b ; f -> u = a -> u ; f -> v = a -> v ; return clipped ; }
Computes the window-space coordinate of a vertex
 Returns a non-zero value if the vertex is not clipped
Computes the window - space coordinate of a vertex Returns a non - zero value if the vertex is not clipped
/* Apply transformations */ /* Clipping, return 0 if the vertex is outside the view volume */ /* Get the normalized device coordinates */ /* Window coordinates */ /* Copy vertex attributes */