
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