Page 1 of 1

DisplayTranslucentSprite() question

Posted: Wed Jun 21, 2006 5:31 am
by Fleath//
Since I upgraded to PB4.0 I've gone about updating my code...well actually I did that months ago and just found this problem again, so I thought I'd ask about it.
When I try to use DisplayTranslucentSprite(), everything before the StartSpecialFX() is washed out in black. I want to display the translucent sprite over the top of a few normal sprites, in this case to simulate light...
However, when I use it without Start/StopSpecialFX, it doesn’t wash out the background. My guess is that creating the special effects buffer fills it with blank space, and that all the sprites before this are just covered up by this...but can anyone tell me what I could do to fix this, or what I'm doing wrong? I remember it working before PB4.0, but I could be wrong.

This is basically what I'm doing:

Code: Select all

InitSprite()
UsePNGImageDecoder()

OpenWindow(0,400,400,200, 150, "Test", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget)
OpenWindowedScreen(WindowID(0),0,0,200,150,1,0,0)

#LIGHT=1
#PATTERN=2
LoadSprite(#LIGHT,"spr_light.png",#PB_Sprite_Memory)
LoadSprite(#PATTERN,"spr_pattern.png")

Repeat
  Delay(33)
  EventID.l = WindowEvent()   ;; catch window event
  ClearScreen(RGB(255,255,255))

  DisplaySprite(#PATTERN,12,27)

  If direction=0
    trans+5
    If trans=255 : direction=1 : EndIf
  ElseIf direction=1
    trans-5
    If trans=0 : direction=0 : EndIf
  EndIf

  StartSpecialFX()
    DisplayTranslucentSprite(#LIGHT, 12, 27, trans)
  StopSpecialFX()
  
  FlipBuffers()

Until EventID = #PB_Event_CloseWindow 

Posted: Wed Jun 21, 2006 11:20 am
by Joakim Christiansen
I also wonder about this!

StartSpecailFX

Posted: Sat Jun 24, 2006 7:36 am
by GBeebe
Have you tried moving StartSpecialFX() up to the point right below your ClarScreen() ? If I remember correctly, you can still do regular displays inside SpecialFX start and stops. Maybe...

Posted: Sat Jun 24, 2006 11:25 am
by Fleath//
That does work, but with an increase in CPU drain...The documentatation says you shouldnt place normal sprite commands inside the Special Effects too. Am I missing something, or is it working unusually? I cant figure this one out...

Posted: Sat Jun 24, 2006 11:43 am
by Num3
It's always worked like this...

You have to do all operations inside startspecialfx / stopspecialfx ...

Posted: Sat Jun 24, 2006 3:31 pm
by Fleath//
I have a lot of normal sprite commands under this translucent layer though, and if I put them all in the Start/StopSpecialFX it wont use the hardware accelleration (according to the documentation) and the CPU drain goes up to around 50% (from under 10%). Not in the example I posted, but my actual game which has a lot more normal spries buzzing around the place.
If I use the command without Start/StopSpecialFX, basically the same result.
Is there any way to do this without losing out?

Posted: Sat Jun 24, 2006 4:34 pm
by Joakim Christiansen
There should really be a way :(

Then I would suggest...

Posted: Sat Jun 24, 2006 6:17 pm
by GBeebe
Maybe you should try using Sprite3d() functions for your translucid spirtes. I know from experience that setting a Transparency level in DisplaySprite3d() doesn't hardly hurt the FPS and CPU useage. And you can use Alpha stuff with .PNG files, which is great for adding shadows and glows to sprites.