
Code : Tout sélectionner
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Coded with Purebasic v.6.3 by threedslider 12/08/2023
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
move.f = 0
Procedure spiral()
Shared move
multiplier.f = 100.0 * #PI
radius.f = 20
glBegin_(#GL_LINE_STRIP)
For mult = 0 To 360
spiral_x.f = radius * (Cos(move*0.1+mult*multiplier*0.1/360.0))/3.0
spiral_y.f = radius * (Sin(move*0.1+mult*multiplier*0.1/360.0))/3.0
glColor3f_(mult/10.0, mult/100.0, mult/100.0)
glVertex3f_(spiral_x*0.3, spiral_y*0.3 , 0.0)
radius = radius + 1.0
Next
glEnd_()
EndProcedure
InitSprite()
InitKeyboard()
OpenWindow(1, 0,0,800,600,"Spiral in color", #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(1),0,0,800,600,0,0,0)
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
gluPerspective_(45.0, 800/600, 1.0, 60.0)
glMatrixMode_(#GL_MODELVIEW)
glTranslatef_(0, 0, -50)
glShadeModel_(#GL_SMOOTH)
glEnable_(#GL_LIGHT0)
glEnable_(#GL_LIGHTING)
glEnable_(#GL_COLOR_MATERIAL)
glEnable_(#GL_DEPTH_TEST)
glEnable_(#GL_CULL_FACE)
glViewport_(0, 0, 800, 600)
glClearColor_(0.1, 0.1, 0.1, 0) ; background color
Repeat
ExamineKeyboard()
event = WindowEvent()
ClearScreen(RGB(0,0,0))
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
For x = 0 To 500
move + 1/1000
spiral()
Next
FlipBuffers()
Until event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
End