0 registered members (),
975
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
panel->target_map plus draw_obj issue
#453412
07/25/15 11:17
07/25/15 11:17
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
OP
Serious User
|
OP
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi, I recently wrote a function that uses a panel target map to render my game buttons.
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:
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.
|
|
|
Re: panel->target_map plus draw_obj issue
[Re: txesmi]
#453421
07/25/15 15:26
07/25/15 15:26
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
Err, I think I had the very same problem just a while ago... However, my interface system didn't use panels, but a view and some entities. The problem was the alpha blending that messed up the outlines of my text.
After setting the blending in the interface-shader manually to
AlphaBlendEnable = True; DestBlend = InvSrcAlpha; SrcBlend = One;
the problem was fixed.
POTATO-MAN saves the day! - Random
|
|
|
Re: panel->target_map plus draw_obj issue
[Re: jcl]
#453444
07/27/15 08:30
07/27/15 08:30
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
OP
Serious User
|
OP
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Hi jcl, it has not the transparent flag set. The panel is opaque but the window covering the whole panel has a 30% transparency. The panel background is a 32bits image but the colored zone is opaque.
The first rectangle on the image is the panel drawn by the engine on its way. The other two are this first panel renderer over two images setting them as the render_map member of the panel. The panel is not shown on rendering time and the render_map is drawn with draw_obj instruction.
I will see what happens when setting transparent flag.
Thank you for your time, txes
EDITED____________ No difference when setting TRANSLUCENT flag.
Last edited by txesmi; 07/27/15 08:38.
|
|
|
Re: panel->target_map plus draw_obj issue
[Re: jcl]
#453450
07/27/15 10:04
07/27/15 10:04
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
OP
Serious User
|
OP
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Here you go! dowloadI've taken the liberty of including two scripts: draw_obj.c and bmap_rendertarget.c I venture to say that both behaviors are related. Salud!
|
|
|
Re: panel->target_map plus draw_obj issue
[Re: jcl]
#453455
07/27/15 11:52
07/27/15 11:52
|
Joined: Jun 2007
Posts: 1,337 Hiporope and its pain
txesmi
OP
Serious User
|
OP
Serious User
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
|
Yes, the problems on translucent objects rendering over a bitmap is the main stream of the thread. Remove that window and all is fine. Is it fine to not be able to render any translucent bitmap, text outline, engine object, draw_..., etc, over an alpha channeled opaque bitmap with no alpha troubles? No, it is not fine.
|
|
|
|