Voici un effet special que l'on rencontre sur les films quand la camera est dans l'axe du soleil.
Bougez la souris.
Nouvel effet a chaque Leftmouse (random).
Enjoy
Code : Tout sélectionner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code : Lightning camera ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PB6.11 - SPH(2024) and Idle (2024) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Import "user32.lib"
PrintWindow(hWnd, hdc, flags.l)
EndImport
Global width,height,wallpaper
Procedure GetWallpaper(mon=0)
Protected himage,hdc,hwnd
ExamineDesktops()
width = DesktopWidth(mon)
height = DesktopHeight(mon)
hImage = CreateImage(-1,Width,Height,24)
hDC = StartDrawing(ImageOutput(himage))
printwindow(FindWindowEx_(0, 0, @"Progman", 0) ,hdc,0)
StopDrawing()
ProcedureReturn hImage
EndProcedure
wallpaper = GetWallpaper(0)
Global chemin$,sph_cmb,attente,attente_ok,mix,miy,ddw,ddh
Global numero,timer,echelle_xf.f,echelle_yf.f,Resx,Resy,categorie$
Global ultimated_NANO_ALPHA.q,cat$,Dim speedx.w(1,1),Dim speedy.w(1,1)
Global axe1f.f,axe2f.f,axe3f.f,axe4f.f,donnees
;-GLOBALS
Global.i Image1, Image2
Global.i Texture1, Texture2
Global menu,ref_ici
;-DEFINES
Define.i Event
Define.i WindowFlags = #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget
;EnableExplicit
;-CONSTANTS
Enumeration
#MainWindow
#OpenGLGadget
EndEnumeration
;These two GL constants are used for texture creation. Don't change their values.
#GL_BGR = $80E0
#GL_BGRA = $80E1
ExamineDesktops()
ddw=DesktopWidth(0)
ddh=DesktopHeight(0)
mix=ddw/2
miy=ddh/2
;********************* DPI *********************
echelle_xf.f=(1920/ddw)*DesktopResolutionX()
echelle_yf.f=(1080/ddh)*DesktopResolutionY()
;**********************************************
;-STRUCTURES
Structure Integer2
X.i
Y.i
EndStructure
Global.Integer2 WindowDim
WindowDim\X = ddw
WindowDim\Y = ddh
;-DEFINES
Define.i Event
Define.i WindowFlags = #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget
;-DECLARES
Declare Render()
Declare Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
Declare SetupOpenGL()
Declare SetupGLTexture(ImageHandle.i)
;-MAIN WINDOW
win=OpenWindow(#MainWindow, 0, 0,ddw,ddh, "Lecteur_polygons",#PB_Window_Maximize|#PB_Window_BorderLess)
If win=0
; Beep_(500,250) : Delay(150) : Beep_(500,250)
MessageRequester("Erreur","OpenWindow() impossible")
End
EndIf
screenGL=OpenGLGadget(#OpenGLGadget,0,0,ddw,ddh)
If screenGL=0
; Beep_(500,250) : Delay(150) : Beep_(500,250)
MessageRequester("Erreur","OpenGLGadget() impossible")
End
EndIf
SetupOpenGL()
AddKeyboardShortcut(0, #PB_Shortcut_Escape, 666) ; quitter
glOrtho_(0,ddw,ddh,0,-1,1)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(0)
;*********************************************************************************************************************************
;;;;;;;;;;;
SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
Procedure Render()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glClearColor_(0,0,0,1)
glEnable_(#GL_TEXTURE_2D)
Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), -2)
glDisable_(#GL_TEXTURE_2D)
EndProcedure
Procedure Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
glBindTexture_(#GL_TEXTURE_2D, OGLTexture)
glBegin_(#GL_QUADS)
glColor4f_ (1,1,1,1)
glNormal3f_ (0,0,1.0)
glTexCoord2f_(1.0,1.0)
glVertex3f_ (StartX+Width,StartY,Z)
glTexCoord2f_(0.0,1.0)
glVertex3f_ (StartX,StartY,Z)
glTexCoord2f_(0.0,0.0)
glVertex3f_ (StartX,StartY+Height,Z)
glTexCoord2f_(1.0,0.0)
glVertex3f_ (StartX+Width,StartY+Height,Z)
glEnd_()
EndProcedure
Procedure SetupOpenGL()
glMatrixMode_(#GL_PROJECTION)
glOrtho_(0.0, WindowDim\X, WindowDim\Y, 0.0, -1000.0, 1000.0)
glMatrixMode_(#GL_MODELVIEW)
; glEnable_(#GL_DEPTH_TEST)
glEnable_(#GL_BLEND)
glBlendFunc_(#GL_SRC_ALPHA, #GL_ONE_MINUS_SRC_ALPHA)
EndProcedure
Procedure affiche_poly(attente,pol,xxx,yyy,angle.f,dkx,dky,zoom.f,alpha.f)
sph_cmb=speedy(pol,0)
sph_la=0
Repeat
glBegin_(#GL_POLYGON)
glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
glColor4f_(speedx(pol,sph_la+1)/255,speedy(pol,sph_la+1)/255,speedx(pol,sph_la+2)/255,(speedy(pol,sph_la+2)/255)*alpha)
;;;;;;
For i=3 To sph_cmb-1
sph_xxx.f=(speedx(pol,sph_la+i)/echelle_xf)-xxx
sph_yyy.f=(speedy(pol,sph_la+i)/echelle_yf)-yyy
sq.f=Sqr(sph_xxx*sph_xxx+sph_yyy*sph_yyy)
ff.f = ATan2(sph_xxx,sph_yyy)+angle ; par Nemerod (sans lui, je n'y serai pas arrivé)
centre_x=xxx+Cos(ff)*sq*zoom
centre_y=yyy+Sin(ff)*sq*zoom
glVertex2f_(centre_x+dkx,centre_y+dky);
Next
;;;;;;;
glEnd_() ;
sph_cmb=speedy(pol,sph_la+i)
sph_la+i
Until speedy(pol,sph_la)=0
If attente<>0 And ElapsedMilliseconds()-timer>=attente
timer=ElapsedMilliseconds()
numero+1
EndIf
;;;;;;;;;;;;;;;
EndProcedure
Procedure SetupGLTexture(ImageHandle.i)
Define.i ImageW, ImageH, ImageD
Define.i MemoryAddress
Define.i TextureHandle
If IsImage(ImageHandle) = 0
ProcedureReturn #False
EndIf
ImageD = ImageDepth(ImageHandle, #PB_Image_InternalDepth)
StartDrawing(ImageOutput(ImageHandle))
MemoryAddress = DrawingBuffer()
StopDrawing()
If MemoryAddress = 0
ProcedureReturn #False
EndIf
glGenTextures_(1, @TextureHandle)
glBindTexture_(#GL_TEXTURE_2D, TextureHandle)
ImageW = ImageWidth(ImageHandle)
ImageH = ImageHeight(ImageHandle)
If ImageD = 32
glTexImage2D_(#GL_TEXTURE_2D, 0, 4, ImageW, ImageH, 0, #GL_BGRA, #GL_UNSIGNED_BYTE, MemoryAddress)
Else
glTexImage2D_(#GL_TEXTURE_2D, 0, 3, ImageW, ImageH, 0, #GL_BGR, #GL_UNSIGNED_BYTE, MemoryAddress)
EndIf
glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MIN_FILTER, #GL_LINEAR)
; glTexParameteri_(#GL_TEXTURE_2D, #GL_TEXTURE_MAG_FILTER, #GL_LINEAR)
ProcedureReturn TextureHandle
EndProcedure
Procedure gestion()
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Resx = GetGadgetAttribute(1, #PB_OpenGL_MouseX)
Resy = GetGadgetAttribute(1, #PB_OpenGL_MouseY)
;;;;;;;
Select EventType()
Case #PB_EventType_LeftClick
donnees=1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndSelect
EndSelect
Case #PB_Event_Menu
Select EventMenu()
Case 666
;timer=ElapsedMilliseconds()-timer
;ShowCursor_(1)
End
EndSelect
EndSelect
Until Event = 0
EndProcedure
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
glClearColor_(0,0,0, 1.0)
max=21
poly_cmb=0
pol=0
Dim speedx(poly_cmb,max)
Dim speedy(poly_cmb,max)
For i=1 To max
Read.w speedx(pol,i-1)
Read.w speedy(pol,i-1)
Next
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Image1 = GetWallpaper(0)
Texture1 = SetupGLTexture(Image1)
;;;;;;;;;;;;;;;;;;;;;;;
combien=8
donnees=1
Repeat
If donnees=1
donnees=0
Dim zoo1(combien)
Dim zoo2(combien)
For i=0 To combien
zoo1(i)=Random(200)+55
zoo2(i)=Random(200)+55
Next
Dim zoom.f(combien)
Dim zoom2.f(combien)
For i=0 To combien
zoom(i)=Random(100)/100
zoom2(i)=Random(100)/100
Next
Dim dist.f(combien)
For i=0 To combien
dist(i)=0.2+Random(400)/100
Next
centrex=(540/echelle_xf)
centrey=(540/echelle_yf)
ddwf.f=5.4+ddw/1920
ddhf.f=5.4+ddh/1080
EndIf
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
gestion()
Render()
glReadPixels_(Resx, ddh-1-Resy, 1 , 1, #GL_RGBA, #GL_UNSIGNED_BYTE, @pixels )
;##############################################
;affiche_poly(attente | n° de polygone | axe de rotation X | axe de rotation Y | angle de rotation(.f) | decallage X | decallage Y | Zoom(.f) | alpha.f)
;mix=milieu de l'ecran (en X)
;miy=milieu de l'ecran (en Y)
;##############################################
For nb=0 To combien
For i=0 To 20
affiche_poly(0,0,0,0,0,mix-centrex*zoom(nb)+i*ddwf-mix*dist(nb)+Resx*dist(nb),miy-centrey*zoom(nb)+i*ddhf-miy*dist(nb)+Resy*dist(nb),zoom(nb)-i/100,1/zoo1(nb))
affiche_poly(0,0,0,0,0,mix-centrex*zoom2(nb)+i*ddwf+mix*dist(nb)-Resx*dist(nb),miy-centrey*zoom2(nb)+i*ddhf+miy*dist(nb)-Resy*dist(nb),zoom2(nb)-i/100,1/zoo2(nb))
Next
Next
SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
ForEver
End
DataSection
sph_data:
Data.w 1,21,255,255,255,255,1014,802,1025,775,1025,304,1012,270,990,243,566,4,540,1,511,4,80
Data.w 255,65,272,59,295,59,781,64,804,81,819,518,1077,543,1079,567,1077,993,829
Data.w 0,0
EndDataSection