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 / problem using "set image colorkey" and "set camera to image"

Author
Message
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Feb 2009 18:43
I can't seem to get set image colorkey to work with images created using set camera to image - i.e. the "transparent" colour keeps getting rendered when I try to paste the camera's output to the screen bitmap.

Anyone know how to do this?

[The only way I could get it to work is the following cumbersome sequence:

0. set image colorkey
1. render the image using a camera
2. save the image as .bmp
3. load the image back in again
4. paste the loaded image to the screen

Works perfectly. So why are steps 2 and 3 needed?
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 7th Feb 2009 19:41 Edited at: 7th Feb 2009 19:43
SET CAMERA TO IMAGE Camera Number, Image Number, Width, Height, Generate Alpha Mode

Generate Alpha Mode 3 should do the trick... does for me... so you shouldnt have to do 2,3,4 ....


edit: well yeah , guess you got to do 4 somehow .... I'm in sprite land with it at the moment

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Feb 2009 19:50 Edited at: 7th Feb 2009 20:12
Thanks! I always forget to look at the extra flags.

I'll test it out ASAP.

Edit Alpha mode 1 with set colorkey set to black did the trick. Thanks. Didn't speed up my demo surprisingly - but at least the code is cleaner.
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 7th Feb 2009 19:58 Edited at: 7th Feb 2009 21:33
I love it! I set the Render Target as big as my screen(1680x1050) and draw a fast area selection with four lines to the Render Target image and then display all that with a sprite. So instead of getting 15-30fps doing the old getimage routine, this method fly's at around 750 fps ( just testing that alone ). It's a powerfull tool!

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 7th Feb 2009 21:35 Edited at: 7th Feb 2009 21:44
Quote: "Edit Alpha mode 1 with set colorkey set to black did the trick. Thanks. Didn't speed up my demo surprisingly - but at least the code is cleaner. "


Are you constantly updating your image every frame?

edit:

as an example:

( Outside of loop, only needs to be done once )
set camera to image 1,1,#,#,2(<- whatever flag you need here)
sync mask %11111101

(inside loop)
set current bitmap -1
cls 0
` Draw your graphics here
set current bitmap 0

`Render Target results
`paste image 1,#,#,1 ... or ...
`sprite #,#,#,1


Edit : I meant mode 2 not 3 when I was talking about it... sry...

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Feb 2009 00:52
Quote: "Are you constantly updating your image every frame?"


Yes, because it's a screenshot of a single moving object in a dynamic scene.

Quote: "( Outside of loop, only needs to be done once )"


No, it needs to be done every frame. Have a look at my latest, totally impractical, demo on the Learning to Write Shaders thread.

In that demo each object has a different dynamic cube map applied to it - although the same image memory is re-used for the purpose. Each object is rendered on its own to a "masking" image as soon as its cube map is rendered. This image is then pasted onto the final screen bitmap - but only the object is rendered hence the need for set image colorkey.

If the objects are static then everything is much simpler as you say.

Quote: "Edit : I meant mode 2 not 3 when I was talking about it... sry..."


Actually I found mode 1 worked - but you couldn't guess that from the Help file.
Todd Riggins
20
Years of Service
User Offline
Joined: 29th Oct 2004
Location: Texas, USA
Posted: 8th Feb 2009 19:20 Edited at: 8th Feb 2009 19:22
Ah, I looked at what your doing and I was not on the same page as you on what you are doing. My mindset was on just updating the rendertarget image for simple text/2d operations and displaying image via a sprite, not the undocumented cube mapping/'sync camera' stuff. sry...

Inspirational Music: Descent ][ Redbook Audio CD Soundtrack

Login to post a reply

Server time is: 2025-08-09 02:28:55
Your offset time is: 2025-08-09 02:28:55