Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Transparent 2D rectangle

Author
Message
Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 5th Mar 2011 14:33
Hello

I wonder if you can help. I'm using the D3D commands to draw 2D text over a 3D scene. I'm trying to draw a transparent box over the top of the D3D text to get a clear 'window', into which I'm drawing some more text.

Er, that sounds confusing! Please take a look at the image to see what I mean.

Any ideas how I can do this?

Thanks for any help.

James
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 5th Mar 2011 14:45
The Advanced 2D Plugin allows you to draw transparent shapes. if you wanted a transparent red box, you'd type:

a2fillbox x1,y1,x2,y2,0x80FF0000

The first byte in the color value defines the transparency (FF for no transparency, 00 for full transparency. I chose 80 in this case). The next 3 bytes are the rgb values, so FF for full red, 00 for no green, and 00 for no blue.

TheComet

Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 5th Mar 2011 15:01
Hi TheComet

Thanks for the quick reply. Downloaded that plugin - great, isn't it?

Unfortunately, it didn't solve my problem. The D3D_text was still visible through the transparent shape. I was hoping the shape would wipe out the 2D text.

Cheers anyway tho
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Mar 2011 16:12
So you don't actually want a transparent shape, you want an opaque shape? Then set the alpha level to ff instead of 80:

a2fillbox x1,y1,x2,y2,0xFFFF0000

Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 5th Mar 2011 17:08
Sorry, I'm not being clear... too much beer last night

Let me try it like this... imagine you wanted to draw a large polo mint in the middle of the screen with 2 circles - a white one, then a clear one in the middle. How would you draw the clear one so that you could see the 3D environment through it?

Cheers!

James
BatVink
Moderator
23
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Mar 2011 17:44
That would be 4 polys to make the border, or you draw the shaped border you want to a bitmap and make an image from it. (SET BITMAP FORMAT 21 to make it transparent)

Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 5th Mar 2011 19:31
Hmm, never played with SET BITMAP FORMAT... I'll have a go with it.

Thanks as always to everyone for your help. Great bunch of folk on here

Login to post a reply

Server time is: 2026-07-15 03:39:17
Your offset time is: 2026-07-15 03:39:17