Making a Sprite Glow?
Posted: Tue Jul 13, 2004 8:13 pm
Is there a way to make a sprite glow without slowing the program down much?
http://www.purebasic.com
https://www.purebasic.fr/english/
I believe this implies that the glow sprites would have per-pixel alpha information that would treat the black (in this example) as 100% transparent and the white as mostly opaque....grays would be in-between...the glow sprites would be alphablended
Code: Select all
Result = OpenWindow(0, 100, 200, 400, 400, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Codemonger Blend Test")
UseJPEGImageDecoder()
InitSprite()
InitSprite3D()
OpenWindowedScreen(Result, 0, 0, 400, 400, AutoStretch, 0, 0)
CatchSprite(0, ?CodemongerLogo,#PB_Sprite_Texture)
CatchSprite(1, ?RightArrow)
CatchSprite(2, ?RightGlow1,#PB_Sprite_Texture)
CatchSprite(3, ?RightGlow2,#PB_Sprite_Texture)
CatchSprite(4, ?RightGlow3,#PB_Sprite_Texture)
CatchSprite(5, ?RightGlow4,#PB_Sprite_Texture)
CreateSprite3D(0, 0)
CreateSprite3D(2, 2)
CreateSprite3D(3, 3)
CreateSprite3D(4, 4)
CreateSprite3D(5, 5)
GlowVar = 2
GlowMod = 1
Repeat
XOffset = WindowMouseX() - 11
YOffset = WindowMouseY() - 13
If CurrentTime - OldTime > 50
OldTime = CurrentTime
GlowVar = GlowVar + GlowMod
EndIf
Start3D()
ZoomSprite3D(0, 400, 400)
Sprite3DQuality(1)
DisplaySprite3D(0,0,0,255)
Sprite3DQuality(0)
Sprite3DBlendingMode(5, 7)
If GlowVar <> 1
DisplaySprite3D(GlowVar, -18+XOffset, -13+YOffset,255)
EndIf
Stop3D()
Select GlowVar
Case 5
GlowMod = -1
Case 1
GlowMod = 1
EndSelect
DisplayTransparentSprite(1,XOffset,YOffset)
FlipBuffers()
CurrentTime = timeGetTime_()
FPS = FPS + 1
If CurrentTime-OldFPSTime => 1000
FPSCount = FPS
FPS = 0
OldFPSTime = timeGetTime_()
EndIf
StartDrawing(WindowOutput())
DrawText("FPS: " + Str(FPSCount))
StopDrawing()
EventID.l = WindowEvent()
Until EventID = #PB_Event_CloseWindow
End
CodemongerLogo: IncludeBinary "CodemongerLogo.bmp"
RightGlow1: IncludeBinary "RightGlow1.jpg"
RightGlow2: IncludeBinary "RightGlow2.jpg"
RightGlow3: IncludeBinary "RightGlow3.jpg"
RightGlow4: IncludeBinary "RightGlow4.jpg"
RightArrow: IncludeBinary "RightArrow.bmp"
maybe you need your nvidia graphics drivers updated ... i have a fx5200 and works great here.Why is that I have problems getting a lot of example code to run on my machine? I was interested in this product but find that 50% of the game/graphics examples do not work!
I have P4, 512MB ram and Fx5600 card.