def main(): LOG.setVerbose() # configure renderer log.info('creating renderer') renderer = render.Renderer() renderer.cpoly = vertex.VertexObject(BUFSIZE) renderer.dimension = 500 renderer.gpu = False # create window log.info('creating window') window = display.Window('Bezier Splines') window.renderer = renderer window.handler = Handler(window) # configure shader renderer.shader.vertex = 'shader/std.vert' renderer.shader.geometry = 'shader/bezier.geom' renderer.shader.fragment = 'shader/std.frag' renderer.shader.compile() # appearance renderer.background = (.2, .2, .2, 0.) renderer.cpolyColor = (1., .6, 0., 0.) renderer.splineColor = (0., .6, 1., 0.) window.show()
def main(argv): """ Program entry point. This function blocks. :param argv: sys.argv (or some mock) :returns: None :rtype: None """ delim = '\n' + '- ' * 40 args = parse_args() if args.verbose: logger.setVerbose() if args.trace: logger.setTrace() # determine window size ratio = map(int, args.res.split('x')) # # INITIALIZE GLUT # cwd = os.getcwd() glt.glutInit([]) os.chdir(cwd) glt.glutInitDisplayMode( glt.GLUT_DEPTH | glt.GLUT_DOUBLE | glt.GLUT_RGB) glt.glutInitWindowSize(*ratio) glt.glutCreateWindow("Rendering %s" % args.filename.rstrip('.obj')) # # CREATE SCENE # log('initializing scene:%s' % delim) scene = render.Scene.Instance() scene.setShading(args.shading) scene.callback = glt.glutSwapBuffers scene.repaint = glt.glutPostRedisplay # alter appearance scene.background = util.Color().hex(0x33333300) light = scene.createLight() light.position = 0.5, 2., 0.5 # create camera cam = render.Camera.Instance() cam.fow, cam.ratio = args.fow, ratio cam.mode, cam.offset = cam.ORTHOGONALLY, 1 scene.camera = cam # create entities log('parsing and inintializing geometries:%s' % delim) for obj in parser.ObjParser(args.filename).objects: polyhedron = geometry.Polyhedron(obj) ent = scene.addEntity(polyhedron) ent.material.ambient = util.Color().rgba(0, 123, 255, 0.5) # ent.material.specular = .2, .2, .2, .5 # ent.material.shininess = 100 # # BIND HANDLER # trace('listening:%s' % delim) glt.glutMouseFunc(scene.evt.mouseClicked) glt.glutMotionFunc(scene.evt.mouseMoved) glt.glutKeyboardFunc(scene.evt.keyPressed) glt.glutReshapeFunc(scene.evt.reshape) # dispatch glt.glutDisplayFunc(scene.render) glt.glutMainLoop()