Example #1
0
static void shader_texture_solid_any_init(uintptr_t state, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3)
{
   INIT_PREAMBLE

   PLANE_DETS(u, v1->u, v2->u, v3->u)
   PLANE_DETS(v, v1->v, v2->v, v3->v)

   state_texture_solid_any_2d* s = (state_texture_solid_any_2d*)state;

   s->target = al_get_target_bitmap();
   s->cur_color = v1->color;

   s->off_x = v1->x - 0.5f;
   s->off_y = v1->y + 0.5f;

   s->w = al_get_bitmap_width(s->texture);
   s->h = al_get_bitmap_height(s->texture);
   
   if (det_u == 0.0f) {
      s->du_dx = s->du_dy = s->u_const = 0.0f;
      s->dv_dx = s->dv_dy = s->v_const = 0.0f;
   }
   else {
      s->du_dx    = -u_det_x / det_u;
      s->du_dy    = -u_det_y / det_u;
      s->u_const  = u_det / det_u;

      s->dv_dx    = -v_det_x / det_u;
      s->dv_dy    = -v_det_y / det_u;
      s->v_const  = v_det / det_u;
   }
}
Example #2
0
static void shader_grad_any_init(uintptr_t state, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3)
{
   INIT_PREAMBLE
   
   ALLEGRO_COLOR v1c = al_get_allegro_color(v1->color);
   ALLEGRO_COLOR v2c = al_get_allegro_color(v2->color);
   ALLEGRO_COLOR v3c = al_get_allegro_color(v3->color);
  
   PLANE_DETS(r, v1c.r, v2c.r, v3c.r)
   PLANE_DETS(g, v1c.g, v2c.g, v3c.g)
   PLANE_DETS(b, v1c.b, v2c.b, v3c.b)
   PLANE_DETS(a, v1c.a, v2c.a, v3c.a)
   
   state_grad_any_2d* s = (state_grad_any_2d*)state;
   
   s->off_x = v1->x - 0.5f;
   s->off_y = v1->y + 0.5f;
   
   s->color_dx.r    = -r_det_x / det_u;
   s->color_dy.r    = -r_det_y / det_u;
   s->color_const.r = r_det / det_u;
   
   s->color_dx.g    = -g_det_x / det_u;
   s->color_dy.g    = -g_det_y / det_u;
   s->color_const.g = g_det / det_u;
   
   s->color_dx.b    = -b_det_x / det_u;
   s->color_dy.b    = -b_det_y / det_u;
   s->color_const.b = b_det / det_u;
   
   s->color_dx.a    = -a_det_x / det_u;
   s->color_dy.a    = -a_det_y / det_u;
   s->color_const.a = a_det / det_u;
}
Example #3
0
static void shader_grad_any_init(uintptr_t state, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3)
{
   INIT_PREAMBLE

   ALLEGRO_COLOR v1c = v1->color;
   ALLEGRO_COLOR v2c = v2->color;
   ALLEGRO_COLOR v3c = v3->color;

   PLANE_DETS(r, v1c.r, v2c.r, v3c.r)
   PLANE_DETS(g, v1c.g, v2c.g, v3c.g)
   PLANE_DETS(b, v1c.b, v2c.b, v3c.b)
   PLANE_DETS(a, v1c.a, v2c.a, v3c.a)

   state_grad_any_2d* s = (state_grad_any_2d*)state;

   s->solid.target = al_get_target_bitmap();
   
   s->off_x = v1->x - 0.5f;
   s->off_y = v1->y + 0.5f;

   if (det_u == 0.0) {
      s->color_dx = s->color_dy = s->color_const = al_map_rgba_f(0, 0, 0, 0);
   }
   else {
      s->color_dx.r    = -r_det_x / det_u;
      s->color_dy.r    = -r_det_y / det_u;
      s->color_const.r = r_det / det_u;

      s->color_dx.g    = -g_det_x / det_u;
      s->color_dy.g    = -g_det_y / det_u;
      s->color_const.g = g_det / det_u;

      s->color_dx.b    = -b_det_x / det_u;
      s->color_dy.b    = -b_det_y / det_u;
      s->color_const.b = b_det / det_u;

      s->color_dx.a    = -a_det_x / det_u;
      s->color_dy.a    = -a_det_y / det_u;
      s->color_const.a = a_det / det_u;
   }
}
Example #4
0
static void shader_texture_grad_any_init(uintptr_t state, ALLEGRO_VERTEX* v1, ALLEGRO_VERTEX* v2, ALLEGRO_VERTEX* v3)
{
   INIT_PREAMBLE
   
   ALLEGRO_COLOR v1c = al_get_allegro_color(v1->color);
   ALLEGRO_COLOR v2c = al_get_allegro_color(v2->color);
   ALLEGRO_COLOR v3c = al_get_allegro_color(v3->color);
  
   PLANE_DETS(r, v1c.r, v2c.r, v3c.r)
   PLANE_DETS(g, v1c.g, v2c.g, v3c.g)
   PLANE_DETS(b, v1c.b, v2c.b, v3c.b)
   PLANE_DETS(a, v1c.a, v2c.a, v3c.a)
   PLANE_DETS(u, v1->u, v2->u, v3->u)
   PLANE_DETS(v, v1->v, v2->v, v3->v)
   
   state_texture_grad_any_2d* s = (state_texture_grad_any_2d*)state;
   
   s->solid.w = al_get_bitmap_width(s->solid.texture);
   s->solid.h = al_get_bitmap_height(s->solid.texture);

   s->solid.off_x = v1->x - 0.5f;
   s->solid.off_y = v1->y + 0.5f;

   s->solid.du_dx    = -u_det_x / det_u;
   s->solid.du_dy    = -u_det_y / det_u;
   s->solid.u_const  = u_det / det_u;
                     
   s->solid.dv_dx    = -v_det_x / det_u;
   s->solid.dv_dy    = -v_det_y / det_u;
   s->solid.v_const  = v_det / det_u;
   
   s->color_dx.r    = -r_det_x / det_u;
   s->color_dy.r    = -r_det_y / det_u;
   s->color_const.r = r_det / det_u;
   
   s->color_dx.g    = -g_det_x / det_u;
   s->color_dy.g    = -g_det_y / det_u;
   s->color_const.g = g_det / det_u;
   
   s->color_dx.b    = -b_det_x / det_u;
   s->color_dy.b    = -b_det_y / det_u;
   s->color_const.b = b_det / det_u;
   
   s->color_dx.a    = -a_det_x / det_u;
   s->color_dy.a    = -a_det_y / det_u;
   s->color_const.a = a_det / det_u;
}