Allegro.cc Forums » Programming Questions » [a5] set_multiply_blender

 This thread is locked; no one can reply to it.
 [a5] set_multiply_blender
 kazzmir Member #1,786 December 2001 What is the A5 equivalent of set_multiply_blender / draw_trans_sprite?
 AMCerasoli Member #11,955 May 2010 The other one I have no idea.
 kazzmir Member #1,786 December 2001 Sorry I meant the combination of set_multiply_blender with draw_trans_sprite. I want to get that effect.al_draw_tinted_bitmap is effectively equal to draw_trans_sprite with the right blender set.
 Elias Member #358 May 2000 For someone not knowing what those A4 functions do - what is the effect you want? --"Either help out or stop whining" - Evert
 kazzmir Member #1,786 December 2001 Well here is the description from allegro.txt: Quote: void set_multiply_blender(int r, int g, int b, int a); Enables a multiply blender mode for combining translucent or lit truecolor pixels. Combines the source and destination images, multiplying the colours to produce a darker colour. If a colour is multiplied by white it remains unchanged; when multiplied by black it also becomes black. I don't know how to describe what the blender is doing any other way. Its implemented by multiplying the individual components of the two colors (source and destination). Here is the code I use in sdl which was copied from allegro4.#SelectExpand 1 2static inline unsigned int transBlender(unsigned int x, unsigned int y, unsigned int n){ 3 unsigned long result; 4 5 if (n) 6 n = (n + 1) / 8; 7 8 /* hex: 0x7E0F81F 9 * binary: 0111 1110 0000 1111 1000 0001 1111 10 */ 11 x = ((x & 0xFFFF) | (x << 16)) & 0x7E0F81F; 12 y = ((y & 0xFFFF) | (y << 16)) & 0x7E0F81F; 13 14 result = ((x - y) * n / 32 + y) & 0x7E0F81F; 15 16 return ((result & 0xFFFF) | (result >> 16)); 17} 18 19static inline unsigned int multiplyBlender(unsigned int x, unsigned int y, unsigned int n){ 20 Uint8 redX = 0; 21 Uint8 greenX = 0; 22 Uint8 blueX = 0; 23 SDL_GetRGB(x, &format565, &redX, &greenX, &blueX); 24 Uint8 redY = 0; 25 Uint8 greenY = 0; 26 Uint8 blueY = 0; 27 SDL_GetRGB(y, &format565, &redY, &greenY, &blueY); 28 29 int r = redX * redY / 256; 30 int g = greenX * greenY / 256; 31 int b = blueX * blueY / 256; 32 return transBlender(makeColor(r, g, b), y, n); 33} Where x is source, y is destination, and n is the current alpha value.
 Mark Oates Member #1,146 March 2001 trans sprite is going to be```ALLEGRO_BITMAP *bmp; float alpha = 0.1; al_draw_tinted_bitmap(bmp, al_map_rgba_f(alpha, alpha, alpha, alpha), x, y, NULL); ``` There is no multiply blender. The closest thing you can get to is the subtractive blender:al_set_blender(ALLEGRO_DEST_MINUS_SRC, ALLEGRO_ONE, ALLEGRO_ONE);or make a shader
 kazzmir Member #1,786 December 2001 Are all the hardware blenders implemented in scanline_drawers.c? Couldn't a new blender be added that did ```r = dr * dst * sr * sa; ... ``` Or am I missing how the blenders are associated with hardware acceleration?
 Thomas Fjellstrom Member #476 June 2000 Those are software blenders. They are used on locked bitmaps, or memory bitmaps. -- Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]"If you can't think of a better solution, don't try to make a better solution." -- weapon_S"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730
 Elias Member #358 May 2000 So yes, if you want to add it, you need to add it to the software blenders, but also for OpenGL and DirectX.For OpenGL it would be almost trivial, what you need is probably either the SRC_COLOR or DST_COLOR blend factor (in A5 it would be another blend factor like ALLEGRO_ALPHA mapped 1:1 to it, ALLEGRO_SOURCE_COLOR and ALLEGRO_DESTINATION_COLOR maybe):http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xmlNo idea about DirectX but since GPUs support it DirectX most likely also supports it somehow. --"Either help out or stop whining" - Evert
 Go to: Allegro Development Installation, Setup & Configuration Allegro.cc Comments Off-Topic Ordeals The Depot Game Design & Concepts Programming Questions Recent Threads