void _al_point_2d(ALLEGRO_BITMAP* texture, ALLEGRO_VERTEX* v) { int shade = 1; int op, src_mode, dst_mode, op_alpha, src_alpha, dst_alpha; ALLEGRO_COLOR vc; int clip_min_x, clip_min_y, clip_max_x, clip_max_y; int x = (int)floorf(v->x); int y = (int)floorf(v->x); al_get_clipping_rectangle(&clip_min_x, &clip_min_y, &clip_max_x, &clip_max_y); clip_max_x += clip_min_x; clip_max_y += clip_min_y; if(x < clip_min_x || x >= clip_max_x || y < clip_min_y || y >= clip_max_y) return; vc = v->color; al_get_separate_blender(&op, &src_mode, &dst_mode, &op_alpha, &src_alpha, &dst_alpha); if (_AL_DEST_IS_ZERO && _AL_SRC_NOT_MODIFIED) { shade = 0; } if (texture) { float U = fix_var(v->u, al_get_bitmap_width(texture)); float V = fix_var(v->v, al_get_bitmap_height(texture)); ALLEGRO_COLOR color = al_get_pixel(texture, U, V); if(vc.r != 1 || vc.g != 1 || vc.b != 1 || vc.a != 1) { color.r *= vc.r; color.g *= vc.g; color.b *= vc.b; color.a *= vc.a; } if (shade) { al_put_blended_pixel(v->x, v->y, color); } else { al_put_pixel(v->x, v->y, color); } } else { ALLEGRO_COLOR color = al_map_rgba_f(vc.r, vc.g, vc.b, vc.a); if (shade) { al_put_blended_pixel(v->x, v->y, color); } else { al_put_pixel(v->x, v->y, color); } } }
static void shader_solid_any_draw_shade(uintptr_t state, int x1, int y, int x2) { state_solid_any_2d* s = (state_solid_any_2d*)state; int x; for (x = x1; x <= x2; x++) { al_put_blended_pixel(x, y - 1, s->cur_color); } }
static mrb_value put_blended_pixel(mrb_state *mrb, mrb_value self) { mrb_int x; mrb_int y; ALLEGRO_COLOR *c; mrb_get_args(mrb, "iid", &x, &y, &c, &mrbal_color_data_type); al_put_blended_pixel(mrbal_clamp_int(x), mrbal_clamp_int(y), *c); return mrb_nil_value(); }
void shal_put_blended_pixel(int x, int y, float color_r, float color_g, float color_b, float color_a) { ALLEGRO_COLOR color; color.r = color_r; color.g = color_g; color.b = color_b; color.a = color_a; return al_put_blended_pixel(x, y, color); }
static void shader_texture_solid_any_draw_shade_white(uintptr_t state, int x1, int y, int x2) { state_texture_solid_any_2d* s = (state_texture_solid_any_2d*)state; float u = s->u; float v = s->v; int x; ALLEGRO_COLOR color; for (x = x1; x <= x2; x++) { color = al_get_pixel(s->texture, fix_var(u, s->w), fix_var(v, s->h)); al_put_blended_pixel(x, y - 1, color); u += s->du_dx; v += s->dv_dx; } }
static void shader_grad_any_draw_shade(uintptr_t state, int x1, int y, int x2) { state_grad_any_2d* s = (state_grad_any_2d*)state; ALLEGRO_COLOR color = s->solid.cur_color; int x; for (x = x1; x <= x2; x++) { /* TODO: This y - 1 bit bothers me, why would I need this? Either _al_put_pixel, or al_draw_bitmap are shifted by 1 relative to OpenGL */ al_put_blended_pixel(x, y - 1, color); color.r += s->color_dx.r; color.g += s->color_dx.g; color.b += s->color_dx.b; color.a += s->color_dx.a; } }
static void shader_texture_grad_any_draw_shade(uintptr_t state, int x1, int y, int x2) { state_texture_grad_any_2d* s = (state_texture_grad_any_2d*)state; float u = s->solid.u; float v = s->solid.v; int x; ALLEGRO_COLOR color; ALLEGRO_COLOR cur_color = s->solid.cur_color; for (x = x1; x <= x2; x++) { color = al_get_pixel(s->solid.texture, fix_var(u, s->solid.w), fix_var(v, s->solid.h)); SHADE_COLORS(color, cur_color) al_put_blended_pixel(x, y - 1, color); u += s->solid.du_dx; v += s->solid.dv_dx; cur_color.r += s->color_dx.r; cur_color.g += s->color_dx.g; cur_color.b += s->color_dx.b; cur_color.a += s->color_dx.a; } }
void al_put_blended_pixel_w(int x, int y, ALLEGRO_COLOR *color) { return al_put_blended_pixel(x, y, *color); }