TransparentSpriteColor fails with DirectX9 subsystem?

Advanced game related topics
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

TransparentSpriteColor fails with DirectX9 subsystem?

Post by Fluid Byte »

Code: Select all

InitSprite() : InitKeyboard()

OpenWindow(0,0,0,640,480,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)

CreateSprite(0,300,300)
StartDrawing(SpriteOutput(0))
Box(0,0,300,300,RGB(0,128,128))
Box(50,50,200,200,#Red)
StopDrawing()

TransparentSpriteColor(0,RGB(0,128,128))

Repeat
	Repeat
		EventID = WindowEvent()
	
		Select EventID
			Case #PB_Event_CloseWindow : End 
		EndSelect
	Until EventID = 0
		
	ExamineKeyboard()
	
	ClearScreen(#White)
	DisplayTransparentSprite(0,50,50)
	FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
This doesn't display the sprite transparent with activated DX9 subsystem.

Am I missing something obvious here?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

maybe an incoherence with the RGB-function?

when I replace it with $800080, it works. please test this.


PS:
ups... when I use $808000, it does not work. dunno whats up there.
oh... and have a nice day.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Kaeru Gaman wrote:ups... when I use $808000, it does not work. dunno whats up there.
No, you are right! You just mixed up the value. It would be $808000, not $800080. :)

So you need to check for the pixel format (#PB_PixelFormat_32Bits_BGR).
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

yes, but the problem occurs with medium cyan, like your example, not with medium purple.
thus I said "dunno whats up there"...

at first glance I would have guessed on a 16bit desktop, but I use 32bit,
and the 16bit problem would occur with every color not with some specific.

the pixel format should be the same for drawing and for transparency,
so this could also not be the cause...
oh... and have a nice day.
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

Kaeru Gaman wrote:yes, but the problem occurs with medium cyan, like your example, not with medium purple.
Indeed. With medium purple you don't need to swap values, but with medium cyan. So this is not reliable ... :?
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Seems a bug with DX9 possibly. TransparentSpriteColor() takes an RGB value but the DX9 subsystem uses it in BGR format. So TransparentSpriteColor(RGB(0,128,128)) will work with a sprite boxed with RGB(128,128,0). Should do, anyhow. But - it isn't really an expected thing, so probably a bug.
Last edited by netmaestro on Fri Mar 06, 2009 12:46 am, edited 1 time in total.
BERESHEIT
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

¿swap values?

PS:
oh, I see...
when I change the color in the transparency command to BGR, it works...
strange! I would have guessed the pixel format should be the same.
oh... and have a nice day.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

I guess you can avoid it for now by using transparent sprite colors where the Red value is equal to the Blue value, ie. RGB(255,0,255) like the GeeBee2 picture in the examples.
BERESHEIT
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

now knowing it, I could use every color again, just have to swap channels for the transparency...

but it's strange anyways, I don't know how it could be repaired if the command is just a DX-API wrapper...
oh... and have a nice day.
Post Reply