from OpenGL.GL import * # import the main gl library, e.g., glViewport from OpenGL.GLU import * # import the gl utility library, e.g., gluOrtho2D from OpenGL.GLUT import * # import GL Utility Toolkit, windowing lib, e.g., glutCreateWindow from math import * import datetime, time, sys circlevtx = [] def draw_disk(): if not circlevtx: circlevtx.append((0.,0.)) for i in range(25): circlevtx.append( (cos(2*pi*i/24), sin(2*pi*i/24)) ) glVertexPointerf( circlevtx ) # draw the disk as a triangle fan def draw_box_centered(): #use corners at +/- 1, that is, from (-1,-1) to (1,1) #glVertexPointerf( ) #glDrawArrays( ) pass def draw_box_cornered(): #use corners at 0 and 1, that is, from (0,0) to (1,1) pass def scale_rot_trans( ctrx, ctry, sclx, scly, angle, nctrx, nctry ): # the first two coordinates set the location of the center # then you need to scale around that center # then rotate around that center # then move the center to a new location (nctrx, nctry) pass def idle(): time.sleep(1) glutPostRedisplay() def display(): dt = datetime.datetime.now() print dt.hour print dt.minute print dt.second # draw the clock using draw_box_cornered(), draw_box_centered(), draw_disk() # place, scale, and orient the components using scale_rot_trans() def myInit(): # set up the background color #glClearColor( ) # enable the use of vertex arrays glEnableClientState( GL_VERTEX_ARRAY ) def reshape(w,h): # set up the viewport to be the full window glViewport( 0,0,w,h ) # start changing the projection matrix glMatrixMode( GL_PROJECTION ) # clear it to identity matrix glLoadIdentity() # multiply the identity matrix with a matrix that uses # orthographic projection, sets the coordinate system # choose your coordinate system here #gluOrtho2D( ) # usually we only modify modelview matrix in the programs, # so set the matrixmode to modelview so don't accidentally # change the projection matrix glMatrixMode( GL_MODELVIEW ) def main(): # initialized glut library glutInit( [] ) # prepare for the window you are going to ask for glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB ) glutInitWindowSize( 300,300 ) glutInitWindowPosition( 300,100 ) # get the window, give it a title string glutCreateWindow( 'OpenGL Clock' ) # set up the callback functions for various events glutReshapeFunc( reshape ) glutDisplayFunc( display ) glutIdleFunc( idle ) # call my own init to set up basic opengl state myInit() # release control to the glut main event loop glutMainLoop() # after all the functions have been declared, just call the main() function # note that main is not a special name like in C or Java main()