[AD] correct behaviour for additive blending? |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Am I doing something wrong or is this a bug?
Here I draw two intersecting lines with additive blending.
On the offscreen bitmap the colour is as I expect (g=50; g=100 at the
intersection). On the backbuffer the colour is only half as much (g=25;
g=50 at the intersection).
~~~~
#include "allegro5/allegro5.h"
#include "allegro5/allegro_primitives.h"
int main()
{
ALLEGRO_DISPLAY *display;
ALLEGRO_BITMAP *bmp;
ALLEGRO_EVENT_QUEUE *queue;
al_init();
display = al_create_display(640, 480);
al_clear_to_color(al_map_rgb(0, 0, 0));
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE, al_map_rgba_f(1,1,1,1));
al_draw_line(100, 150, 200, 150, al_map_rgb(0, 50, 0), 0);
al_draw_line(150, 100, 150, 200, al_map_rgb(0, 50, 0), 0);
bmp = al_create_bitmap(100, 100);
al_set_target_bitmap(bmp);
al_clear_to_color(al_map_rgb(0, 0, 0));
al_draw_line(0, 50, 100, 50, al_map_rgb(0, 50, 0), 0);
al_draw_line(50, 0, 50, 100, al_map_rgb(0, 50, 0), 0);
al_set_target_bitmap(al_get_backbuffer());
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgba_f(1,1,1,1));
al_draw_bitmap(bmp, 0, 0, 0);
al_flip_display();
queue = al_create_event_queue();
al_register_event_source(queue, al_get_display_event_source(display));
while (1) {
ALLEGRO_EVENT event;
al_wait_for_event(queue, &event);
if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
break;
}
return 0;
}