lightning camera

Everything related to 3D programming
User avatar
SPH
Enthusiast
Enthusiast
Posts: 571
Joined: Tue Jan 04, 2011 6:21 pm

lightning camera

Post by SPH »

Hi,
Here is a special effect that we find on films when the camera is in the axis of the sun.
Move the mouse.
New effect at each leftmouse (random).

Big thanks to Idle !!

Enjoy

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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
Last edited by SPH on Mon Oct 14, 2024 7:57 am, edited 3 times in total.

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
threedslider
Enthusiast
Enthusiast
Posts: 397
Joined: Sat Feb 12, 2022 7:15 pm

Re: lightning camera

Post by threedslider »

Nice effects :D

It is great work and thank you for sharing :shock:

Happy coding !
threedslider
Enthusiast
Enthusiast
Posts: 397
Joined: Sat Feb 12, 2022 7:15 pm

Re: lightning camera

Post by threedslider »

I make a little change that depend to Sun and little halo effects :mrgreen:

Before to copy paste the code so download please the picture for background to see this effect :wink: : https://drive.google.com/file/d/1IGMXxB ... sp=sharing

And now here the code :

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code : Lightning camera   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PB6.11 - SPH(2024) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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
;-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=1500
ddh=1001
mix=ddw/2
miy=ddh/2

;********************* DPI *********************
echelle_xf.f=  (ddw / DesktopResolutionX()) / 2 
echelle_yf.f=  (ddh / DesktopResolutionY()) / 2
;**********************************************

;-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/DesktopResolutionX(), ddh/DesktopResolutionY(), "Lecteur_polygons",#PB_Window_ScreenCentered)
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)/DesktopResolutionX(), ImageHeight(Image1)/DesktopResolutionY(), -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 Sun_render(size.f, movex.f, movey.f, angle.f, colorx.f, colory.f, colorz.f)
  
      draw_x.f =   60 * Cos(angle)
      draw_y.f =   60 * Sin(angle)
      
      glBegin_(#GL_QUADS)
        
        glColor3f_(colorx, colory, colorz)
        glVertex3f_( -draw_x*size+movex,  -draw_y*size+movey , 0.1) 
        glVertex3f_( -draw_x*size+movex,  draw_y*size+movey , 0.1) 
        glVertex3f_( draw_x*size+movex,  draw_y*size+movey , 0.1) 
        glVertex3f_( draw_x*size+movex,  -draw_y*size+movey , 0.1) 
     
      glEnd_()
       
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()
                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
            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

;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************

UseJPEGImageDecoder()

image$="paysage.jpg"      ;- put a picture in desktop resolution (if you can, else not =) )
Image1 = LoadImage(#PB_Any,image$)
Texture1 = SetupGLTexture(Image1)

;;;;;;;;;;;;;;;;;;;;;;;

combien=6

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)=Random(200)/100
Next

centrex=(echelle_xf)
centrey=(echelle_yf)

ddwf.f=5.4+ddw/2
ddhf.f=5.4+ddh/2


Repeat
  
  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,Resx*dist(nb)+90, Resy*dist(nb)+90,20,1/zoo1(nb))
      ;affiche_poly(0,0,0,0,0,centrex*zoom2(nb)+i*mix*dist(nb)-Resx*dist(nb),centrey*zoom2(nb)+i*miy*dist(nb)-Resy*dist(nb),zoom2(nb)-i/100,1/zoo2(nb))
    Next
  Next
  
  For drawxy = 0 To 360
    Sun_render(0.5, 90, 90, drawxy, 1.0, 1.0, 1.0)
  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
What do you think of this change ?
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 193
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: lightning camera

Post by moulder61 »

@threedslider

Nice effect, but the picture is upside down and reversed in Linux. :!:

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
User avatar
SPH
Enthusiast
Enthusiast
Posts: 571
Joined: Tue Jan 04, 2011 6:21 pm

Re: lightning camera

Post by SPH »

You mean that with my code, when you put your image on my line 252, it ends up upside down when you run the code?
If yes, as it is not the case on Windows (10 and 11), it means that one of the codes is buggy.

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 193
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: lightning camera

Post by moulder61 »

@SPH

My comment was aimed at threedslider. Your code works fine. 8)

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
threedslider
Enthusiast
Enthusiast
Posts: 397
Joined: Sat Feb 12, 2022 7:15 pm

Re: lightning camera

Post by threedslider »

moulder61 wrote: Sat Oct 12, 2024 3:38 pm Nice effect, but the picture is upside down and reversed in Linux. :!:
Strange :shock: ... It works well on win 11 here. Maybe if I fix that by line 101 and change to as :

Code: Select all

Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), -2)
Is it that work for you on Linux ?
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 193
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: lightning camera

Post by moulder61 »

@threedslider

Still the same.

Moulder.

Image
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
threedslider
Enthusiast
Enthusiast
Posts: 397
Joined: Sat Feb 12, 2022 7:15 pm

Re: lightning camera

Post by threedslider »

moulder61 wrote: Sat Oct 12, 2024 8:30 pm @threedslider

Still the same.

Moulder.

Image
Woot !! It is a serious bug here, not sure if I have inversed the picture and changed the color :shock: :?

Image

I will see what is caused in linux but I am on win 11 and not linux... :|
threedslider
Enthusiast
Enthusiast
Posts: 397
Joined: Sat Feb 12, 2022 7:15 pm

Re: lightning camera

Post by threedslider »

moulder61 wrote: Sat Oct 12, 2024 8:30 pm Still the same.
Hard to see where it is the problem ? At worse desactivate the function on line 32 by adding a comment

Otherwise I have not touched the picture, it sounds strange my code :shock:

@Fred : Any help from my changed code, is it me or is it a bug ?
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: lightning camera

Post by minimy »

nice effect SPH! i feel like spielberg! :lol:
Thanks for share!
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
SPH
Enthusiast
Enthusiast
Posts: 571
Joined: Tue Jan 04, 2011 6:21 pm

Re: lightning camera

Post by SPH »

minimy wrote: Sat Oct 12, 2024 9:48 pm nice effect SPH! i feel like spielberg! :lol:
Thanks for share!
Thx baby love... OOPS : thanks very much :wink:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
User avatar
minimy
Enthusiast
Enthusiast
Posts: 619
Joined: Mon Jul 08, 2013 8:43 pm
Location: off world

Re: lightning camera

Post by minimy »

:lol:
SPH wrote: Sat Oct 12, 2024 10:26 pm
minimy wrote: Sat Oct 12, 2024 9:48 pm nice effect SPH! i feel like spielberg! :lol:
Thanks for share!
Thx baby love... OOPS : thanks very much :wink:
If translation=Error: reply="Sorry, Im Spanish": Endif
User avatar
moulder61
Enthusiast
Enthusiast
Posts: 193
Joined: Sun Sep 19, 2021 6:16 pm
Location: U.K.

Re: lightning camera

Post by moulder61 »

threedslider wrote: Sat Oct 12, 2024 9:14 pm Hard to see where it is the problem ? At worse desactivate the function on line 32 by adding a comment
That didn't make any difference either. :(

@SPH
I tried your original code again and that doesn't work either! I didn't use a large image when I tested it so I never noticed it was upside down? The effect was pretty nice though. :wink:

Moulder.
"If it ain't broke, fix it until it is!

This message is brought to you thanks to SenselessComments.com

My PB stuff for Linux: "https://u.pcloud.link/publink/show?code ... z3MR0T3jyV
User avatar
SPH
Enthusiast
Enthusiast
Posts: 571
Joined: Tue Jan 04, 2011 6:21 pm

Re: lightning camera

Post by SPH »

With the help of Idle, I updated post 1.
No need to manually put an image anymore.

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Portable LENOVO ideapad 110-17ACL 64 bits
Version de PB : 6.12LTS - 64 bits
Post Reply