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.

2D All the way! / 2D drawing commands & transparency

Author
Message
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 3rd Jun 2009 15:10 Edited at: 3rd Jun 2009 15:28
Hi,

I'm creating the GUI for my game which is slowly getting there, but I want to replace my images with hard coded graphics to take full advantage of anti-aliasing etc. I can get them to look ok as they're saved as TGA file with their own alpha channel, but they're not great n slow the game down a little bit, which isn't a great sign as theres barely anything gamewise which is completed yet!

Anyway I've looked at the D3D dll n will probably endup using it for it's txt etc, but can't see transparency in there. How would I go about drawing in this way? I'd be needing alsorts of shapes including 2D polygons. A gradient or 2 would be nice too The symbols on each button etc will remain as images though. Any ideas?

Thanks
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 3rd Jun 2009 19:56
It's better to use .png for images if you want alpha channels. I saved one frame of my avatar in both .png and .tga. The .png took 2k and .tga took 4k. I'm willing to bet if you change that .tga to a .png you'll see a speed increase.

Diggsey
18
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 3rd Jun 2009 20:31
The D3D plugin supports alpha, it is part of the 'colour' parameter to any of its commands. The highest order byte is the alpha value, next highest is red, then green, then blue. You can construct a colour easily using d3d_rgba

NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 4th Jun 2009 01:16
Grog

I'll have a look at that for the symbols, thanks.

Diggsey

Thanks for that. I was expecting to see something like opacity, transparency, or alpha mentioned as a command or it to be a parameter on each drawing command. I hadn't looked at the colour/ rgba commands I hadn't actually used it till today, only looked at the examples and help files.

This should help a lot thanks
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 4th Jun 2009 15:21
Does anyone know why pasted images don't look great when pasted? I've created a perfect antialiased arc in GIMP which I've tried as both TGA and PNG in DBP. They never look as smooth along the edges. Seems a bit rubbish.
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Jun 2009 19:37
LOAD IMAGE Filename, Image Number, Texture Flag, Divide Texture Size

GET IMAGE Image Number, Left, Top, Right, Bottom, Texture Flag

Always use a 1 for the texture flag of LOAD IMAGE and GET IMAGE commands. Using 1 grabs the image exactly the way you see it on the screen... not using a 1 makes Darkbasic Pro think you want it for 3D texture so it's blurred a bit.

NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 6th Jun 2009 01:08
Cool thanks! I'll give that a go again tomorrow. I've been doing more important parts of the game today This will help tremendously with my GUI when I finally decide on the exact layout for it
Jeff Miller
19
Years of Service
User Offline
Joined: 22nd Mar 2005
Location: New Jersey, USA
Posted: 6th Jun 2009 01:43 Edited at: 6th Jun 2009 01:44
I am fairly sure that if you use the anti-aliasing display mode (5th argument in SET DISPLAY MODE command) you will be unable to grab anything from the screen. You could get an error message stating something to the effect that it is an impermissible "surface". The workaround is to draw and grab images from a separate bitmap that you create if you are going to set anti-aliasing on.
NickH
15
Years of Service
User Offline
Joined: 19th May 2008
Location: Nova Prospekt, North Yorks, UK
Posted: 14th Jun 2009 17:43
Hmmm ok thanks. I'll try that when I come to that part properly. Thanks

Login to post a reply

Server time is: 2024-04-27 01:35:41
Your offset time is: 2024-04-27 01:35:41