[AD] Hardware accelerated blending

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


The attached patch (finally!) adds the actual call to the vtable hook for 
set_blender_mode and the nescessary defines.
Please let me know if I've missed anything.

I'd also like to ask the AllegroGL people if there are other vtable hooks 
they think would be nice to have. It'd be nice if all future versions of 
AllegroGL can be used with Allegro 4.2 vanilla and not require a WIP. More 
so because the 4.3 WIP series will be incompatible with the previous 
versions of Allegro.

Evert
? keyboard.dat
? language.dat
Index: include/allegro/gfx.h
===================================================================
RCS file: /cvsroot/alleg/allegro/include/allegro/gfx.h,v
retrieving revision 1.14
diff -u -p -r1.14 gfx.h
--- include/allegro/gfx.h	4 Dec 2004 13:24:15 -0000	1.14
+++ include/allegro/gfx.h	29 Dec 2004 11:02:28 -0000
@@ -38,6 +38,23 @@ struct RGB;
 #define GFX_SAFE                       AL_ID('S','A','F','E')
 
 
+/* Blender mode defines, for the gfx_driver->set_blender_mode() function */
+#define blender_mode_none            0
+#define blender_mode_trans           1
+#define blender_mode_add             2
+#define blender_mode_burn            3
+#define blender_mode_color           4
+#define blender_mode_difference      5
+#define blender_mode_dissolve        6
+#define blender_mode_dodge           7
+#define blender_mode_hue             8
+#define blender_mode_invert          9
+#define blender_mode_luminance      10
+#define blender_mode_multiply       11
+#define blender_mode_saturation     12
+#define blender_mode_screen         13
+#define blender_mode_alpha          14
+
 typedef struct GFX_MODE
 {
    int width, height, bpp;
Index: src/colblend.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/colblend.c,v
retrieving revision 1.6
diff -u -p -r1.6 colblend.c
--- src/colblend.c	3 Jun 2003 19:34:14 -0000	1.6
+++ src/colblend.c	29 Dec 2004 11:02:29 -0000
@@ -928,6 +928,8 @@ unsigned long _blender_screen15(unsigned
 #define SET_BLENDER_FUNC(name)                                 \
    void set_##name##_blender(int r, int g, int b, int a)       \
    {                                                           \
+      if (gfx_driver->set_blender_mode)                        \
+         gfx_driver->set_blender_mode(blender_mode_##name##, r, g, b, a);\
       set_blender_mode(BF16(_blender_##name##15),              \
 		       BF16(_blender_##name##16),              \
 		       BF24(_blender_##name##24),              \
@@ -958,6 +960,10 @@ void set_alpha_blender()
 {
    BLENDER_FUNC f15, f16, f24, f32;
    int r, b;
+   
+   /* Call gfx_driver->set_blender_mode() for hardware acceleration */
+   if (gfx_driver->set_blender_mode)
+      gfx_driver->set_blender_mode(blender_mode_alpha, 0, 0, 0, 0);
 
    /* check which way around the 32 bit pixels are */
    if ((_rgb_g_shift_32 == 8) && (_rgb_a_shift_32 == 24)) {


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/