Page 1 of 1

Polygon Engine 2023

Posted: Wed Nov 22, 2023 2:45 pm
by SPH
Hi,
Here is an example of polygons boosted by my polygon engine. The rotation was the hardest part. I was helped by Nemerod.
Enjoy!

ps: this code does not show anim of several images (I will do it later) but the zooms and rotations :o :wink:

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code : Lecteur de polygones "OPTIMIZED" (datas)   ;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PB6.01 - SPH(2023) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Falsam m'a fait la structure du code OpenGL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Nemerod a codé le moteur "rotation" des polygones ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global chemin$,sph_cmb,Dim sph_xx(1),Dim sph_yy(1),attente,attente_ok
Global numero,echelle_xf.f,echelle_yf.f,Resx,Resy,categorie$

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

timer=ElapsedMilliseconds()

glClearColor_(0,0,0, 1.0)

chemin$="f:\Polygons_OPTIMIZED\"
chemin$=""
attente=500
attente_ok=0
numero=1


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

Procedure load_poly(categorie$,pol) ; ne jamais appeller un polygon "0.pol"
  If attente_ok=0 Or attente_ok<>pol
    attente_ok=pol
    Dim sph_xx(574)
      Dim sph_yy(574)
      
      For i=1 To 574/2
        Read.w sph_xx(i-1)
        Read.w sph_yy(i-1)
      Next
    EndIf

EndProcedure

Procedure affiche_poly(xxx,yyy,angle.f,dkx,dky,zoom.f,alpha.f)
  sph_cmb=sph_yy(0)
  sph_la=0
  Repeat
    glBegin_(#GL_POLYGON)
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    glColor4f_(sph_xx(sph_la+1)/255,sph_yy(sph_la+1)/255,sph_xx(sph_la+2)/255,(sph_yy(sph_la+2)/255)*alpha)
    ;;;;;;
    For i=3 To sph_cmb-1
      sph_xxx.f=(sph_xx(sph_la+i)/echelle_xf)-xxx
      sph_yyy.f=(sph_yy(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=sph_yy(sph_la+i)
    sph_la+i
  Until sph_yy(sph_la)=0
  ;;;;;;;;;;;;;;;
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

;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Repeat
  
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  gestion()
  ;##############################################
  ;load_poly(caregorie$,numero) ; categorie$=par exemple "Generique"+str(numero) appelle le fichier "Generique1.pol"  
  ;affiche_poly(axe de rotation X,axe de rotation Y,angle de rotation(.f),decallage X,decallage Y,Zoom(.f),alpha)
  ;mix=milieu de l'ecran (en X)
  ;miy=milieu de l'ecran (en Y)
  ;##############################################
  load_poly("monstre",1)
  affiche_poly(mix,miy/2,Cos(cos_f.f+0.8)*2,150,200,1+Sin(sin_f.f+0.7)*2,0.2)
  affiche_poly(mix/2,miy,Cos(cos_f.f+0.5)*2,-180,-100,1+Sin(sin_f.f+0.4)*2,0.1)
  affiche_poly(mix,miy,Cos(cos_f.f)*2,0,0,0.5+Sin(sin_f.f)*2,0.5+1)
  affiche_poly(200,miy,Cos(-cos_f.f-sin_f)*1.3,0,0,0.35+Sin(sin_f.f)*1.8,0.5+1)
  affiche_poly(1000,miy,Cos(-cos_f.f+sin_f)*2,0,0,0.2+Cos(sin_f.f)*1.2,0.5+1)
  cos_f.f+0.005
  sin_f.f+0.008
  
  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
  
;   If ElapsedMilliseconds()-timer>2000
;     timer=ElapsedMilliseconds()
;     ;numero+1
;   EndIf
  
ForEver

End


DataSection
Data.w 28,7,37,39,60,255,1919,0,1919,1079,0,1079,0,0,0,20,51,71,115,255
Data.w 1908,589,1919,588,1919,813,1831,815,1772,833,1717,899,1528,946,1519,966,333,961,269,883
Data.w 259,820,0,823,0,115,74,112,139,42,246,0,1869,0,0,10,51,71,115,255
Data.w 0,801,0,963,67,964,213,886,211,847,267,814,157,775,0,19,61,82,141,255
Data.w 236,0,155,544,162,598,300,818,343,825,348,643,380,646,713,881,1185,857,1267,816
Data.w 1424,846,1577,814,1689,594,1695,540,1648,320,1629,0,0,9,61,82,141,255,700,861
Data.w 723,900,485,900,427,844,398,838,381,672,0,7,61,82,141,255,616,816,381,674
Data.w 379,618,611,775,0,22,64,110,239,255,380,0,256,255,235,333,257,496,363,646
Data.w 380,648,412,705,606,750,630,710,646,711,695,734,1155,749,1211,720,1234,697,1384,661
Data.w 1512,514,1509,354,1391,199,1344,0,0,6,64,110,239,255,1200,734,1179,768,1226,732
Data.w 0,6,64,110,239,255,1519,641,1569,429,1590,426,0,7,64,110,239,255,1590,428
Data.w 1542,271,1524,283,1567,437,0,7,64,110,239,255,1352,2,1407,123,1420,127,1362,0
Data.w 0,7,64,110,239,255,1408,123,1523,285,1542,274,1422,129,0,14,0,138,255,255
Data.w 388,0,307,205,290,355,342,524,556,625,1148,689,1352,602,1517,498,1504,342,1389,195
Data.w 1345,0,0,17,0,0,4,255,528,958,448,1010,689,1010,643,706,600,607,648,161
Data.w 551,233,506,354,436,415,420,496,390,516,382,552,406,618,412,700,0,7,0,0
Data.w 4,255,0,1010,0,1079,1919,1071,1919,1009,0,10,0,0,4,255,680,980,725,951
Data.w 936,887,913,956,924,989,927,1013,678,1031,0,18,0,0,4,255,932,889,1256,590
Data.w 1425,402,1358,342,1305,237,1226,160,1169,41,1038,12,806,11,719,42,644,171,599,556
Data.w 632,592,745,898,722,962,0,6,0,0,4,255,642,577,588,621,586,514,0,14
Data.w 0,0,4,255,949,945,911,812,1256,571,1257,590,1154,742,1123,893,1123,948,1174,966
Data.w 1189,1022,935,1033,931,964,0,17,0,0,4,255,1217,975,1161,1002,1178,1069,1412,1038
Data.w 1405,1001,1368,976,1444,765,1466,602,1494,533,1483,491,1454,477,1423,400,1279,622,1229,768
Data.w 0,7,0,0,4,255,1280,625,1249,577,1421,400,1425,407,0,7,0,0,4,255
Data.w 109,1065,1919,1042,1919,1079,15,1079,0,7,188,148,130,255,943,514,937,579,945,579
Data.w 959,512,0,7,188,148,130,255,907,664,898,705,913,705,914,663,0,7,188,148
Data.w 130,255,847,688,830,688,837,641,844,643,0,7,188,148,130,255,817,503,831,539
Data.w 837,538,833,502,0,7,108,25,0,255,789,437,795,453,810,456,806,437,0,7
Data.w 108,25,0,255,966,423,961,439,979,440,985,425,0,0
EndDataSection

Re: Polygon Engine 2023

Posted: Wed Nov 22, 2023 5:01 pm
by juergenkulow
In order to run the program under Linux ShowCursor_ must be replaced by HideCursor. My thanks go to Shardik. Re: Show / hide cursor

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Linux
  #GDK_BLANK_CURSOR = -2
 
  ImportC ""
    gtk_widget_get_window(*Widget.GtkWidget)
  EndImport
CompilerEndIf
 
Procedure HideCursor(HideCursor.I = #True)
  Protected Cursor.I
 
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_Linux
      If HideCursor
        Cursor = gdk_cursor_new_(#GDK_BLANK_CURSOR)
      Else
        Cursor = 0
      EndIf
     
      gdk_window_set_cursor_(gtk_widget_get_window(WindowID(0)), Cursor)
    CompilerCase #PB_OS_MacOS
      If HideCursor
        CocoaMessage(0, 0, "NSCursor hide")
      Else
        CocoaMessage(0, 0, "NSCursor unhide")
      EndIf
    CompilerCase #PB_OS_Windows
      If HideCursor
        ShowCursor_(#False)
      Else
        ShowCursor_(#True)
      EndIf
  CompilerEndSelect
EndProcedure

Re: Polygon Engine 2023

Posted: Sat Dec 02, 2023 2:47 pm
by SPH
Here's another example of displaying polygons. It's very quick to display. Maybe you underestimate the awesomeness of this thing...

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code : Lecteur de polygones "OPTIMIZED" (datas)   ;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PB6.1 - SPH(2023) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global chemin$,sph_cmb,Dim sph_xx(1),Dim sph_yy(1),attente,attente_ok
Global numero,echelle_xf.f,echelle_yf.f,Resx,Resy,categorie$
Global ultimated_NANO_ALPHA.q



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

; Debug "Send me that :"
; Debug Str(ddw)+" / "+Str(ddh)
; Debug Str(echelle_xf)+" / "+Str(echelle_yf)
; Debug "==="
;**********************************************

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

timer=ElapsedMilliseconds()

glClearColor_(0,0,0, 1.0)

chemin$="f:\Polygons_OPTIMIZED\"
;chemin$=""
attente=500
attente_ok=0
numero=1


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

Procedure load_poly(categorie$,pol) ; ne jamais appeller un polygon "0.pol"
  If attente_ok=0 Or attente_ok<>pol
    attente_ok=pol
      Dim sph_xx(2326)
      Dim sph_yy(2326)
      For i=1 To 1163
        Read.w sph_xx(i-1)
        Read.w sph_yy(i-1)
      Next
  EndIf
EndProcedure

Procedure affiche_poly(xxx,yyy,angle.f,dkx,dky,zoom.f,alpha.f)
  sph_cmb=sph_yy(0)
  sph_la=0
  Repeat
    glBegin_(#GL_POLYGON)
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    glColor4f_(sph_xx(sph_la+1)/255,sph_yy(sph_la+1)/255,sph_xx(sph_la+2)/255,(sph_yy(sph_la+2)/255)*alpha)
    ;;;;;;
    For i=3 To sph_cmb-1
      sph_xxx.f=(sph_xx(sph_la+i)/echelle_xf)-xxx
      sph_yyy.f=(sph_yy(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=sph_yy(sph_la+i)
    sph_la+i
  Until sph_yy(sph_la)=0
  ;;;;;;;;;;;;;;;
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

;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Repeat
  
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  gestion()
  ;##############################################
  ;load_poly(caregorie$,numero) ; categorie$=par exemple "Generique"+str(numero) appelle le fichier "Generique1.pol"  
  ;affiche_poly(axe de rotation X,axe de rotation Y,angle de rotation(.f),decallage X,decallage Y,Zoom(.f),alpha)
  ;mix=milieu de l'ecran (en X)
  ;miy=milieu de l'ecran (en Y)
  ;##############################################
  load_poly("larson_",1)
  ;centre
  affiche_poly(mix,miy,0,0,0,1,1)
  affiche_poly(mix,miy,Cos(cos_f.f)*2,0,0,0.5+Sin(sin_f.f),0.8)
  ;gauche
  affiche_poly(mix,miy,Sin(cos_f.f),120-mix,100-miy,Sin(cos_f.f)/3-0.32,1)
  affiche_poly(mix,miy,Cos(cos_f.f),120-mix,-100+miy,Sin(cos_f.f)/3-0.4,1)
  ;droite
  affiche_poly(mix,miy,Sin(cos_f.f),-120+mix,100-miy,Sin(cos_f.f)/3-0.35,1)
  affiche_poly(mix,miy,Cos(cos_f.f),-120+mix,-100+miy,0.445+Sin(cos_f.f)/3-0.38,1)

  ;gauche centre
  affiche_poly(mix,miy,Sin(cos_f.f),360-mix,300-miy,Cos(sin_f.f)/4+0.44,0.6)
  affiche_poly(mix,miy,Cos(cos_f.f),360-mix,-300+miy,Cos(sin_f.f)/4+0.44,0.6)
  ;droite centre
  affiche_poly(mix,miy,Sin(sin_f.f),-360+mix,300-miy,Cos(cos_f.f)/4+0.44,0.6)
  affiche_poly(mix,miy,Cos(cos_f.f),-360+mix,-300+miy,Sin(cos_f.f)/4+0.44,0.6)
  
  ;gauche centre2
  affiche_poly(mix,miy,Sin(cos_f.f),600-mix,500-miy,Cos(cos_f.f)/4+0.44,0.1)
  affiche_poly(mix,miy,Cos(cos_f.f),600-mix,-500+miy,Cos(cos_f.f)/4+0.44,0.1)
  ;droite centre2
  affiche_poly(mix,miy,Sin(cos_f.f),-600+mix,500-miy,Cos(sin_f.f)/4+0.44,0.1)
  affiche_poly(mix,miy,Cos(sin_f.f),-600+mix,-500+miy,Sin(cos_f.f)/4+0.44,0.1)
  
  cos_f.f+0.007
  sin_f.f+0.009
  
  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
  
;   If ElapsedMilliseconds()-timer>2000
;     timer=ElapsedMilliseconds()
;     ;numero+1
;   EndIf
  
ForEver

End

DataSection
  Data.w 107,9,85,87,94,255,162,1079,232,1028,360,1012,510,1007,427,1055,399,1079,0,7,85,87,94,255,1530,1051,1563,1062,1589,1079,1544,1079,0,13,106,110,116,255,556,1031,574,1079,398,1079,433,1048,511,1003,626,958,703,915,732,922,735,981,570,1077,0,8,106,110,116,255,1520,1064,1508,1042,1532,1052,1547,1079,1502,1079,0,12,102,105,107,255,1401,1013,1231,1079,1305,1004,1409,913,1432,962,1506,1038,1520,1064,1505,1079,1227,1079,0,10,102,105,107,255,1408,911,1401,888,1372,878,1376,906,1384,925,1382,950,1415,932,0,8,122,93,55,255,570,1079,619,1042,731,983,750,1041,756,1079,0,16,122,93,55,255,941,1079,755,1079,730,983,721,919,788,927,856,912,983,847,1106,751,1135,715,1123,760,1105,832,1094,877,1047,953,0,19,151,127,93,255,1229,1079,1366,956,1380,921,1373,888,1368,772,1313,441,1308,436,1287,491,1257,518,1242,519,1185,555,1142,681,1108,818,1086,889,1029,975,938,1079,0,12,151,127,93,255,1196,466,1204,420,1239,424,1248,450,1261,462,1258,485,1245,523,1205,561,1178,559,0,15,122,93,55,255,1285,380,1212,355,1218,424,1241,425,1243,443,1260,460,1254,503,1252,515,1271,508,1283,493,1297,450,1312,397,0,24,122,93,55,255,618,600,667,484,692,372,693,304,646,75,531,71,512,280,544,381,551,543,585,669,645,845,668,900,699,916,730,919,716,850,740,812,764,789,764,780,777,705,764,557,629,523,0,35,151,127,93,255,878,718,768,708,708,713,697,711,696,729,698,757,704,771,727,782,765,783,728,825,716,851,720,898,728,921,764,928,813,925,874,911,951,868,1069,786,1124,735,1142,688,1161,622,1195,0,665,0,691,342,671,449,757,599,747,624,695,636,693,668,707,678,774,692,778,712,0,7,151,127,93,255,740,556,643,533,665,483,679,428,0,10,151,127,93,255,683,521,647,527,629,570,648,591,704,587,780,597,776,519,0,12,122,93,55,255,880,261,1041,263,929,300,857,396,845,400,800,370,785,338,781,312,787,288,0,15,203,191,171,255,919,349,978,341,1001,359,997,379,979,391,935,402,889,403,862,390,845,377,841,360,871,326,981,341,0,12,203,191,171,255,685,358,686,379,673,392,644,399,611,398,584,382,576,355,594,335,665,341,0,13,114,96,68,255,921,328,890,331,884,353,891,378,907,393,925,395,944,390,960,372,961,352,954,333,0,11,114,96,68,255,619,334,612,346,613,367,626,383,650,388,667,378,673,355,664,340,0,9,114,96,68,255,867,335,845,359,833,359,865,323,949,330,939,333,0,9,114,96,68,255,940,330,982,337,994,350,965,338,866,332,872,325,0,10,114,96,68,255,662,342,681,358,683,355,666,338,592,331,584,335,593,334,0,7,114,96,68,255,598,336,581,357,575,357,591,333,0,9,114,96,68,255,623,316,595,321,595,325,625,319,652,326
  Data.w 652,322,0,11,114,96,68,255,877,310,939,314,976,324,913,316,864,316,846,324,845,321,862,311,0,10,200,185,155,255,934,335,927,341,929,350,934,358,946,357,954,348,954,338,0,10,200,185,155,255,664,343,668,349,664,357,654,357,645,352,644,346,649,339,0,8,114,96,68,255,796,351,797,367,802,375,800,357,800,350,0,9,114,96,68,255,729,781,701,769,699,769,713,780,745,786,763,782,0,7,114,96,68,255,777,707,837,721,839,725,781,713,0,7,114,96,68,255,782,714,710,715,713,713,776,707,0,8,114,96,68,255,709,715,688,707,685,702,709,713,715,713,0,8,114,96,68,255,687,705,671,708,674,704,688,700,693,706,0,9,114,96,68,255,707,682,690,669,692,666,709,678,723,672,722,678,0,11,114,96,68,255,735,604,749,607,746,612,734,607,720,612,712,622,711,615,726,604,0,9,114,96,68,255,676,607,696,631,691,632,673,610,648,589,658,591,0,7,114,96,68,255,734,585,651,589,660,594,734,589,0,7,114,96,68,255,733,587,757,595,757,590,733,585,0,9,114,96,68,255,650,588,631,571,630,575,645,590,658,598,658,593,0,10,114,96,68,255,672,461,657,511,631,562,631,561,663,481,686,384,690,385,0,8,114,96,68,255,1308,437,1287,490,1270,509,1293,470,1302,428,0,8,114,96,68,255,1268,508,1234,522,1215,542,1250,517,1268,515,0,8,114,96,68,255,1210,558,1218,544,1231,530,1220,531,1209,552,0,10,114,96,68,255,1113,1040,1138,990,1137,980,1112,1037,1079,1079,1087,1079,1117,1036,0,9,114,96,68,255,1145,987,1163,913,1163,892,1167,892,1155,966,1149,994,0,10,114,96,68,255,1175,894,1179,854,1179,842,1184,840,1178,898,1165,948,1163,937,0,7,114,96,68,255,1145,677,1149,677,1126,739,1120,739,0,7,114,96,68,255,1125,731,1080,778,1104,760,1128,737,0,8,114,96,68,255,1094,765,1008,833,1003,833,1060,798,1101,763,0,7,114,96,68,255,1007,831,933,878,936,880,1005,837,0,8,114,96,68,255,929,881,877,907,877,910,904,902,939,882,0,7,114,96,68,255,883,905,812,924,812,927,861,917,0,7,114,96,68,255,818,923,755,924,755,928,793
  Data.w 928,0,7,114,96,68,255,756,925,714,918,715,923,766,931,0,9,114,96,68,255,1243,508,1245,520,1251,518,1250,506,1263,485,1263,475,0,7,114,96,68,255,1262,481,1261,462,1254,444,1258,479,0,7,114,96,68,255,1256,451,1241,431,1236,431,1248,450,0,7,114,96,68,255,1239,433,1242,415,1239,413,1235,433,0,10,114,96,68,255,1241,416,1254,407,1267,393,1267,387,1248,407,1238,412,1234,427,0,8,114,96,68,255,1272,494,1276,468,1271,454,1276,481,1270,495,0,11,114,96,68,255,1262,452,1273,463,1272,467,1277,463,1268,450,1251,448,1256,456,1269,456,0,11,114,96,68,255,1197,611,1190,602,1188,591,1194,590,1202,606,1221,610,1222,613,1205,615,0,7,114,96,68,255,683,356,678,336,674,336,676,354,0,9,114,96,68,255,720,922,727,983,757,1079,758,1079,748,1030,732,985,0,7,114,96,68,255,746,1049,740,1079,757,1079,748,1038,0,19,48,43,22,255,1367,815,1371,861,1382,852,1402,828,1434,746,1426,687,1419,673,1448,561,1436,538,1516,212,1508,150,1369,86,1315,445,1308,505,1303,520,1243,590,0,10,48,43,22,255,1420,798,1415,723,1435,729,1426,797,1416,828,1412,828,1420,789,0,11,48,43,22,255,1451,680,1464,723,1468,755,1464,756,1454,706,1440,686,1405,668,1395,620,0,14,48,43,22,255,1445,554,1460,591,1456,637,1451,657,1452,626,1444,646,1442,649,1435,611,1432,643,1424,646,1411,508,0,10,48,43,22,255,1460,525,1483,505,1488,495,1479,501,1455,517,1413,525,1423,542,0,11,48,43,22,255,1438,512,1458,494,1495,427,1515,374,1522,327,1523,256,1515,198,1382,472,0,10,48,43,22,255,1323,780,1332,801,1343,820,1343,815,1335,780,1348,763,1287,629,0,10,48,43,22,255,1293,777,1324,733,1309,640,1298,742,1285,775,1269,798,1272,799,0,14,48,43,22,255,1285,744,1294,728,1316,701,1289,565,1273,591,1283,724,1272,759,1265,769,1268,771,1283,751,1301,721,0,8,48,43,22,255,1284,693,1269,679,1237,593,1255,579,1305,581,0,16,48,43,22,255,1243,671,1263,690,1272,693,1272,688,1253,673,1253,660,1266,655,1245,586,1219,612,1220,626,1225,646,1246,677,1263,687,0,21,48,43,22,255,1365,174,1320,446,1304,435,1297,421,1294,408,1281,401,1265,388,1249,371,1159,349,1157,322,1130,287,1116,240,1120,221,1077,167,1058,123,1042,29,1059,0,1395,0,0,13,48,43,22,255,1029,86,1033,166,1038,191,1041,191,1037,146,1043,106,1054,70,1053,12,1040,29,1032,57,0,8,48,43,22,255,899,106,928,64,942,28,944,1,933,24,0,8,48,43,22,255,944,0,937,38,920,55,923,10,916,0,0,20,48,43,22,255,916,0,902,47,883,93,856,136,827,166,799,186,775,208,777,203,822,135,836,81,798,136,639,235,631,202,619,177,632,149,645,92,491,0,0,12,48,43,22,255,655,269,679,310,699,341,709,349,704
  Data.w 338,694,300,699,222,706,205,637,231,0,8,48,43,22,255,792,138,754,173,696,217,642,235,636,208,0,15,48,43,22,255,598,106,610,158,625,189,624,152,629,111,654,80,652,41,242,0,574,101,580,141,597,182,605,193,0,14,48,43,22,255,415,0,572,90,540,155,513,260,513,439,473,396,454,370,421,344,393,289,256,101,283,0,0,12,48,43,22,255,359,303,391,356,421,397,424,395,402,360,393,314,404,267,338,173,342,253,0,16,48,43,22,255,304,282,316,320,336,357,344,370,344,363,329,321,329,278,345,217,259,87,252,141,260,194,265,218,288,262,0,10,48,43,22,255,508,279,538,364,544,397,547,465,524,438,517,446,480,399,0,14,48,43,22,255,225,60,242,21,248,0,291,0,269,61,254,68,237,104,224,165,216,180,213,155,213,113,0,24,48,43,22,255,595,263,585,241,569,237,544,244,544,249,534,252,529,269,533,284,544,283,548,287,578,277,605,283,649,308,669,316,679,326,664,307,659,291,657,276,622,262,597,244,579,240,0,22,48,43,22,255,970,250,975,234,1019,233,1065,247,1087,273,1099,302,1085,295,1085,302,1045,286,992,279,939,281,869,295,814,311,781,307,768,302,757,281,826,272,828,267,979,233,0,16,48,43,22,255,1213,343,1212,434,1212,495,1191,566,1184,566,1162,630,1149,656,1147,655,1160,590,1154,587,1154,562,1166,445,1158,296,0,13,40,43,60,255,1512,123,1508,175,1498,188,1468,192,1430,180,1403,184,1392,174,1363,47,1322,0,1472,0,0,11,40,43,60,255,1378,137,1374,158,1366,178,1353,179,1348,140,1338,71,1319,0,1411,0,0,9,40,43,60,255,1303,0,1303,29,1292,53,1284,56,1277,43,1261,0,0,9,40,43,60,255,1256,0,1257,36,1251,48,1237,52,1232,35,1231,0,0,12,40,43,60,255,830,0,807,55,784,97,753,123,727,133,725,126,730,109,779,45,801,0,0,12,40,43,60,255,705,76,682,118,678,147,689,146,700,126,728,79,761,37,760,29,737,34,0,11,40,43,60,255,688,0,731,0,706,38,682,89,665,111,659,105,659,92,687,0,0,10,40,43,60,255,666,3,658,30,646,41,636,33,638,11,640,0,663,0,0,11,45,50,68,255,1520,0,1522,71,1513,144,1501,154,1417,124,1384,85,1384,46,1393,0,0,7,41,45,48,255,557,1079,647,997,645,1003,566,1079,0,9,41,45,48,255,1516,1060,1506,1038,1511,1039,1524,1063,1511,1079,1507,1079,0,7,41,45,48,255,1547,1079,1531,1050,1527,1049,1541,1079,0,10,41,45,48,255,1389,913,1389,897,1383,896,1387,916,1381,934,1385,938,1392,913,0,9,41,45,48,255,431,1050,512,1000,507,1000,433,1043,396,1079,401,1079,0,0
  
EndDataSection

  

Re: Polygon Engine 2023

Posted: Sat Dec 02, 2023 3:27 pm
by pjay
Cool stuff 8)

Re: Polygon Engine 2023

Posted: Tue Jan 09, 2024 8:52 am
by IceSoft
@SPH:
Have you an editor generating the datas?

Re: Polygon Engine 2023

Posted: Wed Jan 10, 2024 7:50 am
by SPH
IceSoft wrote: Tue Jan 09, 2024 8:52 am @SPH:
Have you an editor generating the datas?
Yes, I made myself a polygon editor. For this anime, I took screenshots of the original anime. Then, I reconstruct it point by point.

Re: Polygon Engine 2023

Posted: Wed Jan 10, 2024 2:25 pm
by IceSoft
SPH wrote: Wed Jan 10, 2024 7:50 am Yes, I made myself a polygon editor. For this anime, I took screenshots of the original anime. Then, I reconstruct it point by point.
There are some polygons with overlapped points (i belive).
+> For me it looks like a "bug"

Re: Polygon Engine 2023

Posted: Wed Jan 10, 2024 7:45 pm
by SPH
IceSoft wrote: Wed Jan 10, 2024 2:25 pm There are some polygons with overlapped points (i belive).
Yes, it's normal. I build an image with several polygons :D

Re: Polygon Engine 2023

Posted: Thu Jan 11, 2024 8:11 am
by IceSoft
SPH wrote: Wed Jan 10, 2024 7:45 pm
IceSoft wrote: Wed Jan 10, 2024 2:25 pm There are some polygons with overlapped points (i belive).
Yes, it's normal. I build an image with several polygons :D
Of course. Thats not what I mean.
I mean some Polygons having crossing lines.