|
create_trans_table |
Onewing
Member #6,152
August 2005
|
Setting up a little translucent GUI for my game. I haven't messed with the blender or draw_trans_sprite and/or draw_lit_sprite functions hardly at all, so pardon if I say something obviously incorrect. Anyway, as a quick test, I added this to the game: ... PALETTE pal; COLOR_MAP trans_table; set_palette(pal); create_trans_table(&trans_table, pal, 0, 0, 0, NULL); set_trans_blender(0, 0, 0, 128); ... //Inside game loop rectfill(bText, 0, 0, bText->w, bText->h, GREEN); draw_trans_sprite(buffer, bText, 0, 0); ... Now, the manual says about create_trans_table: Quote: The r, g, and b parameters specify the solidity of each color component, ranging from 0 (totally transparent) to 255 (totally solid). For 50% solidity, pass 128. But, when I try to change anything of those parameters, nothing changes. In fact, if I try to change the first parameters of set_trans_blender parameters, nothing changes. To me, only changing the last parameter of set_trans_blender does anything. ------------ |
ReyBrujo
Moderator
January 2001
|
Have you remembered to set the rgb_map and the color_map global variables after creating your transparency table? -- |
Onewing
Member #6,152
August 2005
|
Quote: Have you remembered to set the rgb_map and the color_map global variables after creating your transparency table? It's not that I didn't remember, it's that I didn't know. What do I set them to? ------------ |
ReyBrujo
Moderator
January 2001
|
rgb_map isn't necessary it seems, it only speeds transformations up. Check extrans.c, line 99. You set the global color_map to point to your trans_table. -- |
Onewing
Member #6,152
August 2005
|
I set color_map = &trans_table and the parameters of create_trans_table and set_trans_blender still don't make any difference. ------------ |
ReyBrujo
Moderator
January 2001
|
Try the extrans.c, modifying the values you are modifying in your program, and see if it doesn't change as well. -- |
Onewing
Member #6,152
August 2005
|
It seems if I set the color depth to 32, those parameters don't do anything. At least, that's what I did with the extrans.c. That's okay, I still have enough control to do what I need. I was just curious as to why they weren't doing anything. Thanks. ------------ |
ReyBrujo
Moderator
January 2001
|
Wait... you were using 32bpp? Palettes are for 8bpp only. -- |
Onewing
Member #6,152
August 2005
|
Quote: pardon if I say something obviously incorrect I didn't know that either. I just saw the create_trans_table() function needed a palette, so I set one up. ------------ |
Johan Peitz
Member #9
April 2000
|
You need to set the drawing mode to tell allegro you want fancy effects. Like so: // let's do some fancy schmancy stuff! drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); // draw it rectfill(...); // back to normal drawing solid_mode();
-- |
Ceagon Xylas
Member #5,495
February 2005
|
Yeah, that's what you really want unless you're dealing with lower color modes. (256 and below I believe) Remember allegro's blender modes are a little slow. |
ReyBrujo
Moderator
January 2001
|
Oh, don't worry. You know, I only work with 8bpp modes, so stuff like palette manipulation I take it for granted... from 15bpp to above, I know nothing -- |
Tobias Dammers
Member #2,604
August 2002
|
Colors are represented ultimately differently between 8bpp and everything else. 8bpp uses a global palette, and each color value represents an index into the palette. 15bpp and above packs RGB values directly into a single integer (16, 24 or 32 bits wide). --- |
|