Flock of birds

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

Flock of birds

Post by SPH »

Hi,

Here is a code reproducing a flock of birds. 8)
What do you think ?

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Flock of birds ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; SPH 2022 - PB6.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;-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

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

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

ech_xf.f=(1920/ddw);*DesktopResolutionX()
ech_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, "Flock of birds",#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.6,0.6,1,0.8)
;ShowCursor_(0)
;- **********************************************
;- **********************************************
;- **********************************************
;- **********************************************

nb=1000

Dim couleur.f(nb)
Dim sph_x1.f(nb)
Dim sph_y1.f(nb)
Dim sph_x2.f(nb)
Dim sph_y2.f(nb)
Dim sph_xx2.f(nb)
Dim sph_yy2.f(nb)

Dim sph_rx.f(nb)

Dim sph_x3.f(nb)
Dim sph_y3.f(nb)

group.f=3
xx3.f=(100+Random(900))/100000
yy3.f=(100+Random(900))/100000

;;
For i=0 To nb
  
  sph_x1.f(i)=0.001+Random(100000)/1000000
  sph_y1.f(i)=0.001+Random(100000)/1000000
  sph_x2.f(i)=0.001+Random(100000)/1000000
  sph_y2.f(i)=0.001+Random(100000)/1000000
  
  sph_x3.f(i)=0.001+Random(100000)/1000000
  sph_y3.f(i)=0.001+Random(100000)/1000000
  
  sph_rx.f(i)=0.005+Random(100)/20000
  couleur(i)=Random(Random(255))/255
Next


;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;##  D E B U T  ##**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************

Repeat
  
  For i=0 To nb
    
    ddw21=Sin(sph_x1(i)+sph_x2(i))*ddw/5
    ddh21=Cos(sph_y1(i)+sph_y2(i))*ddh/5
    ddw22=ddw/5-ddw21
    ddh22=ddh/5-ddh21
    
    sph_xx=Cos(sph_x1(i))*ddw21
    sph_yy=Sin(sph_y1(i))*ddh21
    sph_xx+Cos(sph_x2(i)+sph_x3(i))*ddw22;+Cos(sph_x3(i))*120
    sph_yy+Cos(sph_y2(i)+sph_y3(i))*ddh22;+Sin(sph_y3(i))*120
    
    sph_xx2(i)+(sph_xx-sph_xx2(i))/(i/group)
    sph_yy2(i)+(sph_yy-sph_yy2(i))/(i/group)
    
    ;===========
    
    sph_x1(i)+sph_rx(i)
    sph_y1(i)+sph_rx(i)
    
    sph_x3(i)+xx3
    sph_y3(i)+yy3
  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
  
  
  ;##############################################
  ;##############################################
  ;############    polygones :   ################
  glBegin_(#GL_POLYGON)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  glColor4f_(1,1,1,0.05)
  glVertex2f_(0/ech_xf/dpix,200/ech_yf/dpiy)
  glVertex2f_(0/ech_xf/dpix,400/ech_yf/dpiy)
  glVertex2f_(300/ech_xf/dpix,450/ech_yf/dpiy)
  glVertex2f_(700/ech_xf/dpix,400/ech_yf/dpiy)
  glVertex2f_(720/ech_xf/dpix,350/ech_yf/dpiy)
  glVertex2f_(680/ech_xf/dpix,250/ech_yf/dpiy)
  glVertex2f_(300/ech_xf/dpix,180/ech_yf/dpiy)
  glEnd_()
  
  glBegin_(#GL_POLYGON)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  glColor4f_(1,1,1,0.05)
  glVertex2f_(350/ech_xf/dpix,300/ech_yf/dpiy)
  glVertex2f_(320/ech_xf/dpix,400/ech_yf/dpiy)
  glVertex2f_(360/ech_xf/dpix,500/ech_yf/dpiy)
  glVertex2f_(900/ech_xf/dpix,550/ech_yf/dpiy)
  glVertex2f_(1200/ech_xf/dpix,500/ech_yf/dpiy)
  glVertex2f_(1220/ech_xf/dpix,450/ech_yf/dpiy)
  glVertex2f_(1180/ech_xf/dpix,350/ech_yf/dpiy)
  glVertex2f_(800/ech_xf/dpix,280/ech_yf/dpiy)
  glEnd_()
  
  glBegin_(#GL_POLYGON)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  glColor4f_(1,1,1,0.05)
  glVertex2f_(1150/ech_xf/dpix,800/ech_yf/dpiy)
  glVertex2f_(1100/ech_xf/dpix,900/ech_yf/dpiy)
  glVertex2f_(1160/ech_xf/dpix,1000/ech_yf/dpiy)
  glVertex2f_(2000/ech_xf/dpix,1050/ech_yf/dpiy)
  glVertex2f_(2700/ech_xf/dpix,1000/ech_yf/dpiy)
  glVertex2f_(2720/ech_xf/dpix,950/ech_yf/dpiy)
  glVertex2f_(2480/ech_xf/dpix,850/ech_yf/dpiy)
  glVertex2f_(2100/ech_xf/dpix,780/ech_yf/dpiy)
  glEnd_()
  
  glBegin_(#GL_POLYGON)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  glColor4f_(1,1,1,0.04)
  glVertex2f_(800/ech_xf/dpix,500/ech_yf/dpiy)
  glVertex2f_(750/ech_xf/dpix,600/ech_yf/dpiy)
  glVertex2f_(805/ech_xf/dpix,800/ech_yf/dpiy)
  glVertex2f_(1800/ech_xf/dpix,850/ech_yf/dpiy)
  glVertex2f_(2400/ech_xf/dpix,800/ech_yf/dpiy)
  glVertex2f_(2490/ech_xf/dpix,650/ech_yf/dpiy)
  glVertex2f_(2380/ech_xf/dpix,550/ech_yf/dpiy)
  glVertex2f_(1550/ech_xf/dpix,440/ech_yf/dpiy)
  glEnd_()
  
  glBegin_(#GL_POLYGON)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  glColor4f_(1,1,1,0.05)
  glVertex2f_(1400/ech_xf/dpix,0/ech_yf/dpiy)
  glVertex2f_(1300/ech_xf/dpix,75/ech_yf/dpiy)
  glVertex2f_(1420/ech_xf/dpix,150/ech_yf/dpiy)
  glVertex2f_(1800/ech_xf/dpix,168/ech_yf/dpiy)
  glVertex2f_(2400/ech_xf/dpix,150/ech_yf/dpiy)
  glVertex2f_(2490/ech_xf/dpix,0/ech_yf/dpiy)
  glEnd_()
  
  glBegin_(#GL_POLYGON)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  glColor4f_(1,1,1,0.05)
  glVertex2f_(0/ech_xf/dpix,800/ech_yf/dpiy)
  glVertex2f_(0/ech_xf/dpix,1200/ech_yf/dpiy)
  glVertex2f_(420/ech_xf/dpix,1000/ech_yf/dpiy)
  glVertex2f_(600/ech_xf/dpix,868/ech_yf/dpiy)
  glVertex2f_(580/ech_xf/dpix,750/ech_yf/dpiy)
  glVertex2f_(50/ech_xf/dpix,800/ech_yf/dpiy)
  glEnd_()
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;  glVertex2f_(1150*ech_xf,800*ech_yf)
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  If 1=0
    glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    glColor4f_(1,0,0,0.3)
    glVertex2f_(0,0)
    glVertex2f_(ddw/dpix,ddh/dpiy)
    glEnd_()
    glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    glColor4f_(0,0,0,0.3)
    glVertex2f_(0,ddh/dpiy)
    glVertex2f_(ddw/dpix,0)
    glEnd_()
    
    ;-polyline      
    glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    glColor4f_(0,0,0,1)
    glVertex2f_((ddw/2)/dpix-5,(ddh/2)/dpiy);*ech_yf)
    glVertex2f_((ddw/2)/dpix+5,(ddh/2)/dpiy);*ech_yf)
    glEnd_()
  EndIf
  ;=====
  ;=====
  ;=====
  For i=0 To nb
    If Random(3)>0
      rand=Random(1)*2
      glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
      glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
      glColor4f_(couleur(i),couleur(i),couleur(i),0.6)
      glVertex2f_(((ddw/2)/dpix+sph_xx2(i))-rand,((ddh/2)/dpiy+sph_yy2(i)))
      glVertex2f_(((ddw/2)/dpix+sph_xx2(i))+4+rand,((ddh/2)/dpiy+sph_yy2(i)))
      glEnd_()
    Else
      rand2=Random(1)*2-1
      glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
      glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
      glColor4f_(couleur(i),couleur(i),couleur(i),0.6)
      glVertex2f_((ddw/2)/dpix+sph_xx2(i)-1,(ddh/2)/dpiy+sph_yy2(i)+rand2)
      glVertex2f_((ddw/2)/dpix+sph_xx2(i)+2,(ddh/2)/dpiy+sph_yy2(i))
      glEnd_()
      glBegin_(#GL_LINES);glBegin_(#GL_POLYGON)
      glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
      glColor4f_(couleur(i),couleur(i),couleur(i),0.6)
      glVertex2f_((ddw/2)/dpix+sph_xx2(i)+2,(ddh/2)/dpiy+sph_yy2(i))
      glVertex2f_((ddw/2)/dpix+sph_xx2(i)+5,(ddh/2)/dpiy+sph_yy2(i)+rand2)
      glEnd_()
    EndIf
    
    
  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
Last edited by SPH on Sun Jul 31, 2022 9:05 pm, edited 8 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
Bitblazer
Enthusiast
Enthusiast
Posts: 762
Joined: Mon Apr 10, 2017 6:17 pm
Location: Germany
Contact:

Re: Flock of birds

Post by Bitblazer »

nice :D
#NULL
Addict
Addict
Posts: 1499
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: Flock of birds

Post by #NULL »

cool, I like it. :)
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Flock of birds

Post by Paul »

Just a note...
make sure "Enable DPI aware executable" isn't checked in compiler settings or the "flock of birds" is off the screen ;)
Image Image
User avatar
mk-soft
Always Here
Always Here
Posts: 6246
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Flock of birds

Post by mk-soft »

Runs on macOS (if remove all window api) :wink:
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Flock of birds

Post by netmaestro »

Looks very nice!
But if they're trying to migrate somewhere they'll never get there, swooping around aimlessly like that.
BERESHEIT
User avatar
SPH
Enthusiast
Enthusiast
Posts: 572
Joined: Tue Jan 04, 2011 6:21 pm

Re: Flock of birds

Post by SPH »

Thank you all, that encourages me. 😘

Tell me Paul, your DPI is 125%? 150% +?
Thank you for telling me. 👍

!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
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Flock of birds

Post by Paul »

SPH wrote: Sat Jul 16, 2022 10:09 pm Thank you all, that encourages me. 😘

Tell me Paul, your DPI is 125%? 150% +?
Thank you for telling me. 👍
175%
Image Image
User avatar
Mijikai
Addict
Addict
Posts: 1520
Joined: Sun Sep 11, 2016 2:17 pm

Re: Flock of birds

Post by Mijikai »

Nice 8)
User avatar
NicTheQuick
Addict
Addict
Posts: 1519
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: Flock of birds

Post by NicTheQuick »

Code: Select all

[11:16:25] [COMPILER] Zeile 72: Beep_() is not a function, array, list, map or macro.
[11:17:02] [COMPILER] Zeile 97: ShowCursor_() is not a function, array, list, map or macro.
When I remove all these lines it also works on Linux.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
User avatar
idle
Always Here
Always Here
Posts: 5901
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Flock of birds

Post by idle »

very nice SPH
User avatar
SPH
Enthusiast
Enthusiast
Posts: 572
Joined: Tue Jan 04, 2011 6:21 pm

Re: Flock of birds

Post by SPH »

NicTheQuick wrote: Mon Jul 18, 2022 10:18 am

Code: Select all

[11:16:25] [COMPILER] Zeile 72: Beep_() is not a function, array, list, map or macro.
[11:17:02] [COMPILER] Zeile 97: ShowCursor_() is not a function, array, list, map or macro.
When I remove all these lines it also works on Linux.
Ok, I would remove the "Beep_()". But on the other hand, do you have a common instruction for PCs and MACs to replace "ShowCursor_()"?
😶

!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
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: Flock of birds

Post by Paul »

SPH wrote: Tue Jul 19, 2022 8:57 pm Ok, I would remove the "Beep_()". But on the other hand, do you have a common instruction for PCs and MACs to replace "ShowCursor_()"?
😶
https://www.purebasic.fr/english/viewto ... 26#p525626
Image Image
User avatar
SPH
Enthusiast
Enthusiast
Posts: 572
Joined: Tue Jan 04, 2011 6:21 pm

Re: Flock of birds

Post by SPH »

Hi,
I modified my code. It is more beautiful and shorter.
DPI finally works!
I await your feedback...

Ha yes, do you think there are situations where the ExamineDesktops() does not work?
In this code:

Code: Select all

If Examine Desktops()
   ddw=DesktopWidth(0)
   ddh=DesktopHeight(0)
Else
   ddw=1024
   ddh=768
EndIf
What could I put in place of 1024 / 768?
Is there an instruction that finds the highest resolution?

Thx

!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
blueb
Addict
Addict
Posts: 1116
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Flock of birds

Post by blueb »

SPH wrote: Thu Jul 28, 2022 3:41 pm Hi,
...
What could I put in place of 1024 / 768?
Is there an instruction that finds the highest resolution?

Thx
Perhaps this might give you some help...

Code: Select all

InitSprite()

If ExamineScreenModes()
     While NextScreenMode()
          Debug Str(ScreenModeWidth())+"x"+Str(ScreenModeHeight())+"x"+Str(ScreenModeDepth())+"@"+Str(ScreenModeRefreshRate())+"Hz"
     Wend
EndIf
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Post Reply