Hi,
I recently wrote a function that uses a panel target map to render my game buttons.

Code:
void fncPanRendererCreate ()
{
	bmpRendererBack = bmap_createblack ( 1024, 1024, 32 );
	bmpRendererWindow = bmap_create ( "mask.tga" );
	panRenderer = pan_create ( "", 1 );
	panRenderer->bmap = bmpRendererBack;
	panRenderer->size_x = bmap_width ( bmpRendererBack );
	panRenderer->size_y = bmap_height ( bmpRendererBack );
	panRenderer->flags = CENTER_X | OUTLINE;
	pan_setwindow ( panRenderer, 0, 0, 0, panRenderer->size_x, panRenderer->size_y, bmpRendererWindow, NULL, NULL );
	pan_setstring ( panRenderer, 0, 0, 0, fntButton, strTemp );
}

void fncButtonDraw ( BMAP *bmp, FRAME *frm, FONT *fnt, STRING *str )
{
	panRenderer->target_map = bmp;
	panRenderer->size_x = bmap_width ( bmp );
	panRenderer->size_y = bmap_height ( bmp );
	bmap_process ( bmpRendererBack, NULL, mtlClear );
	bmap_frame_quad ( bmpRendererBack, frm, nullvector, vector(panRenderer->size_x,panRenderer->size_y,0) ); // the function that draws the panel background image
	pan_setstring ( panRenderer, 1, panRenderer->size_x/2, (panRenderer->size_y-fnt->dy)/2, fnt, str );
	draw_obj ( panRenderer );
}





These three rectangles are drawn from the same panel. The panel has a background image (the rounded rectangle) that is neutral grey, a semitransparent yellow window covering the whole panel (added for this test) and a digit string. The panel has the OUTLINE flag set and tex_outline is set to 50.

The first rectangle is the renderer panel (panRenderer) after fncButtonDraw is called in order to draw the other two buttons images. It is correctly drawn on the screen.

The second rectangle is an image rendered by fncButtonDraw. It has a wrong alpha channel.

The third rectangle is an image rendered by fncButtonDraw and converted to a 888 format image after that in order to clearly see the RGB values. The panel background image color is correctly mixed by the alpha values of both panel members and their own colors.

Here is the process:
Code:
fncButtonDraw ( bmp, frmButton, fntButton, str );
fncButtonDraw ( bmp2, frmButton, fntButton, str );
bmap_to_format ( bmp2, 888 );
panRenderer->target_map = NULL;
panRenderer->flags |= SHOW;



I guess the problem is clear enough.

I found same behavior in other bmap rendering functions in the past: bmap_rendertarget plus semitransparent draw_quad, draw_obj and others. That is why I tryed this method in order to render my buttons.

I wish this problem is solved soon however ingenuous it may seem xP

Salud!

Last edited by txesmi; 07/25/15 12:02.