Polygons Editor (99.86%)

Programmation avancée de jeux en PureBasic
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Polygons Editor (99.86%)

Message par SPH »

Mon editeur de polygones (99.85% est fait) : :idea:

Cet éditeur demande des réglages préliminaires : renseigner les lignes 31 et 32
Ensuite, ca roule

Code : Tout sélectionner

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  SPH(2022) ;; version 0.99.86 ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;"p" = piquer une couleur SUR L'IMAGE de fond
;"h" = activer/desactiver le dernier "triangle"
;"+", "-", "*", "/" = change l'alpha
;"1" a "9" = regler les couleurs R V B
;"m" = model on/off
;"k" = kill le dernier polygone
;"i" = matter l'image de fond
;"c" = continuer sur un model ON/OFF
;"z" = zoom ON/OFF
;"a" = tout mettre en Alpha (pour mieux matter l'image du dessous) on/off
;"F1" = couleur precedente en memoire
;"F2" = couleur suivante en memoire
;"F3" =model precedent
;"F4" = model suivant
;"F5" = sauve les polygones
;"Tab" = editer l'un des polygones en le selectionnant avec F9 et F10
;"F9" = polygone precedent
;"F10" = polygone suivant
;"F8" = Undo (pour l'effacement d'un Tab)
;"F11" = diminuer le palier de decrementation/incrementation
;"F12" = augmenter le palier de decrementation/incrementation
;EnableExplicit

UsePNGImageDecoder()
UseJPEGImageDecoder()

chemin$="f:\Nuages_poly\"
image$="f:\lion_anotherworld.bmp"

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

ExamineDesktops()
ddw=DesktopWidth(0)
ddh=DesktopHeight(0)

If ddw<>1920 Or ddh<>1080
  MessageRequester("Erreur","Il faut que le bureau soit en 1920/1080")
EndIf

;-STRUCTURES
Structure Integer2
  X.i
  Y.i
EndStructure
Global.Integer2 WindowDim
WindowDim\X = ddw
WindowDim\Y = ddh


;-GLOBALS
Global.i Image1, Image2
Global.i Texture1, Texture2

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

;Load images.
Image1 = LoadImage(#PB_Any,image$)

Texture1 = SetupGLTexture(Image1)

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

AddKeyboardShortcut(0,  #PB_Shortcut_Escape, 666) ; quitter
AddKeyboardShortcut(0,  #PB_Shortcut_A, 1)        ; activer/desactiver alpha pour le travail fait
AddKeyboardShortcut(0,  #PB_Shortcut_H, 8)        ; hide/show
AddKeyboardShortcut(0,  #PB_Shortcut_K, 11)       ; eliminer le dernier polygone
AddKeyboardShortcut(0,  #PB_Shortcut_M, 13)       ; model on/off
AddKeyboardShortcut(0,  #PB_Shortcut_P, 16)       ; peek une couleur
AddKeyboardShortcut(0,  #PB_Shortcut_Z, 26)       ; peek une couleur
AddKeyboardShortcut(0,  #PB_Shortcut_F1, 98)      ; choisir une couleur deja referencée (-1)
AddKeyboardShortcut(0,  #PB_Shortcut_F2, 99)      ; choisir une couleur deja referencée (+1)
AddKeyboardShortcut(0,  #PB_Shortcut_F3, 96)      ; load le fichier precedent pour le mettre en model
AddKeyboardShortcut(0,  #PB_Shortcut_F4, 97)      ; load le fichier suivant pour le mettre en model
AddKeyboardShortcut(0,  #PB_Shortcut_F5, 95)      ; sauver la scene de polygones
AddKeyboardShortcut(0,  #PB_Shortcut_I, 9)        ; ne matter que l'image de fond
AddKeyboardShortcut(0,  #PB_Shortcut_C, 3)        ; continuer un polygon loadé

AddKeyboardShortcut(0,  #PB_Shortcut_Tab, 130)        ; selection polygone
AddKeyboardShortcut(0,  #PB_Shortcut_F9, 131)         ; polygone precedent
AddKeyboardShortcut(0,  #PB_Shortcut_F10, 132)        ; polygone suivant
AddKeyboardShortcut(0,  #PB_Shortcut_F8, 129)      ; undo
AddKeyboardShortcut(0,  #PB_Shortcut_F11, 140)      ; palier-1
AddKeyboardShortcut(0,  #PB_Shortcut_F12, 141)      ; palier+1

AddKeyboardShortcut(0,  #PB_Shortcut_Add, 100) ; alpha+0.01
AddKeyboardShortcut(0,  #PB_Shortcut_Subtract, 101) ; alpha-0.01
AddKeyboardShortcut(0,  #PB_Shortcut_Multiply, 102) ; alpha=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_Divide, 103)   ; NO alpha

AddKeyboardShortcut(0,  #PB_Shortcut_Pad1, 110) ; rouge-0.02
AddKeyboardShortcut(0,  #PB_Shortcut_Pad2, 111) ; rouge+0.02
AddKeyboardShortcut(0,  #PB_Shortcut_Pad4, 112) ; vert-0.02
AddKeyboardShortcut(0,  #PB_Shortcut_Pad5, 113) ; vert+0.02
AddKeyboardShortcut(0,  #PB_Shortcut_Pad7, 114) ; bleu-0.02
AddKeyboardShortcut(0,  #PB_Shortcut_Pad8, 115) ; bleu+0.02

AddKeyboardShortcut(0,  #PB_Shortcut_Pad3, 116) ; rouge=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_Pad6, 117) ; vert=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_Pad9, 118) ; bleu=0.5



hide=0
rouge.f=0.5
vert.f=0.5
bleu.f=0.5
alpha.f=0.5
no_alpha=0
nb=0
travail=0;1
model=1
Continu2=1
polygon=0
polygon_on=0
palier=5
;;;;;;;;;;;;;;;;;;;;;;;
ref_colors=0
ref=0
ref_ici=0
Dim ref_r.f(1000)
Dim ref_v.f(1000)
Dim ref_b.f(1000)
Dim ref_a.f(1000)
ref_r.f(0)=rouge
ref_v.f(0)=vert
ref_b.f(0)=bleu
ref_a.f(0)=alpha


Dim poly_x.w(1000)
Dim poly_y.w(1000)

Dim poly_x2.w(100000)
Dim poly_y2.w(100000)

      Dim poly_x2_1.w(100000)
      Dim poly_y2_1.w(100000)

Dim poly_mx2.w(100000)
Dim poly_my2.w(100000)

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

dernier=1
i=1
While FileSize(chemin$+Str(i)+".pol")<>-1
  i+1
Wend
dernier_ici=i-1
dernier_fichier=i-1


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

glOrtho_(0,ddw,ddh,0,-1,1)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(0)

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

Procedure.i OpenGLDrawText(Gadget.i, x.f, y.f, Text$, Textcolor=#White)
 
  Protected Image.i, TextWidth.i, TextHeight.i, Result.i, tmpy.f
 
 
  Image = CreateImage(#PB_Any, 1, 1)
  If Image
    If StartDrawing(ImageOutput(Image))
      TextWidth = TextWidth(Text$)
      TextHeight = TextHeight(Text$)
      StopDrawing()
     
      If ResizeImage(Image, TextWidth, TextHeight)
        If StartDrawing(ImageOutput(Image))
          DrawingMode(#PB_2DDrawing_Transparent)
          DrawText(0, 0, Text$, Textcolor)
         
          tmpy = y - (1 / GadgetHeight(Gadget) * TextHeight * 2)
         
          glRasterPos2f_(x, tmpy)
          glDrawPixels_(TextWidth, TextHeight, #GL_BGR_EXT, #GL_UNSIGNED_BYTE, DrawingBuffer())
         
          Result = #True
         
          StopDrawing()
        EndIf
      EndIf
     
    EndIf
    FreeImage(Image)
  EndIf
 
  ProcedureReturn Result
 
EndProcedure

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


;-MAIN REPEAT
Repeat ;- ..... Repeat
  
  glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  
  Render()
  glReadPixels_(Resx, ddh-1-Resy, 1 , 1, #GL_RGBA, #GL_UNSIGNED_BYTE, @pixels )
  
  
  Event = WaitWindowEvent()
  
  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
              Beep_(1500,33) ;;debug "Clic avec le bouton gauche de la souris"
              poly_x(0)+1
              poly_x(poly_x(0))=Resx 
              poly_y(poly_x(0))=Resy
              
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            Case #PB_EventType_RightDoubleClick 
              If poly_x(0)>0
                Beep_(500,400) ;: ;debug "Double-clic avec le bouton droit de la souris"
                Dim poly_x(1000)
                Dim poly_y(1000)
                
              EndIf
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              
            Case #PB_EventType_RightClick
              If poly_x(0)>0
                Beep_(500,33) ;;debug "Clic avec le bouton droit de la souris"
                poly_x(0)-1
                
              EndIf
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              
            Case #PB_EventType_MiddleButtonDown
              If poly_x(0)>2
                Beep_(3000,33) : Delay(33) : Beep_(3000,33) ;;debug "Clic avec le bouton centre de la souris"
                
                ;-;;;;;;;;;;;;;;;;;;;;;;;bouton centre
                poly_x2(0)+1
                ;old=1
                
                nb=0
                While poly_y2(nb)>0
                  nb+poly_y2(nb)
                Wend
                
                ; Debug "nb = "+Str(nb)
                
                poly_y2(nb)=poly_x(0)+5
                poly_x2(nb+1)=rouge*255
                poly_x2(nb+2)=vert*255
                poly_x2(nb+3)=bleu*255
                If no_alpha=1
                  poly_x2(nb+4)=no_alpha*255
                  uuu.f=no_alpha
                Else
                  poly_x2(nb+4)=alpha*255
                  uuu=alpha
                EndIf
                
                t=0
                For i=0 To ref
                  ii1=ref_r(i)*255
                  ii2=ref_v(i)*255
                  ii3=ref_b(i)*255
                  If ii1=rouge*255 And ii2=vert*255 And ii3=bleu*255 And ref_a(i)=uuu
                    t=1
                    ;Break
                  EndIf
                Next
                ;debug "t = "+Str(t)
                If t=0
                  ref+1
                  ref_r(ref)=rouge
                  ref_v(ref)=vert
                  ref_b(ref)=bleu
                  ref_a(ref)=uuu
                  ;Debug "ref = "+Str(ref)
                EndIf
                
                For i=1 To poly_x(0)
                  poly_x2(nb+4+i)=poly_x(i)
                  poly_y2(nb+4+i)=poly_y(i)
                Next
                
                Dim poly_x(1000)
                Dim poly_y(1000)
                
                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                
              EndIf
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;              
          EndSelect
      EndSelect
    Case #PB_Event_Menu
      Select EventMenu()
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;        
        Case 666
          End
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 1
          travail+1
          travail%2
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 3
          Continu=1
          Continu2+1
          Continu2%2
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 8
          hide+1
          hide%2
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 9
          image_fond+1
          image_fond%2
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 11
          elimine=1
          elimine3+1
          elimine3%2
          
          ;old=1
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 13
          model+1
          model%2
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 16;-Case 16
          glReadPixels_(Resx, ddh-1-Resy, 1 , 1, #GL_RGBA, #GL_UNSIGNED_BYTE, @pixels )
          rouge=(Red(pixels))/255
          vert=(Green(pixels))/255
          bleu=(Blue(pixels))/255
          alpha=(Alpha(pixels))/255
          
          ref+1
          ref_ici=ref
          ref_r(ref)=rouge
          ref_v(ref)=vert
          ref_b(ref)=bleu
          ref_a(ref)=alpha
          
          Beep_(3000,50)      

          ref_colors=1
          timer=ElapsedMilliseconds()

          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case 26
          zoom+1
          zoom%2
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 95
          save=1
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 96
          dernier=1
          dernier_ici-1
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 97
          dernier=1
          dernier_ici+1
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 98 ;- case 98
          ref_colors=1
          timer=ElapsedMilliseconds()
          ref_ici-1
          If ref_ici<0
            ref_ici=ref
            Beep_(3000,50)      
          Else
            Beep_(1500,50)      
          EndIf
          ;          ;debug ref_ici
          ;           ref_colors%2
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 99 ;- case 99
          ref_colors=1
          timer=ElapsedMilliseconds()
          ref_ici+1
          If ref_ici>ref
            ref_ici=0
            Beep_(3000,50)      
          Else
            Beep_(1500,50)      
          EndIf
          ;           ref_colors%2
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case 140
          palier-1
          If palier<1
            palier=1
          EndIf
          
        Case 141
          palier+1
          If palier>10
            palier=10
          EndIf
          
        Case 100
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          alpha+palier/255
          If alpha>1
            alpha=1
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Case 101
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          alpha-palier/255
          If alpha<0
            alpha=0
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 102
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          alpha=0.5
          no_alpha=0
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 103
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          no_alpha+1
          no_alpha%2          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 110
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          rouge-palier/255
          If rouge<0
            rouge=0
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 111
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          rouge+palier/255
          If rouge>1
            rouge=1
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 112
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          vert-palier/255
          If vert<0
            vert=0
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 113
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          vert+palier/255
          If vert>1
            vert=1
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 114
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          bleu-palier/255
          If bleu<0
            bleu=0
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 115
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          bleu+palier/255
          If bleu>1
            bleu=1
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 116
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          rouge=0.5
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 117
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          vert=0.5
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 118
          ref_colors5=1
          timer5=ElapsedMilliseconds()
          bleu=0.5
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
          ;- Case 129
        Case 129
        For i=0 To 100000
          Swap poly_x2(i),poly_x2_1(i)
          Swap poly_y2(i),poly_y2_1(i)
        Next
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
          
        Case 130
          polygon+1
          polygon%2        
          polygon_on=0
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 131
          polygon_on-1
          If polygon_on<0
            polygon_on=poly_x2(0)-1
          EndIf
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 132
          polygon_on+1
          If polygon_on>=poly_x2(0)
            polygon_on=0
          EndIf
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
      EndSelect
  EndSelect
  
  
  ;   glBlendFunc_(#GL_SRC_ALPHA,0)
  ;   glBegin_(#GL_POLYGON)
  ;   glColor4f_(1,1,1,1)
  ;   glVertex2f_(22,11)
  ;   glVertex2f_(500,66)
  ;   glVertex2f_(33,755)
  ;   glEnd_()
  ;   
  ;   ;  glEnable_(#GL_BLEND)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  ;   glBegin_(#GL_POLYGON)
  ;   glColor4f_(0,1,1,0.5)
  ;   ;glColor4f_(1,1,1,1)
  ;   glVertex2f_(400,600)
  ;   glVertex2f_(200,600)
  ;   glVertex2f_(300,100)
  ;   glEnd_()
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;-;;;;;;;;;;;;;;;  History of polygons  ;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  If image_fond=0
    
    
    nb2=0
    ii=0
    If model=1
      While poly_my2(nb2)>0
        ii=poly_my2(nb2)
        alpha2.f=poly_mx2(nb2+4)/255
        glBegin_(#GL_POLYGON)
        If travail=0
          If alpha2=1
            glBlendFunc_(#GL_SRC_ALPHA,0)
            glColor4f_(poly_mx2(nb2+1)/255,poly_mx2(nb2+2)/255,poly_mx2(nb2+3)/255,1)
          Else
            glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
            glColor4f_(poly_mx2(nb2+1)/255,poly_mx2(nb2+2)/255,poly_mx2(nb2+3)/255,alpha2)
          EndIf
        Else
          glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
          glColor4f_(poly_mx2(nb2+1)/255,poly_mx2(nb2+2)/255,poly_mx2(nb2+3)/255,0.3)
        EndIf
        For i=1 To poly_my2(nb2)-5
          glVertex2f_(poly_mx2(nb2+4+i),poly_my2(nb2+4+i))
        Next
        glEnd_()
        nb2+ii
      Wend
    EndIf
    
    ;========================================================
    
    nb2=0
    ii=0
    While poly_y2(nb2)>0
      ii=poly_y2(nb2)
      alpha2.f=poly_x2(nb2+4)/255
      glBegin_(#GL_POLYGON)
      If travail=0
        If alpha2=1
          glBlendFunc_(#GL_SRC_ALPHA,0)
          glColor4f_(poly_x2(nb2+1)/255,poly_x2(nb2+2)/255,poly_x2(nb2+3)/255,1)
        Else
          glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
          glColor4f_(poly_x2(nb2+1)/255,poly_x2(nb2+2)/255,poly_x2(nb2+3)/255,alpha2)
        EndIf
      Else
        glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
        glColor4f_(poly_x2(nb2+1)/255,poly_x2(nb2+2)/255,poly_x2(nb2+3)/255,0.3)
      EndIf
      For i=1 To poly_y2(nb2)-5
        glVertex2f_(poly_x2(nb2+4+i),poly_y2(nb2+4+i))
      Next
      glEnd_()
      nb2+ii
    Wend
    
    ;=======================================================
    
    ;Debug poly_x(0);>1; And 0=1
    If poly_x(0)>1; And 0=1
      glBegin_(#GL_POLYGON)
      If no_alpha=1
        glColor4f_(rouge,vert,bleu,1)
      Else
        glColor4f_(rouge,vert,bleu,alpha)
      EndIf
      
      For i=1 To poly_x(0)
        glVertex2f_(poly_x(i),poly_y(i))
      Next
      If hide=0
        glVertex2f_(Resx,Resy) 
      EndIf
      
      glEnd_()
    EndIf
    
    
  EndIf ;If image_fond=0
  
  
  ;   SetGadgetAttribute(1,#PB_OpenGL_FlipBuffers,#True)
  
  
  ;- le texte
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  If model=1
    OpenGLDrawText(1, 300, 25, "Model ON (m)", #White)
  Else
    OpenGLDrawText(1, 300, 25, "Model OFF (m)", #White)
  EndIf
  
  If zoom=1
    OpenGLDrawText(1, 450, 25, "Zoom ON (z)", #White)
  Else
    OpenGLDrawText(1, 450, 25, "Zoom OFF(z)", #White)
  EndIf

  If poly_x2(0)=0
    OpenGLDrawText(1, 600, 25, Str(poly_x2(0))+" Polygon (c)", #Red)
  Else
    OpenGLDrawText(1, 600, 25, Str(poly_x2(0))+" Polygons", #White)
  EndIf
  
  If travail=1
    OpenGLDrawText(1, 750, 25, "Alpha ON (a)", #White)
  Else
    OpenGLDrawText(1, 750, 25, "Alpha OFF (a)", #White)
  EndIf
  
  
  If image_fond=1
    OpenGLDrawText(1, 900, 25, "Image ON (i)", #Red)
  Else
    OpenGLDrawText(1, 900, 25, "Image OFF (i)", #White)
  EndIf
  
  OpenGLDrawText(1, 1050, 25, "Palier="+Str(palier)+" (F11&F12)", #White)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  
  ;- If ref_colors=1
  If ref_colors=1
    If timer2=0
      ;       timer=ElapsedMilliseconds()
      timer2=1
;      colors=1
      ;Beep_(5000,150)
    EndIf
    If timer2=1 And ElapsedMilliseconds()-timer>3000
      ref_colors=0
      timer2=0
    EndIf
    
    
    
    glBlendFunc_(#GL_SRC_ALPHA,0)
    glBegin_(#GL_POLYGON)
    glColor4f_(ref_r(ref_ici),ref_v(ref_ici),ref_b(ref_ici),1);ref_a(ref_ici))
    
    ;                 poly_x2(nb+1)=rouge*255
    ;                 poly_x2(nb+2)=vert*255
    ;                 poly_x2(nb+3)=bleu*255
    ;                 If no_alpha=1
    ;                   poly_x2(nb+4)=no_alpha*255
    ;                   uuu.f=no_alpha
    ;                 Else
    ;                   poly_x2(nb+4)=alpha*255
    ;                   uuu=alpha
    ;                 EndIf
    
    glVertex2f_(0,0)
    glVertex2f_(128,0)
    glVertex2f_(128,128)
    glVertex2f_(0,128)
    glEnd_()
    
    rouge=ref_r(ref_ici)
    vert=ref_v(ref_ici)
    bleu=ref_b(ref_ici)
    alpha=ref_a(ref_ici)
    
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    glBegin_(#GL_POLYGON)
    glColor4f_(rouge,vert,bleu,alpha)
    
    glVertex2f_(256,0)
    glVertex2f_(128,0)
    glVertex2f_(128,128)
    glVertex2f_(256,128)
    glEnd_()

OpenGLDrawText(1, 10, 25, "Rouge : "+Str(rouge*255), #White)
OpenGLDrawText(1, 10, 45, "Vert : "+Str(vert*255), #White)
OpenGLDrawText(1, 10, 65, "Bleu : "+Str(bleu*255), #White)
OpenGLDrawText(1, 10, 85, "Alpha : "+Str(alpha*255), #White)

  EndIf
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  ;- If ref_colors5=1
  
  If ref_colors5=1
    If timer6=0
      ;       timer=ElapsedMilliseconds()
      timer6=1
 ;     colors5=1
      ;Beep_(5000,150)
    EndIf
    If timer6=1 And ElapsedMilliseconds()-timer5>3000
      ref_colors5=0
      timer6=0
    EndIf
    
    
    
    glBlendFunc_(#GL_SRC_ALPHA,0)
    glBegin_(#GL_POLYGON)
    glColor4f_(rouge,vert,bleu,1)
    
    glVertex2f_(0,0)
    glVertex2f_(128,0)
    glVertex2f_(128,128)
    glVertex2f_(0,128)
    glEnd_()
    
;     rouge=ref_r(ref_ici)
;     vert=ref_v(ref_ici)
;     bleu=ref_b(ref_ici)
;     alpha=ref_a(ref_ici)
    
    glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
    glBegin_(#GL_POLYGON)
    glColor4f_(rouge,vert,bleu,alpha)
    
    glVertex2f_(256,0)
    glVertex2f_(128,0)
    glVertex2f_(128,128)
    glVertex2f_(256,128)
    glEnd_()

OpenGLDrawText(1, 10, 25, "Rouge : "+Str(rouge*255), #White)
OpenGLDrawText(1, 10, 45, "Vert : "+Str(vert*255), #White)
OpenGLDrawText(1, 10, 65, "Bleu : "+Str(bleu*255), #White)
OpenGLDrawText(1, 10, 85, "Alpha : "+Str(alpha*255), #White)

  EndIf
          
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  If continu2=1
    record=0  
  EndIf
  
  If record=1 And poly_x2(0)=0
    record=0
  EndIf
  
  If record=1
    glBlendFunc_(#GL_SRC_ALPHA,0)
    glBegin_(#GL_POLYGON)
    glColor4f_(1,0,0,1);ref_a(ref_ici))
                       ;glColor4f_(1,1,1,1)
    glVertex2f_(ddw-50,30)
    glVertex2f_(ddw-50,40)
    glVertex2f_(ddw-40,50)
    glVertex2f_(ddw-30,50)
    glVertex2f_(ddw-20,40)
    glVertex2f_(ddw-20,30)
    glVertex2f_(ddw-30,20)
    glVertex2f_(ddw-40,20)
    glEnd_()
    
  EndIf
  
  If travail=0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    glBlendFunc_(#GL_SRC_ALPHA,0)
    glBegin_(#GL_POLYGON)
    glColor4f_(1,1,1,1);ref_a(ref_ici))
                       ;glColor4f_(1,1,1,1)
    glVertex2f_(ddw-80,20)
    glVertex2f_(ddw-80,50)
    glVertex2f_(ddw-110,50)
    glVertex2f_(ddw-110,20)
    glEnd_()
    
  EndIf
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  If old=1
    For i=0 To 80
      ;Debug ("poly_x2 : "+Str(poly_x2(i))+" --- poly_y2 : "+Str(poly_y2(i)))
    Next
    Debug ("xxxxx")
    old=0
    Beep_(1000,100)
  EndIf
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  ;- If elimine=1  ...................................
  
  If elimine=1
    elimine=0
    ;debug "==========="
    
    If polygon1=0
      nb2=0
      ii=0
      nb3=0
      While poly_y2(nb2)>0
        ii=poly_y2(nb2)
        ;debug nb
        nb3=nb2
        nb2+ii
      Wend
      If nb2<>0
        Beep_(500,150)
        poly_x2(0)-1
      EndIf
      For i=nb3 To 100000
        poly_x2(i)=0
        poly_y2(i)=0
      Next
      
    Else
      
      ;-;;;;;;;;;;;;;;;;;;;;;;  tout le charabia ici pour killer le polygon tab
      
;       Debug ("Start")
      
      nb5=0
      nb6=0
      nb2=0
      ii=0
      cont=0
      While poly_y2(nb2)>0
        ii=poly_y2(nb2)
        If polygon_on=cont
          nb5=nb2-1
          ;    Goto la556
        EndIf
        If polygon_on<cont
          nb6=nb2
          Goto la556
        EndIf
        
        cont+1
        nb2+ii
      Wend
      
      la556:

      Dim poly_x2_1(100000)
      Dim poly_y2_1(100000)
      
      polyx=poly_x2(0)-1
      
      If polyx<>0
        ;polyx=poly_x2(0)-1
        
        cont=0   
        For i=0 To nb5
          poly_x2_1(cont)=poly_x2(i)
          poly_y2_1(cont)=poly_y2(i)
          cont+1
        Next
        
        If nb6>=nb5
          For i=nb6 To 100000
            poly_x2_1(cont)=poly_x2(i)
            poly_y2_1(cont)=poly_y2(i)
            cont+1
            If cont>100000
              Break
            EndIf
            
          Next
        EndIf
        
        For i=0 To 100000
          Swap poly_x2(i),poly_x2_1(i)
          Swap poly_y2(i),poly_y2_1(i)
        Next
        poly_x2(0)=polyx
      
      Else
        
        Dim poly_x2(100000)
        Dim poly_y2(100000)
        
      EndIf
      
;       If nb5=-1 And nb6=0 And polyx=0
;         Beep_(1800,1000)
;       EndIf
      
      For i=0 To 60
        ;Debug ("<=    poly_x2 : "+Str(poly_x2(i))+" --- poly_y2 : "+Str(poly_y2(i)))
      Next
      
      Beep_(1000,100)
      
;       Debug ("xxxxx")
      
      If polygon_on>=poly_x2(0)
        polygon_on=0
      EndIf

      ;;;;;;;;;;;;;;;;;;;;;;;
      
    EndIf
    
  EndIf
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  ;- If save=1    ............................
  
  If save=1
    save=0
    sph_x=0
    compteur=0
      If poly_x2(0)>0
      i=1
      While FileSize(chemin$+Str(i)+".pol")<>-1
        i+1
      Wend
      dernier_fichier=i-1
      chem$=chemin$+Str(i)+".pol"
      ;Debug chem$
      
      nb2=0
      ii=0
      i=1
      Dim saut.w(10000)
      While poly_y2(nb2)>0
        ii=poly_y2(nb2)
        saut(i)=ii
;         Debug saut(i)
        i+1
        ;debug nb
        nb2+ii
      Wend
      saut(0)=1
;       Debug "==="
;       End
      
      If CreateFile(0, chem$)    ; Ouvre un fichier existant ou en crée un nouveau s'il n'existait pas
        Debug "DataSection"
        Debug "sph_data:"
        For i=0 To nb2
          ; Debug ("poly_x2 : "+Str(poly_x2(i))+" --- poly_y2 : "+Str(poly_y2(i)))
          ;     WriteWord(0,poly_x2(i))
          ;     WriteWord(0,poly_y2(i))
          WriteWord(0,poly_x2(i))
          WriteWord(0,poly_y2(i))
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Rajout pour récuperer les datas
          sph_x+1
          compteur+1
          If sph_x=1
            sph_data$="data.w "+Str(poly_x2(i))+","+Str(poly_y2(i))
          Else
            sph_data$+","+Str(poly_x2(i))+","+Str(poly_y2(i))
          EndIf
          If compteur=saut(saut(0))
            sph_x=0
            compteur=0
            Debug sph_data$
            sph_data$=""
            saut(0)+1
          EndIf
          
          
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        Next
        ;End
        ;;;;;;;;;;;;;;
        CloseFile(0)
        Beep_(2500,150)      
      Else
        MessageRequester("Erreur","Creation de fichier impossible")
      EndIf
      
      i=1
      While FileSize(chemin$+Str(i)+".pol")<>-1
        i+1
      Wend
      dernier_fichier=i-1
      
      Debug sph_data$
      sph_x=0
      sph_data$=""            
      Debug "EndDataSection"
      
    EndIf
  EndIf
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;- If dernier=1    ...........................................
  
  If dernier=1
    dernier=0
    If dernier_ici<1
      dernier_ici=1
    EndIf
    If dernier_ici>dernier_fichier
      dernier_ici=dernier_fichier
    EndIf
    continu=0
    record=0
    
    If FileSize(chemin$+Str(dernier_ici)+".pol")=-1
      Beep_(500,200)
    Else
      If model=1
        If ReadFile(1, chemin$+Str(dernier_ici)+".pol")
          Dim poly_mx2(100000)
          Dim poly_my2(100000)
          For i=1 To Lof(1)/4
            ;           poly_mx2(i)=ReadWord(1)
            ;           poly_my2(i)=ReadWord(1)
            poly_mx2(i-1)=ReadWord(1)
            poly_my2(i-1)=ReadWord(1)
            ;Debug ("poly_mx2() = "+Str(poly_mx2(i-1))+"  -  "+"poly_my2() = "+Str(poly_my2(i-1)))
          Next
          CloseFile(1)
        EndIf
      EndIf
    EndIf
  EndIf
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;-If Continu=1  .........................
  
  If Continu=1
    Continu=0
    model=0
    record=1
    
    For i=0 To 100000
      poly_x2(i)=poly_mx2(i)
      poly_y2(i)=poly_my2(i)
      ;Debug ("<poly_x2 : "+Str(poly_x2(i))+" --- <poly_y2 : "+Str(poly_y2(i)))
    Next
    
    
    nb2=0
    ii=0
    While poly_my2(nb2)>0
      ii=poly_my2(nb2)
      ;         Debug ii
      ;         End
      
      ref_r(1000)=poly_mx2(nb2+1)/255
      ref_v(1000)=poly_mx2(nb2+2)/255
      ref_b(1000)=poly_mx2(nb2+3)/255
      ref_a(1000)=poly_mx2(nb2+4)/255
      
      t=0
      For i=0 To ref
        If ref_r(i)=ref_r(1000) And ref_v(i)=ref_v(1000) And ref_b(i)=ref_b(1000) And ref_a(i)=ref_a(1000)
          t=1
          Break
        EndIf
      Next
      ;Debug "t = "+Str(t)
      If t=0
        ref+1
        ref_r(ref)=ref_r(1000)
        ref_v(ref)=ref_v(1000)
        ref_b(ref)=ref_b(1000)
        ref_a(ref)=ref_a(1000)
      EndIf
      ;next
      
      For i=1 To poly_my2(nb2)-5
        glVertex2f_(poly_mx2(nb2+4+i),poly_my2(nb2+4+i))
      Next
      glEnd_()
      nb2+ii
    Wend
    
;    Debug ("<<<>>>")
    
  EndIf
  
  ;     
  ;     ;========================================================
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;-If zoom=1   .........................
  
  If zoom=1
    If Resx<400
      zoomx=ddw-500
    Else
      zoomx=0
    EndIf
    
    For u=-10 To 10
      For i=-10 To 10
        glReadPixels_(Resx+i, ddh-1-Resy-u, 1 , 1, #GL_RGBA, #GL_UNSIGNED_BYTE, @pixels )
        rougez.f=(Red(pixels))/255
        vertz.f=(Green(pixels))/255
        bleuz.f=(Blue(pixels))/255
        alphaz.f=(Alpha(pixels))/255
        glBlendFunc_(#GL_SRC_ALPHA,0)
        glBegin_(#GL_POLYGON)
        glColor4f_(rougez,vertz,bleuz,alphaz)
        glVertex2f_(zoomx+250+i*10,270+u*10)
        glVertex2f_(zoomx+250+i*10+10,270+u*10)
        glVertex2f_(zoomx+250+i*10+10,270+u*10+10)
        glVertex2f_(zoomx+250+i*10,270+u*10+10)
        glEnd_()
        
      Next
    Next
    
    glBlendFunc_(#GL_SRC_ALPHA,0)
    glBegin_(#GL_POLYGON)
    glColor4f_(1,1,1,1)
    glVertex2f_(zoomx+254,265)
    glVertex2f_(zoomx+256,265)
    glVertex2f_(zoomx+256,285)
    glVertex2f_(zoomx+254,285)
    glEnd_()
    
    glBlendFunc_(#GL_SRC_ALPHA,0)
    glBegin_(#GL_POLYGON)
    glColor4f_(1,1,1,1)
    glVertex2f_(zoomx+245,274)
    glVertex2f_(zoomx+245,276)
    glVertex2f_(zoomx+265,276)
    glVertex2f_(zoomx+265,274)
    glEnd_()
    
    
  EndIf
  
  
  
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;- If polygon=1 And poly_x(0)=0 ;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  If polygon=1 And poly_x(0)=0 And poly_x2(0)>0
    
    polygon1=1
    nb4=0
    nb2=0
    ii=0
    
    While poly_y2(nb2)>0; And 1=0
      If polygon_on=nb4
        glBegin_(#GL_POLYGON)
        glBlendFunc_(#GL_SRC_ALPHA,0)
        
        If ref_colors=1 ;And colors=1
          ;  colors=0
          poly_x2(nb2+1)=ref_r(ref_ici)*255
          poly_x2(nb2+2)=ref_v(ref_ici)*255
          poly_x2(nb2+3)=ref_b(ref_ici)*255
          poly_x2(nb2+4)=ref_a(ref_ici)*255
;           poly_x2(nb2+1)=rouge*255
;           poly_x2(nb2+2)=vert*255
;           poly_x2(nb2+3)=bleu*255
;           poly_x2(nb2+4)=alpha*255
       EndIf
        
       clignote+1
       clignote%12
       
     If clignote<5
       glColor4f_(poly_x2(nb2+1)/255,poly_x2(nb2+2)/255,poly_x2(nb2+3)/255,1)
     EndIf
     If clignote=5
       glColor4f_(poly_x2(nb2+1)/255,poly_x2(nb2+2)/255,poly_x2(nb2+3)/255,0.1)
     EndIf
     If clignote=6
       glColor4f_(0,0,0,1)
     EndIf
     If clignote=7
       glColor4f_(1,1,1,1)
     EndIf
     If clignote>=8
       glColor4f_(poly_x2(nb2+1)/255,poly_x2(nb2+2)/255,poly_x2(nb2+3)/255,poly_x2(nb2+4)/255)
     EndIf
     
        For i=1 To poly_y2(nb2)-5
          glVertex2f_(poly_x2(nb2+4+i),poly_y2(nb2+4+i))
        Next
        glEnd_()
        Break
      EndIf
      
      nb4+1
      ii=poly_y2(nb2)
      nb2+ii
    Wend
    
    glBlendFunc_(#GL_SRC_ALPHA,0)
    glBegin_(#GL_POLYGON)
    glColor4f_(1,0,0,1);- fleche rouge (tab)
    
    glVertex2f_(ddw-135,35)
    glVertex2f_(ddw-150,20)
    glVertex2f_(ddw-150,25)
    glVertex2f_(ddw-160,25)
    glVertex2f_(ddw-160,45)
    glVertex2f_(ddw-150,45)
    glVertex2f_(ddw-150,50)
    glEnd_()
    
    
  Else
    polygon=0
    polygon1=0
  EndIf
  

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

; EndIf
End
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************
;*********************************************************************************************************************************


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

===============================================================================================
Si vous faites une scène de polygones, que vous la sauvez et que vous quittez avec ESC, vous aurez dans le message du débuggueur la liste des polygones; un polygone par ligne (ce qui est plus facile pour relire de visu)

Ensuite, voici un lecteur de polygones (copier les datas a la fin du code) :

Code : Tout sélectionner

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code : Lecteur de polygones (datas)   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; PB6.0 - SPH(2022) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


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

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

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

;;;;;;;;;;;
  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
  
  timer=ElapsedMilliseconds()

glClearColor_(0,0,0, 1.0)
; ShowCursor_(0)
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
;-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;#################**********************************************
Repeat
  
  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
  
  
  ;##############################################
  ;##############################################
  ;##############################################
  ;##############################################
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Restore sph_data

Read.w sph_nombre_poly
Read.w sph_cmb
; Debug sph_nombre
; Debug sph_cmb
sph_cmb_mem=sph_cmb

Dim sph_xx.w(sph_cmb)
Dim sph_yy.w(sph_cmb)
sph_la=0

Repeat
                      glBegin_(#GL_POLYGON);
                      glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
If sph_la<>0
;   Debug "==="
  sph_cmb_mem+sph_cmb
;  Debug sph_cmb_mem
  ReDim sph_xx.w(sph_cmb_mem)
  ReDim sph_yy.w(sph_cmb_mem)
EndIf

sph_xx(la)=sph_nombre
sph_yy(la)=sph_cmb

For i=1 To 4;sph_cmb
Read.w sph_xx(sph_la+i)  
Read.w sph_yy(sph_la+i)  
; Debug sph_xx(sph_la+i)
; Debug sph_yy(sph_la+i)
Next
                      glColor4f_(sph_xx(sph_la+1)/255,sph_xx(sph_la+2)/255,sph_xx(sph_la+3)/255,sph_xx(sph_la+4)/255)

For i=5 To sph_cmb-1
Read.w sph_xx(sph_la+i)  
Read.w sph_yy(sph_la+i)  
                      glVertex2f_(sph_xx(sph_la+i)/echelle_xf,sph_yy(sph_la+i)/echelle_yf);
Next
                      glEnd_()                      ; 

Read.w sph_xx(sph_la+i)  
Read.w sph_yy(sph_la+i)  
; Debug "=="
sph_cmb=sph_yy(sph_la+i)
; Debug "sph_cmb = "+Str(sph_cmb)
sph_la+i
Until sph_yy(sph_la)=0
;;;;;;;;;;;;;;;

 
  SetGadgetAttribute(#OpenGLGadget, #PB_OpenGL_FlipBuffers, #True)
  
timer=ElapsedMilliseconds()-timer
;Debug timer
timer=ElapsedMilliseconds()
 
ForEver

End


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


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;- DataSection
DataSection
sph_data:
Data.w 25,9,51,0,71,0,115,0,255,0,0,0,0,1079,1919,1079,1919,0
Data.w 0,22,66,0,89,0,153,0,255,0,235,0,156,551,165,601,296,814,430,849,484,900,726,902,711,883,1184,858,1236,829,1418,847,1463,847,1575,814,1689,599,1695,545,1650,320,1625,0
Data.w 0,17,64,0,110,0,239,0,255,0,373,0,264,244,236,326,261,498,291,554,427,730,679,844,1185,769,1516,516,1509,350,1401,203,1343,0
Data.w 0,17,0,0,138,0,255,0,255,0,389,0,304,233,291,355,344,522,506,612,653,722,714,740,1176,744,1517,513,1508,344,1394,188,1345,0
Data.w 0,13,36,0,39,0,59,0,255,0,67,960,213,887,274,892,333,967,1520,964,1644,1079,0,1079,0,966
Data.w 0,11,36,0,39,0,59,0,255,0,1919,816,1828,813,1775,834,1719,897,1607,1079,1919,1079
Data.w 0,10,36,0,39,0,59,0,255,0,1721,895,1525,951,1513,988,1621,1079,1712,1079
Data.w 0,9,51,0,71,0,115,0,255,0,341,834,347,649,377,650,403,889
Data.w 0,9,0,0,0,0,4,0,255,0,0,1008,0,1079,1919,1079,1919,1010
Data.w 0,23,0,0,0,0,4,0,255,0,402,610,416,705,530,960,685,981,638,691,599,610,631,588,1174,43,1033,10,828,10,716,41,646,163,555,233,517,348,440,411,422,497,389,517,379,554
Data.w 0,16,0,0,0,0,4,0,255,0,911,951,935,886,1213,134,1171,42,623,580,745,895,728,953,512,1079,914,1079,924,1007,927,986
Data.w 0,9,0,0,0,0,4,0,255,0,529,956,438,1018,738,1037,677,969
Data.w 0,21,0,0,0,0,4,0,255,0,949,945,930,864,1212,125,1223,155,1307,239,1358,339,1420,396,1253,584,1153,743,1121,892,1122,947,1171,964,1200,1079,914,1079,932,1008,931,965
Data.w 0,19,0,0,0,0,4,0,255,0,1278,621,1231,553,1420,397,1452,480,1483,489,1495,534,1460,619,1458,639,1442,771,1368,979,1367,1079,1205,1079,1220,974,1231,762
Data.w 0,11,0,0,0,0,4,0,255,0,1224,974,1169,1003,1156,1079,1409,1079,1404,1001,1360,970
Data.w 0,9,172,0,135,0,115,0,255,0,828,689,846,688,841,641,835,641
Data.w 0,9,172,0,135,0,115,0,255,0,912,705,901,706,907,665,913,665
Data.w 0,9,172,0,135,0,115,0,255,0,942,514,937,578,943,579,959,514
Data.w 0,9,172,0,135,0,115,0,255,0,817,502,828,535,833,536,833,504
Data.w 0,9,111,0,26,0,0,0,255,0,789,438,794,454,811,454,804,438
Data.w 0,9,111,0,26,0,0,0,255,0,967,425,984,425,978,441,963,440
Data.w 0,9,89,0,0,0,0,0,255,0,0,0,0,1079,12,1079,12,0
Data.w 0,9,89,0,0,0,0,0,255,0,0,0,1919,0,1919,15,0,15
Data.w 0,9,89,0,0,0,0,0,255,0,1919,0,1919,1079,1907,1079,1906,0
Data.w 0,9,89,0,0,0,0,0,255,0,1919,1079,0,1079,0,1067,1919,1065
Data.w 0,0
EndDataSection
Dernière modification par SPH le lun. 01/août/2022 10:50, modifié 27 fois.

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Polygons Editor

Message par venom »

Fonctionne bien chez moi. Par contre comment tu finalise une forme ?
clic gauche créer un point
clic droit efface la forme
middle rien :lol:






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Polygons Editor

Message par SPH »

venom a écrit :Fonctionne bien chez moi. Par contre comment tu finalise une forme ?
clic gauche créer un point
clic droit efface la forme
middle rien :lol:
Tu as tout compris : middle validera la forme :P

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Polygons Editor

Message par SPH »

Fini à 75% 8)

"H" pour hide/show le triangle actuel
"1" pour diminuer le rouge
"2" pour augmenter le rouge
"3" pour rendre le rouge a 0.5

"4 a 6" pour le vert
"7 a 9" pour le bleu

"+" augmente l'alpha
"-" diminue l'alpha
"*" met l'alpha a 0.5
"/" met l'alpha a 1

clic gauche : ajouter un point a son polygone
clic droit : retirer le dernier point
double clic droit : eliminer le polygone en court

CLIC CENTRE : il n'est pas fait mais j'y travaille :idea:

:P

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Polygons Editor (75%)

Message par kernadec »

boujour SPH
c'est bien parti pour ton soft :wink:
merci pour le partage
je te soumet une petite suggestion
pour les couleurs
tu pourrais utiliser une combinaison de touche exemple pour le rouge mode, plus "shift R"
pour le rouge mode, moins "ctrl r"
idem pour les autre couleurs ainsi la transparence serait mode, plus "shift A" etc.

peut être aussi une alternative pour les combinaisons de la souris avec le clavier inclus
te permettrait de faire plus de combinaisons
exemple de fonction "ctrl clic droit" fin du polygone etc..

peut être aussi avec la touche f1 en mode (oui/non) affichage aide
sur l'écran des combinaisons touches clavier/souris etc..
tout cela en mème temps que le dessin

jette un oeil sur les fonctions PB :KeyboardPushed() et KeyboardReleased()

cordialement
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Polygons Editor (75%)

Message par SPH »

kernadec a écrit :boujour SPH
c'est bien parti pour ton soft :wink:
merci pour le partage
je te soumet une petite suggestion
pour les couleurs
tu pourrais utiliser une combinaison de touche exemple pour le rouge mode, plus "shift R"
pour le rouge mode, moins "ctrl r"
idem pour les autre couleurs ainsi la transparence serait mode, plus "shift A" etc.
Merci kernadec

Pour les couleurs, je localise tout sur le pavé numerique. Mais il y a une fonction que je ferais et qui consistera a peek une couleur sur l'image de fond; une image venant par exemple du jeu another world.

Pour la touche F1, tu as raison. Mais il faut que je trouve une methode sous openGL pour afficher tu texte :mrgreen:

Heuuu, et puis, un secret : l'editeur n'est qu'un editeur. Je veux dire que je ne le distribuerais pas au grand public (enfin, je crois)...
Il faut que je code le programme de "decryptage" des polygones pour les afficher dans une animation (ce sera facile).

Voila ! :P

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Polygons Editor (75%)

Message par kernadec »

tu pourrais afficher avec f1 une fenêtre d'aide indépendante :wink:

j'avais poster un code du forum anglais pour écriture avec OpenGLGadget
https://www.purebasic.fr/french/viewtop ... =6&t=17867
cordialement
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Polygons Editor (75%)

Message par SPH »

kernadec a écrit :tu pourrais afficher avec f1 une fenêtre d'aide indépendante :wink:

j'avais poster un code du forum anglais pour écriture avec OpenGLGadget
https://www.purebasic.fr/french/viewtop ... =6&t=17867
cordialement
Lien extrêmement intéressant !!

Moi qui cherchais a aficher un plot sur une fenetre GL...

Tres grand merci :P

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Polygons Editor (75%)

Message par kernadec »

merci @applePi :mrgreen:

j 'ai modifié l'exemple KeyboardPushed()
pour utiliser les touches "Ctrl,Shift,Alt" avec un clic souris
voici l'exemple avec "Ctrl" avec souris clic gauche.

oops:
[Réédit:] Correction
Comme le dit @falsam dans le post suivant KeyboardPushed() ne fonctionne pas avec OpenGlGadget
heureusement, il y a AddKeyboardShortcut()

ps: je laisse le code exemple malgré tout avec OpenScreen

Code : Tout sélectionner

If InitSprite() And InitKeyboard() And OpenScreen(800,600,16,"") And InitMouse()
    Repeat
      FlipBuffers()
      ExamineKeyboard()
      ExamineMouse() 
      
      If StartDrawing(ScreenOutput())
        DrawText(0, 0, "Appuyez sur la touche [Echap] pour quitter")
        StopDrawing()
      EndIf
     
      If KeyboardPushed(#PB_Key_RightBracket)  +  MouseButton(#PB_MouseButton_Left) = #True
       End  ;" touche control et clic gauche souris "
      EndIf

    ForEver
  EndIf
cordialement
Dernière modification par kernadec le mer. 02/déc./2020 11:55, modifié 2 fois.
Avatar de l’utilisateur
falsam
Messages : 7317
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Polygons Editor (75%)

Message par falsam »

Hello Kernadec.

SPH n'utilise pas OpenScreen(). InitKeyboard() ne fonctionne pas avec OpenGLGadget()

J'aurais bien aimé d'ailleurs que ca soit le cas :wink:

Edit : Petite correction. InitKeyboard() retourne bien #True mais la fonction KeyboardPushed() (ou Released) génère une erreur de compilation.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Polygons Editor (75%)

Message par SPH »

kernadec a écrit :heureusement, il y a AddKeyboardShortcut()
Aïe :twisted:

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Polygons Editor (75%)

Message par kernadec »

bsr
Pour utiliser les touches clavier et la souris avec OpenGLGadget
c 'est écrit dans la doc :mrgreen:
voici un exemple avec Controle + clic souris gauche

Code : Tout sélectionner

OpenWindow(0, 0, 0, 530, 320, "OpenGL Gadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenGLGadget(1, 0, 0,  530, 320,#PB_OpenGL_Keyboard)

Repeat
  Event = WaitWindowEvent()
  
  If  GetGadgetAttribute(1, #PB_OpenGL_Control) | GetGadgetAttribute(1, #PB_EventType_LeftClick)
    End    
  EndIf
  
ForEver
voici un bel exemple de transparence sous OpenGL 2ème code : appelPi du forum anglais
https://www.purebasic.fr/english/viewto ... 36&t=64547


Cordialement
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Polygons Editor (75%)

Message par SPH »

Tiens, je viens de m'apercevoir d'un truc plutot embetant : on ne peux pas faire de polygones "creux".
Par exemple, essayez de faire une lune :
Image
http://xmas.free.fr/lune.bmp
Ca viens de où ?

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Avatar de l’utilisateur
kernadec
Messages : 1606
Inscription : ven. 25/avr./2008 11:14

Re: Polygons Editor (75%)

Message par kernadec »

bjr SPH
pour test voilà une modification des commandes clavier :
touche controle + r = rouge moins
touche shift + R = rouge plus
touche controle + v = vert moins
touche shift + V = vert plus
touche controle + b = bleu moins
touche shift + B = bleu plus
touche controle + a = alpha moins
touche shift + A = alpha plus
touche r = rouge moyen
touche v =vert moyen
touche b = bleu moyen
cordialement

Code : Tout sélectionner

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ANOTHER EARTH (SPH2020) ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Global valeur_rouge.l, valeur_verte.l, valeur_bleue.l, valeur_alpha.l, taux.d
Global rouge.d, vert.d, bleu.d, alpha.d, Aide.s, h.l
taux = 1 / 255
h.l = 20

If OpenWindow(0, 0, 0, 0, 0, "Polygons_Maker",#PB_Window_Maximize|#PB_Window_BorderLess)=0
  
  Beep_(500,250) : Delay(150) : Beep_(500,250)
  Debug ("OpenWindow() impossible")
  End
EndIf
SetWindowColor(0, #Black)
GL=OpenGLGadget(1,0,28,WindowWidth(0),WindowHeight(0)-28)
If GL=0
  Beep_(500,250) : Delay(150) : Beep_(500,250)
  Debug ("OpenGLGadget() impossible")
  End
EndIf


Procedure help()
  
  StartDrawing(WindowOutput(0))
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 0  , "touche controle + r = rouge moins"   ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 1  , "touche shift + R = rouge plus"       ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 2  , "touche controle + v = vert moins"    ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 3  , "touche shift + V = vert plus"        ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 4  , "touche controle + b = bleu moins"    ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 5  , "touche shift + B = bleu plus"        ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 6  , "touche controle + a = alpha moins"   ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 7  , "touche shift + A = alpha plus"       ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 8  , "touche r = rouge moyen"              ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 9  , "touche v = vert moyen"                ,#White,#Black)
  DrawText(WindowWidth(0) - 250, WindowX(0) + 28 + h * 10 , "touche b = bleu moyen"               ,#White,#Black)
  StopDrawing()
  
EndProcedure

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

glOrtho_(0,1920,1080,0,-1,1)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(0)

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


AddKeyboardShortcut(0,  #PB_Shortcut_Escape, 666)
AddKeyboardShortcut(0,  #PB_Shortcut_H, 8) ; hide/show

AddKeyboardShortcut(0,  #PB_Shortcut_Add, 100) ; alpha+0.01
AddKeyboardShortcut(0,  #PB_Shortcut_Subtract, 101) ; alpha-0.01
AddKeyboardShortcut(0,  #PB_Shortcut_Multiply, 102) ; alpha=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_Divide, 103)   ; NO alpha
AddKeyboardShortcut(0,  #PB_Shortcut_Space, 505)    ; aide

AddKeyboardShortcut(0,  #PB_Shortcut_R, 501) ; rouge=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_V, 502) ; vert=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_B, 503) ; bleu=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_A, 500) ; bleu=0.5
AddKeyboardShortcut(0,  #PB_Shortcut_N, 504) ; rouge=0.5

AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_R, Asc("r"))  ;control + 114
AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_V, Asc("v"))  ;control + 118
AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_B, Asc("b"))  ;control + 098
AddKeyboardShortcut(0, #PB_Shortcut_Control | #PB_Shortcut_A, Asc("a"))  ;control + 097
AddKeyboardShortcut(0, #PB_Shortcut_Shift | #PB_Shortcut_R, Asc("R"))    ;shift + 082
AddKeyboardShortcut(0, #PB_Shortcut_Shift | #PB_Shortcut_V, Asc("V"))    ;shift + 086
AddKeyboardShortcut(0, #PB_Shortcut_Shift | #PB_Shortcut_B, Asc("B"))    ;shift + 066
AddKeyboardShortcut(0, #PB_Shortcut_Shift | #PB_Shortcut_A, Asc("A"))    ;shift + 065

hide=0
alpha = 1
rouge = 0.5
vert = 0.5
bleu = 0.5
no_alpha=0

Dim poly_x(1000)
Dim poly_y(1000)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;




Repeat
  
  
  glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  
  
  glBegin_(#GL_POLYGON)
  glColor4f_(1,1,1,1)
  glVertex2f_(22,11)
  glVertex2f_(500,66)
  glVertex2f_(33,755)
  glEnd_()
  
  glEnable_(#GL_BLEND)
  glBlendFunc_(#GL_SRC_ALPHA,#GL_ONE_MINUS_SRC_ALPHA)
  glBegin_(#GL_POLYGON)
  glColor4f_(0,1,1,0.5)
  ;glColor4f_(1,1,1,1)
  glVertex2f_(400,600)
  glVertex2f_(200,600)
  glVertex2f_(300,100)
  glEnd_()
  
  
  ;;;;;;;;;;;;;;;;;;;
  
  
  Event = WaitWindowEvent()
  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
              Beep_(1500,55) ;Debug "Clic avec le bouton gauche de la souris"
              hide=0
              poly_x(0)+1
              poly_x(poly_x(0))=Resx
              poly_y(poly_x(0))=Resy
              
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            Case #PB_EventType_RightDoubleClick
              If poly_x(0)>0
                Beep_(500,400) ;: Debug "Double-clic avec le bouton droit de la souris"
                Dim poly_x(1000)
                Dim poly_y(1000)
              EndIf
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
            Case #PB_EventType_RightClick
              If poly_x(0)>0
                Beep_(500,55) ;Debug "Clic avec le bouton droit de la souris"
                poly_x(0)-1
              EndIf
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
            Case #PB_EventType_MiddleButtonDown
              Resx = poly_x(poly_x(0))
              Resy = poly_y(poly_x(0))
              hide+1 : hide%2
              ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;             
          EndSelect
          
      EndSelect
    Case #PB_Event_Menu
      Select EventMenu()
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;       
        Case 666
          End
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 8
          hide+1 : hide%2
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 100
          alpha+0.01
          If alpha>1
            alpha=1
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 101
          alpha-0.01
          If alpha<0
            alpha=0
          EndIf
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 102
          alpha=0.5
          no_alpha=0
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
        Case 103
          no_alpha+1 : no_alpha%2                
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;   
        Case 505
          help()
          MessageRequester("      Informations       ","Effacer l' affichage des Commandes Clavier ",#PB_MessageRequester_Ok)          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
        Case Asc("r")     ; control "r" = moins ,114 
          valeur_rouge = rouge * 255
          valeur_rouge = valeur_rouge - 1
          If valeur_rouge < 0   : valeur_rouge = 0  : EndIf
          rouge = valeur_rouge * taux
          ;Debug "rouge:" + valeur_rouge + " : " + rouge
        Case Asc("v")     ; control "v" = moins ,118
          valeur_verte = vert * 255
          valeur_verte = valeur_verte - 1
          If valeur_verte < 0    : valeur_verte = 0   : EndIf
          vert = valeur_verte * taux
          ;Debug "Vert:" + valeur_verte + " : " + vert
        Case Asc("b")     ; control "b" = moins ,098
          valeur_bleue = bleu * 255
          valeur_bleue = valeur_bleue - 1
          If valeur_bleue < 0    : valeur_bleue = 0   : EndIf
          bleu = valeur_bleue * taux
          ;Debug "Bleu:" + valeur_bleue + " : " + bleu
        Case Asc("a")     ; control "a" = moins ,097
          valeur_alpha  = alpha * 255
          valeur_alpha = valeur_alpha - 1
          If valeur_alpha < 0   : valeur_alpha = 255     : EndIf
          alpha = valeur_alpha * taux
          ;Debug "alpha:" + valeur_alpha + " : " + alpha
        Case Asc("R")     ; Shift   "R", = plus ,082
          valeur_rouge = rouge * 255
          valeur_rouge = valeur_rouge + 1
          If valeur_rouge > 255 : valeur_rouge = 255    : EndIf
          rouge = valeur_rouge * taux
          ;Debug "rouge:" + valeur_rouge + " : " + rouge
        Case Asc("V")     ; Shift   "V" = plus ,086
          valeur_verte = vert * 255
          valeur_verte = valeur_verte + 1
          If valeur_verte > 255  : valeur_verte = 255   : EndIf
          vert = valeur_verte * taux
          ;Debug "Vert:" + valeur_verte + " : " + vert
        Case Asc("B")     ; Shift   "B" = plus ,066
          valeur_bleue = bleu * 255
          valeur_bleue = valeur_bleue + 1
          If valeur_bleue > 255   : valeur_bleue = 255  : EndIf
          bleu = valeur_bleue * taux
          ;Debug "Bleu:" + valeur_bleue + " : " + bleu
        Case Asc("A")     ; Shift   "A" = plus ,065
          valeur_alpha  = alpha * 255
          valeur_alpha = valeur_alpha + 1
          If valeur_alpha > 255  : valeur_alpha = 255   : EndIf
          alpha = valeur_alpha * taux
          ;Debug "alpha:" + valeur_alpha + " : " + alpha
        Case 501 ; "r" rouge moyen
          rouge = 0.5 : vert = 0   : bleu = 0   : alpha = 1 : valeur_rouge = rouge * 255
          ;Debug "rouge RVBA:" + valeur_rouge + " : " + valeur_verte + " : " + valeur_bleue + " : " + valeur_alpha
        Case 502 ; "v" vert moyen
          rouge = 0   : vert = 0.5 : bleu = 0   : alpha = 1 : valeur_verte = vert * 255
          ;Debug "vert RVBA:" + valeur_rouge + " : " + valeur_verte + " : " + valeur_bleue + " : " + valeur_alpha
        Case 503; "b" bleu moyen
          rouge = 0   : vert = 0   : bleu = 0.5 : alpha = 1 : valeur_bleue = bleu * 255
          ;Debug "bleu RVBA:" + valeur_rouge + " : " + valeur_verte + " : " + valeur_bleue + " : " + valeur_alpha
        Case 500 ; "a" alpha
          alpha = 1 : valeur_alpha  = alpha * 255
          ;Debug "alpha RVBA:" + valeur_rouge + " : " + valeur_verte + " : " + valeur_bleue + " : " + valeur_alpha
        Case 504 ; "n" noire
          rouge = 0   : vert = 0   : bleu = 0 : alpha = 1 : valeur_bleue = 0 : valeur_verte = 0 : valeur_rouge = 0 : valeur_alpha = alpha * 255
          ;Debug "alpha RVBA:" + valeur_rouge + " : " + valeur_verte + " : " + valeur_bleue + " : " + valeur_alpha   
          ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;         
      EndSelect
  EndSelect
  
  ;;;;;;;;;;;;;;;;
  
  StartDrawing(WindowOutput(0))
  DrawText(WindowWidth(0) - 400, WindowX(0) + 12  , "                                                                                                                 ",#Black,#Black)
  DrawText(WindowWidth(0) - 400, WindowX(0) + 12  , "RVBA( " + Str(rouge * 255) + " , " + Str(vert * 255) + " , " + Str(bleu * 255) + " , " + Str(alpha * 255) + " )" ,#White,#Black)
  DrawText(WindowWidth(0) - 200, WindowX(0) + 12  ,  "AIDE = Touche Espace" ,#Green,#Black)
  StopDrawing()
  ;;;;;;;;;;;;;;;;
  
  
  If poly_x(0) > 1; And 0=1
    glBegin_(#GL_POLYGON)
    If no_alpha=1
      glColor4f_(rouge,vert,bleu,1)
    Else
      glColor4f_(rouge,vert,bleu,alpha)
      ;Debug "RVBA:" + rouge + " : " + vert + " : " + bleu + " : " + alpha
    EndIf
    
    For i=1 To poly_x(0)
      glVertex2f_(poly_x(i),poly_y(i))    
    Next
    If hide=0
      glVertex2f_(Resx,Resy) ;: Debug Resx : Debug Resy : Debug "----------"
    EndIf
    
    glEnd_()
  EndIf
  
  SetGadgetAttribute(1,#PB_OpenGL_FlipBuffers,#True)
  
  
  ;;;;;;;;;;;;;;;;
  ; mode clavier et souris   touche "Alt + Clic Souris Gauche
  ;   If  GetGadgetAttribute(1,#PB_OpenGL_Alt) | GetGadgetAttribute(1, #PB_EventType_LeftClick)
  ;     End   
  ;   EndIf
  ;   
ForEver
Dernière modification par kernadec le sam. 05/déc./2020 7:11, modifié 4 fois.
Avatar de l’utilisateur
SPH
Messages : 4937
Inscription : mer. 09/nov./2005 9:53

Re: Polygons Editor (75%)

Message par SPH »

Merci kernadec 8)

Mon probleme n'est plus au menu de reglages mais au tracage de polygones concaves (croissant de lune) :idea: :arrow: :?

!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.12LTS- 64 bits
Répondre