the special preparations are characterized by the usage of mysterious functions such as "wglCreateContext(hDC)" , "SetupPixelFormat();"PIXELFORMATDESCRIPTOR" ... etc. they are frustrating me and surely frustrating some users.
while in purebasic you can learn OpenGL focusing only on the OpenGL functions. together with everyday normal purebasic functions
this subject are discussed here before by other users, and i just refresh it in another way.
before presenting some examples i suggest to download the glu.pbi in the package "OpenGL-Engine-Linux.tar.gz" provided by remi_meier at the end of this thread http://www.purebasic.fr/english/viewtop ... 15&t=30065 . the glu.pbi will work also for windows. thank for remi_meier for keeping these files alive many years. used here in the Fourth example only
Example 1 : the same cube example in "PureBasic\Examples\Sources - Advanced\OpenGL Cube\OpenGL.pb" but deleting all the mysterious functions mentioned above
Code: Select all
InitKeyboard()
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  CompilerIf Subsystem("OpenGL") = #False
    MessageRequester("Error", "Please set the Library subsystem to OpenGL from IDE : Compiler... Compiler Options")
    End
  CompilerEndIf
CompilerEndIf
If InitSprite() = 0
  MessageRequester("Error", "Can't open screen & sprite environment!")
  End
EndIf
OpenWindow(0, 0, 0, 800, 600, "rotating cube", #PB_Window_SystemMenu | #PB_Window_Invisible)
SetWindowColor(0, 14403509)
ContainerGadget(0, 5, WindowHeight(0)-50, 250, 60, #PB_Container_Raised)
ButtonGadget(1, 5, 5, 55, 20, "Stop/Run")
TrackBarGadget(2, 60, 10, 90, 20, 0, 200)
TextGadget(3, 150, 10, 100, 25, "0")
CloseGadgetList()
SetGadgetState(0, 0)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0)-50, WindowHeight(0)-60, 0, 0, 0)
HideWindow(0, #False)
Global RollAxisX.f
Global RollAxisY.f
Global RollAxisZ.f
Global RotateSpeedX.f
Global RotateSpeedY.f
Global RotateSpeedZ.f
Global ZoomFactor.f
Global running = 1
glClearColor_ (0.0, 0.0, 0.0, 0.0);
glShadeModel_ (#GL_SMOOTH)
glEnable_(#GL_LIGHTING);
glEnable_(#GL_LIGHT0);
glEnable_(#GL_DEPTH_TEST);
glColorMaterial_(#GL_FRONT,  #GL_AMBIENT_AND_DIFFUSE)
glEnable_(#GL_COLOR_MATERIAL) ; color tracking
glEnable_(#GL_NORMALIZE)
Procedure.l Cube_Render()
 glPushMatrix_()                  ; Save the original Matrix coordinates
  glMatrixMode_(#GL_MODELVIEW)
  glTranslatef_(0, 0, ZoomFactor)  ;  move it forward a bit
  glRotatef_ (RollAxisX, 1.0, 0, 0) ; rotate around X axis
  glRotatef_ (RollAxisY, 0, 1.0, 0) ; rotate around Y axis
  glRotatef_ (RollAxisZ, 0, 0, 1.0) ; rotate around Z axis
 
  RollAxisX + RotateSpeedX 
  RollAxisY + RotateSpeedY 
  RollAxisZ + RotateSpeedZ 
  ; clear framebuffer And depth-buffer
  glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  ; draw the faces of a cube
  
  ; draw colored faces
  glDisable_(#GL_LIGHTING)
  glBegin_  (#GL_QUADS)
  
  ; Build a face, composed of 4 vertex ! 
  ; glBegin() specify how the vertexes are considered. Here a group of
  ; 4 vertexes (GL_QUADS) form a rectangular surface.
  ; Now, the color stuff: It's r,v,b but with float values which
  ; can go from 0.0 To 1.0 (0 is .. zero And 1.0 is full intensity) 
  
  glNormal3f_ (0,0,1.0)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (0.5,0.5,0.5)   
  glColor3f_  (0,1.0,1.0)         
  glVertex3f_ (-0.5,0.5,0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (-0.5,-0.5,0.5)
  glColor3f_  (0,0,0)
  glVertex3f_ (0.5,-0.5,0.5) 
  ; The other face is the same than the previous one 
  ; except the colour which is nice blue To white gradiant
  glNormal3f_ (0,0,-1.0)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (-0.5,-0.5,-0.5)
  glColor3f_  (0,0,1.0)
  glVertex3f_ (-0.5,0.5,-0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (0.5,0.5,-0.5)
  glColor3f_  (1.0,1.0,1.0)
  glVertex3f_ (0.5,-0.5,-0.5)
  
  glEnd_()
  
  ; draw shaded faces
  glEnable_(#GL_LIGHTING)
  glEnable_(#GL_LIGHT0)
  glBegin_ (#GL_QUADS)
  glNormal3f_ (   0, 1.0,   0)
  glVertex3f_ ( 0.5, 0.5, 0.5)
  glVertex3f_ ( 0.5, 0.5,-0.5)
  glVertex3f_ (-0.5, 0.5,-0.5)
  glVertex3f_ (-0.5, 0.5, 0.5)
  glNormal3f_ (0,-1.0,0)
  glVertex3f_ (-0.5,-0.5,-0.5)
  glVertex3f_ (0.5,-0.5,-0.5)
  glVertex3f_ (0.5,-0.5,0.5)
  glVertex3f_ (-0.5,-0.5,0.5)
  glNormal3f_ (1.0,0,0)
  glVertex3f_ (0.5,0.5,0.5)
  glVertex3f_ (0.5,-0.5,0.5)
  glVertex3f_ (0.5,-0.5,-0.5)
  glVertex3f_ (0.5,0.5,-0.5)
  glNormal3f_ (-1.0,   0,   0)
  glVertex3f_ (-0.5,-0.5,-0.5)
  glVertex3f_ (-0.5,-0.5, 0.5)
  glVertex3f_ (-0.5, 0.5, 0.5)
  glVertex3f_ (-0.5, 0.5,-0.5)
  glEnd_()
  glPopMatrix_()
  glFinish_()
    
EndProcedure
HideWindow(0, #False)
RotateSpeedX = 2.0   ; The speed of the rotation For the 3 axis
RotateSpeedY = 2
RotateSpeedZ = 2.0
ZoomFactor = 0      ; Distance of the camera. Negative value = zoom back
glViewport_(0, 0, WindowWidth(0), WindowHeight(0))
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
gluPerspective_(30.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 500.0)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_ ()
; viewing transformation
glTranslatef_(0.0, 2.0, -1.0);
gluLookAt_(0,5,15,0,1.5,0,0,1,0);
  
  Repeat
    EventID = WindowEvent()
    Select EventID
      Case #PB_Event_Gadget
          If EventGadget() = 1
            running ! 1
            RotateSpeedX = running
            RotateSpeedY = running
            RotateSpeedZ = running
          EndIf
          If EventGadget() = 2
            ZoomFactor = (GetGadgetState(2)/200)*5
           
           SetGadgetText(3, Str(ZoomFactor))
          EndIf     
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
    ExamineKeyboard()
     
  Cube_Render()
  FlipBuffers()
  Delay(20)
 
  Until Quit = 1 Or KeyboardPushed(#PB_Key_Escape)
End
Code: Select all
InitKeyboard()
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  CompilerIf Subsystem("OpenGL") = #False
    MessageRequester("Error", "Please set the Library subsystem to OpenGL from IDE : Compiler... Compiler Options")
    End
  CompilerEndIf
CompilerEndIf
If InitSprite() = 0
  MessageRequester("Error", "Can't open screen & sprite environment!")
  End
EndIf
OpenWindow(0, 0, 0, 800, 600, "rotating Helix", #PB_Window_SystemMenu | #PB_Window_Invisible)
SetWindowColor(0, 14403509)
ContainerGadget(0, 5, WindowHeight(0)-50, 250, 60, #PB_Container_Raised)
ButtonGadget(1, 5, 5, 55, 20, "Stop/Run")
TrackBarGadget(2, 60, 10, 90, 20, 0, 200)
TextGadget(3, 150, 10, 100, 25, "0")
CloseGadgetList()
SetGadgetState(0, 0)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0)-50, WindowHeight(0)-60, 0, 0, 0)
HideWindow(0, #False)
Global RollAxisX.f
Global RollAxisY.f
Global RollAxisZ.f
Global RotateSpeedX.f
Global RotateSpeedY.f
Global RotateSpeedZ.f
Global ZoomFactor.f ;Distance of the camera
Global running = 1
Global angle.f
Global rot.f = 3
Procedure.l Cube_Render()
 glPushMatrix_()                  ; Save the original Matrix coordinates
  glMatrixMode_(#GL_MODELVIEW)
  glTranslatef_(0, 0, -120)  ;  move it forward a bit
  glRotatef_ (RollAxisX, 1.0, 0, 0) ; rotate around X axis
  glRotatef_ (RollAxisY, 0, 1.0, 0) ; rotate around Y axis
  glRotatef_ (RollAxisZ, 0, 0, 1.0) ; rotate around Z axis
 
  RollAxisX + RotateSpeedX 
  RollAxisY + RotateSpeedY 
  RollAxisZ + RotateSpeedZ 
  ; clear framebuffer And depth-buffer
  glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  
  glDisable_(#GL_LIGHTING)
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT) ;Clear The Screen And The Depth Buffer
  glLoadIdentity_() ;Reset The View
 
  glViewport_(0, 0, WindowWidth(0), WindowHeight(0))
  glMatrixMode_(#GL_PROJECTION)
  glLoadIdentity_()
  ;gluPerspective_(90.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 1000.0)
  glFrustum_(-10.0, 10.0, -10.0, 10.0, 10.0, 1000.0); 
 
  
   R.f = 30.0; // Radius of helix.
   t.f = -10*#PI; // Angle parameter along helix.
   glClear_(#GL_COLOR_BUFFER_BIT);
   glColor3f_(1.0, 0.7, 0.0);
   glPushMatrix_();
   ;The Trick: To align the axis of the helix along the y-axis prior To rotation
   ;And then Return it To its original location.
   glTranslatef_(0.0, 0.0, -120+ZoomFactor);
   glRotatef_(angle, 1, 1, 1);
   glTranslatef_(0.0, 0.0, 60.0);
   ;glPointSize_(5);
   angle.f + rot
   ;//GL_POINTS
   ;//GL_LINE_STRIP
   glBegin_(#GL_LINE_STRIP);
      
   While t <= 10 * #PI
     
       glVertex3f_(R * Cos(t), t, R * Sin(t) - 60.0);
       t = t+(#PI/40.0)
      
   
   Wend
 
 glEnd_();
 glPopMatrix_();
 
 glFinish_()
 
EndProcedure
HideWindow(0, #False)
RotateSpeedX = 2.0   ; The speed of the rotation For the 3 axis
RotateSpeedY = 2.0
RotateSpeedZ = 2.0
  Repeat
    EventID = WindowEvent()
    Select EventID
      Case #PB_Event_Gadget
          If EventGadget() = 1
            running ! 1
            rot = 3*running
          EndIf
          If EventGadget() = 2
           ZoomFactor = (GetGadgetState(2)/200)*100
           SetGadgetText(3, Str(ZoomFactor))
          EndIf     
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
    ExamineKeyboard()
     
  Cube_Render()
  FlipBuffers()
  Delay(20)
 
  Until Quit = 1 Or KeyboardPushed(#PB_Key_Escape)
End
Code: Select all
InitKeyboard()
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  CompilerIf Subsystem("OpenGL") = #False
    MessageRequester("Error", "Please set the subsystem to OpenGL")
    End
  CompilerEndIf
CompilerEndIf
If InitSprite() = 0
  MessageRequester("Error", "Can't open screen & sprite environment!")
  End
EndIf
OpenWindow(0, 0, 0, 640, 480, "press space key to switch On/Off the fan rotation", #PB_Window_SystemMenu | #PB_Window_Invisible)
SetWindowColor(0, 0)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0), 0, 0, 0)
HideWindow(0, #False)
Global running.b = 0;
Global angle_step.f = 0.3
Global angle_direction.f
lngh.f : width.f : depth.f
glClearColor_ (0.0, 0.0, 0.0, 0.0);
glShadeModel_ (#GL_SMOOTH)
glEnable_(#GL_LIGHTING);
glEnable_(#GL_LIGHT0);
glEnable_(#GL_DEPTH_TEST);
glColorMaterial_(#GL_FRONT,  #GL_AMBIENT_AND_DIFFUSE)
glEnable_(#GL_COLOR_MATERIAL) ; color tracking
glEnable_(#GL_NORMALIZE)
Procedure.l blade(lngh.f, width.f, depth.f)
   a.f = lngh: b.f = width: c.f = depth
       
glBegin_(#GL_QUADS);
; Top face of box
    glColor3f_(1.0, 0.0, 0.0) ; red blades !
    glNormal3f_(0.0, 1.0, 0.0)
   
    glVertex3f_(a, b, -c);     // Top right vertex (Top of cube)
    glVertex3f_(-a, b, -c);    //Top left vertex (Top of cube)
    glVertex3f_(-a, b, c);     // Bottom left vertex (Top of cube)
    glVertex3f_(a, b, c);      // Bottom right vertex (Top of cube)
    ;Bottom face of box
   
    glNormal3f_(0.0, -1.0, 0.0)   
    glVertex3f_(a, -b, -c);     // Top right vertex (Bottom of cube)
    glVertex3f_(-a, -b, -c);    // Top left vertex (Bottom of cube)
    glVertex3f_(-a, -b, c);   // Bottom left vertex (Bottom of cube)
    glVertex3f_( a, -b, c);   // Bottom right vertex (Bottom of cube)
   
    ;Front of box
   
    glNormal3f_(0.0, 0.0, 1.0)     
    glVertex3f_(a, b, c);      // Top right vertex (Front)
    glVertex3f_(-a, b, c);     // Top left vertex (Front)
    glVertex3f_(-a, -b, c);    // Bottom left vertex (Front)
    glVertex3f_(a, -b, c);     // Bottom right vertex (Front)
   
    ;Back of box
   
    glNormal3f_(0.0, 0.0, -1.0)     
    glVertex3f_(a, -b, -c);    // Bottom right vertex (Back)
    glVertex3f_(-a, -b, -c);   // Bottom left vertex (Back)
    glVertex3f_(-a, b, -c);    // top left vertex (Back)
    glVertex3f_(a, b, -c);     // Top right vertex (Back)
   
    ;Left of box
   
    glNormal3f_(-1.0, 0.0, 0.0)         
    glVertex3f_(-a, b, c);     // Top right vertex (Left)
    glVertex3f_(-a, b, -c);    // Top left vertex (Left)
    glVertex3f_(-a, -b, -c);   // Bottom left vertex (Left)
    glVertex3f_(-a, -b, c);    // Bottom vertex (Left)
   
    ;Right of box
       
    glNormal3f_(1.0, 0.0, 0.0)   
    glVertex3f_(a, b, -c);     // Top right vertex (Right)
    glVertex3f_(a, b, c);      // Top left vertex (Right)
    glVertex3f_(a, -b, c);     // Bottom left vertex (Right)
    glVertex3f_(a, -b, -c);    // Bottom right vertex (Right)
   
    ;End drawing the box
    glEnd_();
    ;Return TRUE;
           
EndProcedure
Procedure.l Fan_Render(spin.f)
glPushMatrix_();
  glColor3f_(1.0, 1.0, 0.0)
 
  ;Fan
  glPushMatrix_();
  ;Fan Base:
        qobj = gluNewQuadric_();
      gluQuadricDrawStyle_(qobj, #GL_FILL); /* smooth shaded */
      gluQuadricNormals_(qobj, #GL_SMOOTH);
      glScalef_( 4 , 0.5 , 4 );
      ;glEnable_(#GL_NORMALIZE);
      ;Sphere With radius 0.25 then scaled
      gluSphere_(qobj, 0.25, 20, 20);
  glPopMatrix_();
   
   ;Fan stand:
  glPushMatrix_();
      gluQuadricDrawStyle_(qobj, #GL_FILL); /* flat shaded */
      gluQuadricNormals_(qobj, #GL_FLAT);
      glRotatef_(-90, 1.0, 0.0, 0.0);
      gluCylinder_(qobj, 0.125, 0.125, 3, 16, 10);
   
  glPopMatrix_();
   
    ;Fan Motor:
    glRotatef_(angle_direction, 0.0, 1.0, 0.0)
  glPushMatrix_();
     gluQuadricDrawStyle_(qobj, #GL_FILL); /* smooth shaded */
     gluQuadricNormals_(qobj, #GL_SMOOTH);
      glTranslatef_(0.0, 2.5, 0.0);
      glScalef_( 0.5, 0.5, 1);
      ;glEnable_(#GL_NORMALIZE);
      gluSphere_(qobj, 1 , 20 , 20 );
  glPopMatrix_();
   ;Blades construction
   glTranslatef_(0.0, 2.5, 0.5)
   ;glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  glRotatef_(spin, 0.0, 0.0, 1.0 );
   For i = 1 To 360  Step 60
   
    glPushMatrix_();
      glRotatef_( i, 0.0, 0.0, 1.0 );
      glTranslatef_(1.2, 0.0, 0.0);
      glRotatef_( -45, 1.0, 0.0, 0.0 );
      glShadeModel_(#GL_FLAT);   
      glEnable_(#GL_DEPTH_TEST);
      glPushMatrix_();
      ;calling blade ie: drawing the Blade of the fan*/
      blade(0.8,0.3,0.01);
     glPopMatrix_();
    glPopMatrix_();     
   Next
       
    
glPopMatrix_();
EndProcedure
Procedure.f Fan_Physics()
   Static spin.f
   Static speed.f
   If running = 1
     speed = speed + 1
     angle_direction = angle_direction + angle_step
    If angle_direction > 110
      angle_step = -0.3
      ElseIf angle_direction < 0
           angle_step = 0.3
    EndIf
   EndIf
   If speed > 360.0: speed = 360.0: EndIf
   If running = 0 :speed = speed - 1.8: EndIf
  If speed < 0: speed = 0: EndIf
  spin = spin + speed/100
  ProcedureReturn spin
     
EndProcedure
HideWindow(0, #False)
  Procedure.l Fan_Run()
  glViewport_(0, 0, WindowWidth(0), WindowHeight(0))
  glMatrixMode_(#GL_PROJECTION)
  glLoadIdentity_()
  gluPerspective_(30.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 500.0)
  glMatrixMode_(#GL_MODELVIEW)
  glLoadIdentity_()
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
   glLoadIdentity_ ()
   ; viewing transformation
   glTranslatef_(0.0, 0.0, -6.0);
   gluLookAt_(5,5,5,0,1.5,0,0,1,0);
   spin.f = Fan_Physics();
   
   Fan_Render(spin);
 
EndProcedure
While Quit.b = 0
  Repeat
    EventID = WindowEvent()
    Select EventID
           
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
    ExamineKeyboard()
  If KeyboardReleased(#PB_Key_Space)
      running ! 1
   EndIf
 
  Fan_Run()
  FlipBuffers()
  Delay(1)
 
  Until EventID = 0
 
Wend
End
Code: Select all
;;IncludeFile "glu.pbi"
Global xrot.f ;X Rotation
Global yrot.f ;Y Rotation
Global xspeed.f ;X Rotation Speed
Global yspeed.f ;Y Rotation Speed
;Global z.f=-5.0 ;Depth Into The Screen
Global quadratic.l ;Storage For Our Quadratic Objects ( NEW )
InitKeyboard()
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
  CompilerIf Subsystem("OpenGL") = #False
    MessageRequester("Error", "Please set the subsystem to OpenGL")
    End
  CompilerEndIf
CompilerEndIf
If InitSprite() = 0
  MessageRequester("Error", "Can't open screen & sprite environment!")
  End
EndIf
Global angle.f = 0
OpenWindow(0, 0, 0, 800, 600, "Dodecahedron and other GLut objects .. use the slider to rotate", #PB_Window_SystemMenu | #PB_Window_Invisible)
SetWindowColor(0, 14403509)
ContainerGadget(0, 5, WindowHeight(0)-50, 250, 60, #PB_Container_Raised)
TrackBarGadget(2, 60, 10, 90, 20, 0, 200)
TextGadget(3, 150, 10, 100, 25, "0")
CloseGadgetList()
SetGadgetState(0, 0)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0)-50, WindowHeight(0)-60, 0, 0, 0)
HideWindow(0, #False)
Global running.b = 0;
lngh.f : width.f : depth.f 
glClearColor_ (0.0, 0.0, 0.0, 0.0);
glShadeModel_ (#GL_SMOOTH)
glEnable_(#GL_LIGHTING);
glEnable_(#GL_LIGHT0);
glEnable_(#GL_DEPTH_TEST);
Procedure.l DrawGLScene()
 glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT) ;Clear The Screen And The Depth Buffer
 glLoadIdentity_() ;Reset The View
 
  glViewport_(0, 0, WindowWidth(0), WindowHeight(0))
  glMatrixMode_(#GL_PROJECTION)
  glLoadIdentity_()
  gluPerspective_(30.0, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 500.0)
  glMatrixMode_(#GL_MODELVIEW)
  glLoadIdentity_()
  glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  glLoadIdentity_ ()
   ; viewing transformation  
   glTranslatef_(0.0, 0.0, -10.0); 
   ;gluLookAt_(5,5,5,0,1.5,0,0,1,0);
      
   glPushMatrix_()                  ; Save the original Matrix coordinates
  ;glMatrixMode_(#GL_MODELVIEW)
  glTranslatef_(0, 0, ZoomFactor)  ;  move it forward a bit
  glClear_ (#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
  glDisable_(#GL_LIGHTING)
  glRotatef_(angle, 0.0, 1.0, 0.0)
glScalef_(0.4,0.4,0.4)  
glBegin_(#GL_TRIANGLES) ; start drawing a triangle
  glColor3f_(1.0, 0.0, 0.0);
  glVertex3f_( 0.0, 1.0, 0.0) ; top
  glColor3f_(0.0, 1.0, 0.0);
  glVertex3f_(-1.0,-1.0, 0.0) ; bottom left
  glColor3f_(0.0, 0.0, 1.0);
  glVertex3f_( 1.0,-1.0, 0.0) ; bottom right
glEnd_() ; finished 
  
glPopMatrix_() 
 
 glRotatef_(xrot,1.0,0.0,0.0) ;Rotate On The X Axis By xrot
 glRotatef_(yrot,0.0,1.0,0.0) ;Rotate On The Y Axis By yrot
 ;glutWireTeapot_(2) 
 glColor3f_(1.0, 0.0, 1.0)
 glutWireDodecahedron_()
 glColor3f_(0.0, 0.6, 0.0)
 glutWireIcosahedron_()
 
 xrot+xspeed ;Add xspeed To xrot
 yrot+yspeed ;Add yspeed To yrot
 ProcedureReturn #True ;Keep Going
 
EndProcedure
While Quit.b = 0
  Repeat 
    EventID = WindowEvent()
    Select EventID
        Case #PB_Event_Gadget
          If EventGadget() = 1
            run.i = 1
          EndIf
          If EventGadget() = 2
           angle = GetGadgetState(2)
           SetGadgetText(3, Str(angle))
           yspeed=0.01*angle
           ;xspeed=0.01*angle
          EndIf
           
      Case #PB_Event_CloseWindow
        Quit = 1
    EndSelect
    ExamineKeyboard()
  If KeyboardReleased(#PB_Key_Escape)
    Quit = 1
      
   EndIf
  
  DrawGLScene()
  FlipBuffers()
  Delay(1)
  
  Until EventID = 0
  
Wend
Endsome references:
http://glprogramming.com/red/ the red book
GLFW 304 wrapper 1.03:
http://www.purebasic.fr/english/viewtop ... 40&t=57875
Simple Windowed OpenGL Framework - for OpenGL beginners
http://www.purebasic.fr/english/viewtopic.php?t=28835
Small cross-platform OpenGL demo:
http://www.purebasic.fr/english/viewtop ... 12&t=49583
OpenGL with GL, GLU and GLUT:
http://www.purebasic.fr/english/viewtopic.php?p=223261
How to initialise and use OpenGL (not OGRE) in MacOSX:
http://www.purebasic.fr/english/viewtop ... 19&t=36261



