Desktop FX

Share your advanced PureBasic knowledge/code with the community.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Desktop FX

Post by Psychophanta »

Code updated for 5.20+

Code: Select all

;Desktop FX by Psychophanta (Albert) 2007-03
Define .f
bitplanes.b=32
If ExamineDesktops():Global SCREENWIDTH=DesktopWidth(0),SCREENHEIGHT=DesktopHeight(0)
Else:Global SCREENWIDTH=GetSystemMetrics_(#SM_CXSCREEN),SCREENHEIGHT=GetSystemMetrics_(#SM_CYSCREEN)
EndIf
If InitSprite()=0 Or InitKeyboard()=0
  MessageRequester("Error","Can't access DirectX",0):End
EndIf
;SnapShot:
desktop.l = CreateImage(0,SCREENWIDTH,SCREENHEIGHT)
hdc.l = StartDrawing(ImageOutput(0))
SelectObject_(hdc,desktop)
BitBlt_(hdc,0,0,SCREENWIDTH,SCREENHEIGHT,GetDC_(GetDesktopWindow_()),0,0,#SRCCOPY)
StopDrawing()
DeleteDC_(hdc)
While OpenScreen(SCREENWIDTH,SCREENHEIGHT,bitplanes.b,"FullScreen")=0
  If bitplanes.b>16:bitplanes.b-8
  ElseIf SCREENHEIGHT>600:SCREENWIDTH=800:SCREENHEIGHT=600
  ElseIf SCREENHEIGHT>480:SCREENWIDTH=640:SCREENHEIGHT=480
  ElseIf SCREENHEIGHT>400:SCREENWIDTH=640:SCREENHEIGHT=400
  ElseIf SCREENHEIGHT>240:SCREENWIDTH=320:SCREENHEIGHT=240
  ElseIf SCREENHEIGHT>200:SCREENWIDTH=320:SCREENHEIGHT=200
  Else:MessageRequester("Listen:","Can't open Screen!",0):End
  EndIf
Wend
w=SCREENWIDTH:h=SCREENHEIGHT:z=1000/Sqr(3):perspw=w:PerspectiveAngle.d=#PI/16
CreateSprite(0,w,h)
StartDrawing(SpriteOutput(0))
DrawImage(ImageID(0),0,0)
StopDrawing()
DisplaySprite(0,0,0):FlipBuffers():DisplaySprite(0,0,0)
;
DataSection
Data.f 0.005,0.005,0.0045
EndDataSection
x3=w-1:x4=0:y3=h:y4=h:z3=z:z4=z
For t.b=1 To 3
  omega=-omega:Read alfa
  Repeat
    ExamineKeyboard():ClearScreen(0)
    Incrz=h*Sin(Angle)
    x1=Incrz*Tan(PerspectiveAngle):x2=x3-x1
    y1=h-h*Cos(Angle):y2=y1
    z1=z+Incrz/4.75:z2=z1
    TransformSprite(0,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4)
    DisplayTransparentSprite(0,0,0,255)
    omega+alfa
    If omega<0:Angle-Pow(omega,2):Else:Angle+Pow(omega,2):EndIf
    If Angle<0 Or Angle>4/5*#PI:Break:EndIf
    FlipBuffers():Delay(16)
  Until KeyboardPushed(#PB_Key_Escape)
Next
DisplaySprite(0,0,0):FlipBuffers():Delay(16):DisplaySprite(0,0,0)
:)
Useful for when starting and finishing a screen saver for example :P

EDITED: now without use SuperSprite3D functions, but only Pure native.
EDITED2: Again and final :)
Last edited by Psychophanta on Sun Apr 08, 2007 10:33 pm, edited 7 times in total.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Post by netmaestro »

Looks great! I like it very much!
BERESHEIT
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

nice example, very good
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

Very impressive.

Thanks.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

8)

Nice one.
I may look like a mule, but I'm not a complete ass.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Image Very nice !
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Post by yrreti »

WoW! Very nice.
I might add scary at first too! :lol: :lol:
JCV
Enthusiast
Enthusiast
Posts: 580
Joined: Fri Jun 30, 2006 4:30 pm
Location: Philippines

Post by JCV »

cool! 8)
Nice example :wink:
Derek
Addict
Addict
Posts: 2354
Joined: Wed Apr 07, 2004 12:51 am
Location: England

Post by Derek »

Wow, very neat.
SCRJ
User
User
Posts: 93
Joined: Sun Jan 15, 2006 1:36 pm

Post by SCRJ »

Very nice example! :D

*That's my new screen saver :mrgreen: *
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

ARghhhh doesn't work...

I always get "Following variable does not have a structure:'V'"
In the DisplaySuperSprite3D(Scr) macro
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

This is cool :D
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> ARghhhh doesn't work

Works for everyone else who posted. :)
Re-install v4.02 clean and try it again.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
SFSxOI
Addict
Addict
Posts: 2970
Joined: Sat Dec 31, 2005 5:24 pm
Location: Where ya would never look.....

Post by SFSxOI »

very cool...., works great. Thank you. :)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Thanks :D
@Num3, that's wierd, you should do what PB wrote. :)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
Post Reply