Page 1 of 1

OpenGL : Abstract 3

Posted: Wed Sep 18, 2024 3:15 am
by threedslider
Another code as fun too :)

Code: Select all

;;;
;;;  Created by threedslider -- 18/09/2024
;;;

move.f = 0
move2.f = 0

Procedure Abstract(x)
  Shared move
  Shared move2
  
      
    
      slide_x.f =  move * 60 * Cos(x+move2)
      slide_y.f =   60 * Sin(x+move2/50.0)
      
      If move >= 1.0
        move = 1.0
      EndIf
      
      
      glBegin_(#GL_QUADS)
        
        glColor3f_(1.0, 0.3, 1.0)
        glVertex3f_( -slide_x*0.3,  -slide_y*0.3 , 0.3) 
        glVertex3f_( -slide_x*0.3,  slide_y*0.3 , 0.3) 
        glVertex3f_( slide_x*0.3,  slide_y*0.3 , 0.3) 
        glVertex3f_( slide_x*0.3,  -slide_y*0.3 , 0.3) 
     
    glEnd_()
    
EndProcedure
  

InitSprite()
InitKeyboard()


OpenWindow(0, 0, 0, 800/DesktopResolutionX(), 600/DesktopResolutionY(), "OpenGL : Abstract 3", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)


glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_() 
gluPerspective_(45.0, 800/600, 1.0, 60.0)
glMatrixMode_(#GL_MODELVIEW)

glTranslatef_(0, 0, -50)
glShadeModel_(#GL_SMOOTH)
glPolygonMode_(#GL_FRONT_AND_BACK, #GL_LINE)
glEnable_(#GL_LIGHT0)
glEnable_(#GL_LIGHTING)
glEnable_(#GL_COLOR_MATERIAL)
glEnable_(#GL_DEPTH_TEST)
glEnable_(#GL_CULL_FACE)   
glViewport_(0, 0, 800, 600)

x.i = 0

Repeat
glClearColor_(0.1, 0.1, 0.1, 0) ; background color
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  Repeat
    event = WindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        quit = 1
     EndSelect
   Until event = 0
   
   
   
    For x = 0 To 90
      
      move  = move +  1/100000
      move2 = move2 + 1/100000
      
    Abstract(x)  
       
    Next 
   
       
   
 FlipBuffers()
 
 ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape) Or quit = 1
Happy coding !

Re: OpenGL : Abstract 3

Posted: Wed Sep 18, 2024 3:30 am
by threedslider
Abstract 3-b

Code: Select all

;;;
;;;  Created by threedslider -- 18/09/2024
;;;

move.f = 0
move2.f = 0

Procedure Abstract(x)
  Shared move
  Shared move2
  
      
    
      slide_x.f =   60 * Cos(x+move2) * Sin(x-move)
      slide_y.f =   60 * Sin(x+move2/50.0)
      
      If move >= 1.0
        move = 1.0
      EndIf
      
      
      glBegin_(#GL_QUADS)
        
        glColor3f_(1.0, 0.3, 1.0)
        glVertex3f_( -slide_x*0.3,  -slide_y*0.3 , 0.3) 
        glVertex3f_( -slide_x*0.3,  slide_y*0.3 , 0.3) 
        glVertex3f_( slide_x*0.3,  slide_y*0.3 , 0.3) 
        glVertex3f_( slide_x*0.3,  -slide_y*0.3 , 0.3) 
     
    glEnd_()
    
EndProcedure
  

InitSprite()
InitKeyboard()


OpenWindow(0, 0, 0, 800/DesktopResolutionX(), 600/DesktopResolutionY(), "OpenGL : Abstract 3-b", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600)


glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_() 
gluPerspective_(45.0, 800/600, 1.0, 60.0)
glMatrixMode_(#GL_MODELVIEW)

glTranslatef_(0, 0, -50)
glShadeModel_(#GL_SMOOTH)
glPolygonMode_(#GL_FRONT_AND_BACK, #GL_LINE)
glEnable_(#GL_LIGHT0)
glEnable_(#GL_LIGHTING)
glEnable_(#GL_COLOR_MATERIAL)
glEnable_(#GL_DEPTH_TEST)
glEnable_(#GL_CULL_FACE)   
glViewport_(0, 0, 800, 600)

x.i = 0

Repeat
glClearColor_(0.1, 0.1, 0.1, 0) ; background color
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  Repeat
    event = WindowEvent()
    Select Event
      Case #PB_Event_CloseWindow
        quit = 1
     EndSelect
   Until event = 0
   
   
   
    For x = 0 To 90
      
      move  = move +  1/100000
      move2 = move2 + 1/100000
      
    Abstract(x)  
       
    Next 
   
       
   
 FlipBuffers()
 
 ExamineKeyboard()
 
Until KeyboardPushed(#PB_Key_Escape) Or quit = 1