Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 859 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
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 Offline OP
Serious User
txesmi  Offline 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.

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.
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 Offline
Expert
Kartoffel  Offline
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: Kartoffel] #453423
07/25/15 19:23
07/25/15 19:23
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Thanks for the info!

Unfortunatelly the use of views for buttons rendering would be a pain for this project. It has near a thousand buttons of different shapes. I thought on rendering the visible ones over a common template so it would have just a little part on memory at a time. A good save of memory.

I am thinking on building my own layered renderer using bmap_process and material skins. I hope it fast.

Re: panel->target_map plus draw_obj issue [Re: txesmi] #453443
07/27/15 07:32
07/27/15 07:32
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
From what I understood, the rendered panel had a wrong 50% alpha transparency? What happens when you set panRenderer->alpha = 100?

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 Offline OP
Serious User
txesmi  Offline 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: txesmi] #453445
07/27/15 08:46
07/27/15 08:46
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Hmm, my test script displays panel render targets ok. Can you upload your example, or contact Support and send it to them? They'll look into it. The next update is just in the works and it would be good if this issue could be solved for 8.46.

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 Offline OP
Serious User
txesmi  Offline OP
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Here you go!

dowload

I'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: txesmi] #453452
07/27/15 11:23
07/27/15 11:23
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thanks for the script. From what I see, you're putting a half transparent window over your panel - that seems to be the reason of the transparency. A window is a hole in the panel background, it makes your panel transparent at that place and you can see through. Remove that window and all is fine.



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 Offline OP
Serious User
txesmi  Offline 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.

Originally Posted By: jcl
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.

Re: panel->target_map plus draw_obj issue [Re: txesmi] #453461
07/27/15 14:45
07/27/15 14:45
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You're not rendering a bitmap over another bitmap. You're simply copying a bitmap into a target bitmap. If the source bitmap has alpha transparency, the target bitmap will naturally get that alpha transparency too.

This might be not intuitive, but it is just logical. In a 3D level, transparent objects are sorted and blended over each other. This won't happen with panel elements. They are just drawn, one after the other, regardless of their transparency.

I don't think that it's very difficult to nevertheless produce a non transparent panel of any sort, even on a target bitmap. If you have problems, just ask and I'll help.

Page 1 of 2 1 2

Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1