include "Tlbx agl.incl" include "Tlbx glut.incl" output file "Rotating Sphere" local fn SphereDraw '~'1 begin globals dim as double  sRotation // 'static' var end globals // Speed of rotation sRotation += 2.9 glMatrixMode( _GLMODELVIEW ) glLoadIdentity() // Position parameters: x axis, y axis, z axis // Set to center of screen: glTranslated( 0.0, 0.0, 0.0 ) // Rotation (wobble) parameters: angle, x, y glRotated( sRotation, -0.45, -0.8, -0.6 ) // Set color of sphere's wireframe glColor3d( 1.0, 0.0, 0.3 ) // Set width of sphere's wireframe lines glLineWidth( 1.5 ) // Apply above to GLUT's built-in sphere wireframe // Size & frame parameters: radius, slices, stack fn glutWireSphere( 0.8, 25, 25 ) end fn // main program dim as GLint           attrib(2) dim as CGrafPtr        port dim as AGLPixelFormat  fmt dim as AGLContext      glContext dim as EventRecord     ev dim as GLboolean       yesOK // Make a window window 1, @"Rotating Sphere", (0,0) - (500,500) // Minimal setup of OpenGL attrib(0) = _AGLRGBA attrib(1) = _AGLDOUBLEBUFFER attrib(2) = _AGLNONE fmt = fn aglChoosePixelFormat( 0, 0, attrib(0) ) glContext = fn aglCreateContext( fmt, 0 ) aglDestroyPixelFormat( fmt ) // Set the FB window as port for drawing port = window( _wndPort ) yesOK = fn aglSetDrawable( glContext, port ) yesOK = fn aglSetCurrentContext( glContext ) // Background color: red, green, blue, alpha glClearColor( 0.0, 0.0, 0.0, 0.0 ) // 60/s HandleEvents Trigger poke long event - 8, 1 do // Clear window glClear( _GLCOLORBUFFERBIT ) // Run animation fn SphereDraw aglSwapBuffers( glContext ) HandleEvents until gFBquit