Page 1 of 1
TransparentSpriteColor fails with DirectX9 subsystem?
Posted: Thu Mar 05, 2009 11:56 pm
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?
Posted: Fri Mar 06, 2009 12:14 am
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.
Posted: Fri Mar 06, 2009 12:24 am
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).
Posted: Fri Mar 06, 2009 12:29 am
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...
Posted: Fri Mar 06, 2009 12:41 am
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 ...

Posted: Fri Mar 06, 2009 12:45 am
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.
Posted: Fri Mar 06, 2009 12:45 am
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.
Posted: Fri Mar 06, 2009 1:04 am
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.
Posted: Fri Mar 06, 2009 1:26 am
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...