Picasso SPH

Everything else that doesn't fall into one of the other PB categories.
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Picasso SPH

Post by SPH »

Hi,

Here is an abstract paintings generator. It is entirely made in OpenGL. I had fun doing it.
Know that it works with many Cos and Sin; so maybe you won't understand the code.
The code is ugly because it didn't have that purpose. The tables are formed after about 1 minute. Then it becomes anything. :D

Thanks to Falsam without whom I would never have managed to code in OpenGL (the code base is from him (maybe 2 years ago)) :idea:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;           p i c a s s o _ S P H          ;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code : SPH  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PB6.0 (2022) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;EnableExplicit

;-CONSTANTS
Enumeration
  #MainWindow
  #OpenGLGadget
EndEnumeration


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Réglage  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;nb=30 entre 0 (1 ligne) et x milliards (+++) ;D
nb=30
;alpha.f entre 0.005 (tres transparent) et 1 (pas transparent)
alpha.f=0.01
;rayon.f entre 1 (plein ecran) et 6 (cadrage serré)
rayon.f=2.5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;These two GL constants are used for texture creation. Don't change their values.
#GL_BGR = $80E0
#GL_BGRA = $80E1

If ExamineDesktops()
  ddw=DesktopWidth(0)
  ddh=DesktopHeight(0)
Else
  ddw=1024
  ddh=768
EndIf


;********************* DPI *********************
dpix.f=DesktopResolutionX()
dpiy.f=DesktopResolutionY()

If dpix > 1
xf.f=(1920/ddw)*dpix
Else
   xf = 1
EndIf

If dpiy > 1
yf.f=(1024/ddh)*dpiy
Else
   yf = 1
 EndIf
 
;**********************************************

;-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, "Picasso_SPH",#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)

;*********************************************************************************************************************************

;;;;;;;;;;;
timer=ElapsedMilliseconds()

glClearColor_(0,0,0, 1.0)
ShowCursor_(0)
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Dim sph_x1.f(nb)
Dim sph_y1.f(nb)
Dim sph_x2.f(nb)
Dim sph_y2.f(nb)
Dim sph_x3.f(nb)
Dim sph_y3.f(nb)
Dim sph_x4.f(nb)
Dim sph_y4.f(nb)
Dim sph_x11.f(nb);=(50+Random(50))/20000
Dim sph_y11.f(nb);=(50+Random(50))/20000
Dim sph_x21.f(nb);=(50+Random(50))/20000
Dim sph_y21.f(nb);=(50+Random(50))/20000
Dim sph_x31.f(nb);=(50+Random(50))/20000
Dim sph_y31.f(nb);=(50+Random(50))/20000
Dim sph_x41.f(nb);=(50+Random(50))/20000
Dim sph_y41.f(nb);=(50+Random(50))/20000
Dim sph_xx(nb)
Dim sph_yy(nb)
Dim sph_xx2(nb);=Cos(sph_x3(i))*ddw31
Dim sph_yy2(nb);=Sin(sph_y3(i))*ddh31
Dim sph_xx2(nb);+Cos(sph_x4(i))*ddw32
Dim sph_yy2(nb);+Sin(sph_y4(i))*ddh32
Dim r(4)
Dim v(4)
Dim b(4)

; reglage des couleurs ici (mais c'est délicat)
r(0)=255
v(0)=0
b(0)=0

r(1)=255
v(1)=255
b(1)=0

r(2)=0
v(2)=255
b(2)=0

r(3)=0
v(3)=0
b(3)=255

r(4)=255
v(4)=0
b(4)=255
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


For i=0 To nb
sph_x1.f(i)=(0+Random(200000))/100000;+0.13
sph_y1.f(i)=(0+Random(200000))/100000;0.152
sph_x2.f(i)=(0+Random(200000))/100000;0.1233
sph_y2.f(i)=(0+Random(200000))/100000;0.1402
sph_x3.f(i)=(0+Random(200000))/100000;+0.13
sph_y3.f(i)=(0+Random(200000))/100000;0.152
sph_x4.f(i)=(0+Random(200000))/100000;0.1233
sph_y4.f(i)=(0+Random(200000))/100000;0.1402

sph_x11.f(i)=(50+Random(100))/30000
sph_y11.f(i)=(50+Random(100))/30000
sph_x21.f(i)=(50+Random(100))/30000
sph_y21.f(i)=(50+Random(100))/30000
sph_x31.f(i)=(50+Random(100))/30000
sph_y31.f(i)=(50+Random(100))/30000
sph_x41.f(i)=(50+Random(100))/30000
sph_y41.f(i)=(50+Random(100))/30000

Next


;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Repeat
  
  For i=0 To nb
    
  ddw21=Sin(sph_x1(i))*ddw/rayon.f
  ddh21=Cos(sph_y1(i))*ddh/rayon.f
  ddw22=Sin(sph_x2(i))*ddw/rayon.f
  ddh22=Cos(sph_x2(i))*ddh/rayon.f
  
sph_xx(i)=Cos(sph_x1(i))*ddw21
sph_yy(i)=Sin(sph_y1(i))*ddh21
sph_xx(i)+Cos(sph_x2(i))*ddw22
sph_yy(i)+Sin(sph_y2(i))*ddh22

  ddw31=Sin(sph_x3(i))*ddw/rayon.f
  ddh31=Cos(sph_y3(i))*ddh/rayon.f
  ddw32=Cos(sph_x4(i))*ddw/rayon.f
  ddh32=Sin(sph_y4(i))*ddh/rayon.f
  
sph_xx2(i)=Cos(sph_x3(i))*ddw31
sph_yy2(i)=Sin(sph_y3(i))*ddh31
sph_xx2(i)+Sin(sph_x4(i))*ddw32
sph_yy2(i)+Cos(sph_y4(i))*ddh32

Next

;glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)


;*****
  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
          ;MessageRequester("Timer", Str(timer)+" ms - "+Str(scene)+" frames",2)
;           Debug scene
;           Debug timer
          ShowCursor_(1)
          End
        EndSelect
    EndSelect
   
  Until Event = 0
 
 
  ;##############################################
  ;##############################################
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; L I N E S ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  For i=0 To nb
    
    glBegin_(#GL_LINES);

    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    
    glColor4f_(r(i%5),v(i%5),b(i%5),alpha)
    
    glVertex2f_(ddw/2+sph_xx(i),ddh/2+sph_yy(i));
    glVertex2f_(ddw/2-sph_xx2(i),ddh/2-sph_yy2(i));
glEnd_(); 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 
  sph_x1(i)+sph_x11(i);0.00951
  sph_y1(i)+sph_y11(i);(50+Random(50))/10000;0.00732
  
  sph_x2(i)+sph_x21(i);(50+Random(50))/10000;0.00621
  sph_y2(i)+sph_y21(i);(50+Random(50))/10000;0.01
  
  sph_x3(i)+sph_x31(i);0.00951
  sph_y3(i)+sph_y31(i);(50+Random(50))/10000;0.00732
  
  sph_x4(i)+sph_x41(i);(50+Random(50))/10000;0.00621
  sph_y4(i)+sph_y41(i);(50+Random(50))/10000;0.01
Next

  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
  
ForEver




Procedure Render()
 
  ;Clearing buffers and resetting clear color to remove old graphics from the last frame.
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  ;  glClearColor_(0.2, 0.2, 0.2, 1.0)
  glClearColor_(0,0,0,1)
 
  ;## DRAWING TEXTURES/IMAGES
  ;First enable the Texture system.
  glEnable_(#GL_TEXTURE_2D)
 
  ;This procedure will create a quad and apply a texture to it.
  ;The Texture variable contains the texture created earlier using SetupGLTexture().
  Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), -2)
  ; Render2DQuad(Texture2, 0, 0, ImageWidth(Image2), ImageHeight(Image2), -1)
 
  ;After all the textures have been displayed disable the texture system.
  ;Otherwise it will conflict with the non texture graphics.
  glDisable_(#GL_TEXTURE_2D)
 
EndProcedure

Procedure Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
 
  ;The texture is first bound which tells OpenGL to use this texture for any future rendering.
  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


http://HexaScrabble.com/
!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 : 5.73LTS - 32 bits
User avatar
jacdelad
Addict
Addict
Posts: 1475
Joined: Wed Feb 03, 2021 12:46 pm
Location: Planet Riesa
Contact:

Re: Picasso SPH

Post by jacdelad »

Wow, looks very nice. Like one of the good old screensavers.
PureBasic 6.04/XProfan X4a/Embarcadero RAD Studio 11/Perl 5.2/Python 3.10
Windows 11/Ryzen 5800X/32GB RAM/Radeon 7770 OC/3TB SSD/11TB HDD
Synology DS1821+/36GB RAM/130TB
Synology DS920+/20GB RAM/54TB
Synology DS916+ii/8GB RAM/12TB
User avatar
idle
Always Here
Always Here
Posts: 5092
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Picasso SPH

Post by idle »

cool
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Picasso SPH

Post by SPH »

With triangles :

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;           p i c a s s o _ S P H          ;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code : SPH  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; triangles  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PB6.0 (2022) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;EnableExplicit

;-CONSTANTS
Enumeration
  #MainWindow
  #OpenGLGadget
EndEnumeration


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Réglage  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;nb=30 entre 0 (1 ligne) et x milliards (+++) ;D
nb=7
;alpha.f entre 0.005 (tres transparent) et 1 (pas transparent)
alpha.f=0.03
;rayon.f entre 1 (plein ecran) et 6 (cadrage serré)
rayon.f=2.2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;These two GL constants are used for texture creation. Don't change their values.
#GL_BGR = $80E0
#GL_BGRA = $80E1

If ExamineDesktops()
  ddw=DesktopWidth(0)
  ddh=DesktopHeight(0)
Else
  ddw=1024
  ddh=768
EndIf


;********************* DPI *********************
dpix.f=DesktopResolutionX()
dpiy.f=DesktopResolutionY()

If dpix > 1
  xf.f=(1920/ddw)*dpix
Else
  xf = 1
EndIf

If dpiy > 1
  yf.f=(1024/ddh)*dpiy
Else
  yf = 1
EndIf

;**********************************************

;-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, "Picasso_SPH",#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)

;*********************************************************************************************************************************

;;;;;;;;;;;
timer=ElapsedMilliseconds()

glClearColor_(0,0,0, 1.0)
ShowCursor_(0)
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Dim sph_x1.f(nb)
Dim sph_y1.f(nb)
Dim sph_x2.f(nb)
Dim sph_y2.f(nb)
Dim sph_x3.f(nb)
Dim sph_y3.f(nb)
Dim sph_x4.f(nb)
Dim sph_y4.f(nb)
Dim sph_x11.f(nb);=(50+Random(50))/20000
Dim sph_y11.f(nb);=(50+Random(50))/20000
Dim sph_x21.f(nb);=(50+Random(50))/20000
Dim sph_y21.f(nb);=(50+Random(50))/20000
Dim sph_x31.f(nb);=(50+Random(50))/20000
Dim sph_y31.f(nb);=(50+Random(50))/20000
Dim sph_x41.f(nb);=(50+Random(50))/20000
Dim sph_y41.f(nb);=(50+Random(50))/20000
Dim sph_xx.f(nb)
Dim sph_yy.f(nb)
Dim sph_xx2.f(nb)
Dim sph_yy2.f(nb)

Dim rayon(nb)
Dim sph_r.f(nb)
Dim sph_r2.f(nb)
Dim sph_xr.f(nb)
Dim sph_xr2.f(nb)
Dim sph_rr.f(nb)
Dim sph_rr2.f(nb)
Dim sph_xrr.f(nb)
Dim sph_xrr2.f(nb)
Dim sph_yrr.f(nb)
Dim sph_yrr2.f(nb)

Dim r(4)
Dim v(4)
Dim b(4)

; reglage des couleurs ici (mais c'est délicat)
r(0)=255
v(0)=0
b(0)=0

r(1)=255
v(1)=255
b(1)=0

r(2)=0
v(2)=255
b(2)=0

r(3)=0
v(3)=0
b(3)=255

r(4)=255
v(4)=0
b(4)=255
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
angle.f=(3.141592*2)/3

For i=0 To nb
  sph_x1.f(i)=(0+Random(200000))/100000;+0.13
  sph_y1.f(i)=(0+Random(200000))/100000;0.152
  sph_x2.f(i)=(0+Random(200000))/100000;0.1233
  sph_y2.f(i)=(0+Random(200000))/100000;0.1402
  sph_x3.f(i)=(0+Random(200000))/100000;+0.13
  sph_y3.f(i)=(0+Random(200000))/100000;0.152
  sph_x4.f(i)=(0+Random(200000))/100000;0.1233
  sph_y4.f(i)=(0+Random(200000))/100000;0.1402
  sph_r.f(i)=(0+Random(200000))/100000 ;0.1233
  sph_r2.f(i)=(0+Random(200000))/100000;0.1233
  sph_xr.f(i)=(0+Random(200000))/100000;0.1233
  sph_xr2.f(i)=(0+Random(200000))/100000;0.1233
  
  sph_x11.f(i)=(50+Random(100))/30000
  sph_y11.f(i)=(50+Random(100))/30000
  sph_x21.f(i)=(50+Random(100))/30000
  sph_y21.f(i)=(50+Random(100))/30000
  sph_x31.f(i)=(50+Random(100))/30000
  sph_y31.f(i)=(50+Random(100))/30000
  sph_x41.f(i)=(50+Random(100))/30000
  sph_y41.f(i)=(50+Random(100))/30000
  sph_rr.f(i)=(50+Random(100))/20000
  sph_rr2.f(i)=(50+Random(100))/20000
  sph_yrr.f(i)=(50+Random(100))/20000
  sph_yrr2.f(i)=(50+Random(100))/20000
  
  rayon(i)=10+Random(70)
  
Next


;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Repeat
  
  For i=0 To nb
    
    ddw21=Sin(sph_x1(i))*ddw/rayon.f
    ddh21=Cos(sph_y1(i))*ddh/rayon.f
    ddw22=Sin(sph_x2(i))*ddw/rayon.f
    ddh22=Cos(sph_x2(i))*ddh/rayon.f
    
    sph_xx.f(i)=Cos(sph_x1(i))*ddw21
    sph_yy.f(i)=Sin(sph_y1(i))*ddh21
    sph_xx.f(i)+Cos(sph_x2(i))*ddw22
    sph_yy.f(i)+Sin(sph_y2(i))*ddh22
    
    ddw31=Sin(sph_x3(i))*ddw/rayon.f
    ddh31=Cos(sph_y3(i))*ddh/rayon.f
    ddw32=Cos(sph_x4(i))*ddw/rayon.f
    ddh32=Sin(sph_y4(i))*ddh/rayon.f
    
    sph_xx2.f(i)=Cos(sph_x3(i))*ddw31
    sph_yy2.f(i)=Sin(sph_y3(i))*ddh31
    sph_xx2.f(i)+Sin(sph_x4(i))*ddw32
    sph_yy2.f(i)+Cos(sph_y4(i))*ddh32
    
    ;====
    sph_r(i)=Cos(sph_rr(i))
    rayon(i)=Cos(sph_r(i))*200+Sin(sph_r2(i))*200
    sph_rr(i)+sph_yrr2(i)
    ;====
    
    
  Next
  
  
  ;*****
  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
  
  
  ;##############################################
  ;##############################################
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; L I N E S ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  For i=0 To nb
    
    ;     glBegin_(#GL_LINES);
    ; 
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    
    glColor4f_(r(i%5),v(i%5),b(i%5),alpha)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
    
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    
    glColor4f_(r(i%5),v(i%5),b(i%5),alpha)
    
    
    glVertex2f_(ddw/2+sph_xx(i)+Cos(0+sph_r(i))*rayon(i),ddh/2+sph_yy(i)+Sin(0+sph_r(i))*rayon(i));
    glVertex2f_(ddw/2+sph_xx(i)+Cos(angle.f+sph_r(i))*rayon(i),ddh/2+sph_yy(i)+Sin(angle.f+sph_r(i))*rayon(i));
    glEnd_()
    ; ; ; ; ; ; ; 
    glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
    
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    
    glColor4f_(r(i%5),v(i%5),b(i%5),alpha)
    
    
    glVertex2f_(ddw/2+sph_xx(i)+Cos(angle.f+sph_r(i))*rayon(i),ddh/2+sph_yy(i)+Sin(angle.f+sph_r(i))*rayon(i));
    glVertex2f_(ddw/2+sph_xx(i)+Cos(angle.f*2+sph_r(i))*rayon(i),ddh/2+sph_yy(i)+Sin(angle.f*2+sph_r(i))*rayon(i));
    glEnd_()
    ; ; ; ; ; ; ; 
    glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
    
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    
    glColor4f_(r(i%5),v(i%5),b(i%5),alpha)
    
    
    glVertex2f_(ddw/2+sph_xx(i)+Cos(angle.f*2+sph_r(i))*rayon(i),ddh/2+sph_yy(i)+Sin(angle.f*2+sph_r(i))*rayon(i));
    glVertex2f_(ddw/2+sph_xx(i)+Cos(0+sph_r(i))*rayon(i),ddh/2+sph_yy(i)+Sin(0+sph_r(i))*rayon(i))                ;
    glEnd_()
    
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    
    
    sph_x1(i)+sph_x11(i);0.00951
    sph_y1(i)+sph_y11(i);(50+Random(50))/10000;0.00732
    
    sph_x2(i)+sph_x21(i);(50+Random(50))/10000;0.00621
    sph_y2(i)+sph_y21(i);(50+Random(50))/10000;0.01
    
    sph_x3(i)+sph_x31(i);0.00951
    sph_y3(i)+sph_y31(i);(50+Random(50))/10000;0.00732
    
    sph_x4(i)+sph_x41(i);(50+Random(50))/10000;0.00621
    sph_y4(i)+sph_y41(i);(50+Random(50))/10000;0.01
    
    sph_xx(i)+sph_xx2(i);(50+Random(50))/10000;0.00621
    sph_yy(i)+sph_yy2(i);(50+Random(50))/10000;0.01
  Next
  
  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
  
ForEver




Procedure Render()
  
  ;Clearing buffers and resetting clear color to remove old graphics from the last frame.
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  ;  glClearColor_(0.2, 0.2, 0.2, 1.0)
  glClearColor_(0,0,0,1)
  
  ;## DRAWING TEXTURES/IMAGES
  ;First enable the Texture system.
  glEnable_(#GL_TEXTURE_2D)
  
  ;This procedure will create a quad and apply a texture to it.
  ;The Texture variable contains the texture created earlier using SetupGLTexture().
  Render2DQuad(Texture1, 0, 0, ImageWidth(Image1), ImageHeight(Image1), -2)
  ; Render2DQuad(Texture2, 0, 0, ImageWidth(Image2), ImageHeight(Image2), -1)
  
  ;After all the textures have been displayed disable the texture system.
  ;Otherwise it will conflict with the non texture graphics.
  glDisable_(#GL_TEXTURE_2D)
  
EndProcedure

Procedure Render2DQuad(OGLTexture.i, StartX.d, StartY.d, Width.i, Height.i, Z.d)
  
  ;The texture is first bound which tells OpenGL to use this texture for any future rendering.
  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



http://HexaScrabble.com/
!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 : 5.73LTS - 32 bits
User avatar
SPH
Enthusiast
Enthusiast
Posts: 268
Joined: Tue Jan 04, 2011 6:21 pm

Re: Picasso SPH

Post by SPH »

Tell me all: I'm looking for the OpenGL file (dll or other) that decides to increase the color intensity by one pixel and block it once it has reached its max color.
I would like to reprogram this part to make the color black again from a white point (RGBA(255,255,255,255)!
All in opengl. I have a special effect to do in PB.

Thanks
http://HexaScrabble.com/
!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 : 5.73LTS - 32 bits
Post Reply