コード例 #1
0
ファイル: window.py プロジェクト: sehoonha/pydart2
    def run(self, ):
        print("\n")
        print("space bar: simulation on/off")
        print("' ': run/stop simulation")
        print("'a': run/stop animation")
        print("'[' and ']': play one frame backward and forward")

        # Init glut
        GLUT.glutInit(())
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA |
                                 GLUT.GLUT_DOUBLE |
                                 GLUT.GLUT_MULTISAMPLE |
                                 GLUT.GLUT_ALPHA |
                                 GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(*self.window_size)
        GLUT.glutInitWindowPosition(0, 0)
        self.window = GLUT.glutCreateWindow(self.title)

        # Init functions
        # glutFullScreen()
        GLUT.glutDisplayFunc(self.drawGL)
        GLUT.glutIdleFunc(self.idle)
        GLUT.glutReshapeFunc(self.resizeGL)
        GLUT.glutKeyboardFunc(self.keyPressed)
        GLUT.glutMouseFunc(self.mouseFunc)
        GLUT.glutMotionFunc(self.motionFunc)
        GLUT.glutTimerFunc(25, self.renderTimer, 1)
        self.initGL(*self.window_size)

        # Run
        GLUT.glutMainLoop()
コード例 #2
0
def main():
    global calib, cyl

    src_dir = os.path.split(os.path.abspath(__file__))[0]
    data_dir = os.path.join(src_dir,'..','data')
    pmat = np.loadtxt( os.path.join(data_dir, 'cameramatrix.txt') )
    calib = decompose(pmat)
    width = 752
    height = 480

    glut.glutInit()
    glut.glutInitWindowSize(width,height)
    glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DEPTH | glut.GLUT_ACCUM | glut.GLUT_DOUBLE)
    glut.glutCreateWindow("calib_test_pyopengl");

    cyl = PointCylinder()
    if 1:
        # compose view matrix
        r = get_gluLookAt(pmat)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
        glu.gluLookAt( *r['all_args'] )
    gl.glDisable(gl.GL_DEPTH_TEST)
    glut.glutDisplayFunc(on_draw)
    on_resize(width,height)
    glut.glutMainLoop()
コード例 #3
0
    def run_sim_with_window(self):
        print("\n")
        print("space bar: simulation on/off")
        print("' ': run/stop simulation")
        print("'a': run/stop animation")
        print("'[' and ']': play one frame backward and forward")

        # Init glut
        GLUT.glutInit(())
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE
                                 | GLUT.GLUT_MULTISAMPLE | GLUT.GLUT_ALPHA
                                 | GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(*self.window_size)
        GLUT.glutInitWindowPosition(0, 0)
        self.window = GLUT.glutCreateWindow(self.title)

        # Init functions
        # glutFullScreen()
        GLUT.glutDisplayFunc(self.drawGL)
        GLUT.glutIdleFunc(self.idle)
        GLUT.glutReshapeFunc(self.resizeGL)
        GLUT.glutKeyboardFunc(self.keyPressed)
        GLUT.glutMouseFunc(self.mouseFunc)
        GLUT.glutMotionFunc(self.motionFunc)
        GLUT.glutTimerFunc(25, self.renderTimer, 1)
        self.initGL(*self.window_size)

        # Run
        GLUT.glutMainLoop()
コード例 #4
0
ファイル: pyopengl_main.py プロジェクト: borsboom/babal
def main():
    GLUT.glutInit(sys.argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)
    GLUT.glutInitWindowSize(320, 240)
    global window
    window = GLUT.glutCreateWindow("Babal")

    GLUT.glutDisplayFunc(display_cb)
    GLUT.glutVisibilityFunc(visibility_cb)
    GLUT.glutReshapeFunc(reshape_cb)

    GLUT.glutIgnoreKeyRepeat(1)
    GLUT.glutKeyboardFunc(keyboard_cb)
    GLUT.glutKeyboardUpFunc(keyboard_up_cb)
    GLUT.glutSpecialFunc(special_cb)
    GLUT.glutSpecialUpFunc(special_up_cb)
    GLUT.glutJoystickFunc(joystick_cb, 0)

    map_file = None
    if len(sys.argv) > 1:
        map_file = open(sys.argv[1])

    global game
    game = Game(map_file)
    gl_draw.init(GL, GLU, game)

    # reshape_cb gets called when window is made visible

    GLUT.glutMainLoop()
コード例 #5
0
ファイル: molecular_vis.py プロジェクト: atrigent/smilesvis
    def run(self):
        glut.glutInit(sys.argv)
        glut.glutInitWindowSize(500, 500)
        glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE | glut.GLUT_DEPTH)
        self.win = glut.glutCreateWindow(b'Molecular visualizer')

        glut.glutDisplayFunc(self.display)
        glut.glutReshapeFunc(self.reshape)
        glut.glutKeyboardFunc(self.keyboard)
        glut.glutMotionFunc(self.rotate)
        glut.glutMouseFunc(self.mouse)

        gl.glClearColor(0, 0, 0, 1)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glEnable(gl.GL_LIGHTING)
        gl.glEnable(gl.GL_LIGHT0)

        gl.glColorMaterial(gl.GL_FRONT, gl.GL_DIFFUSE)
        gl.glEnable(gl.GL_COLOR_MATERIAL)

        # very diffuse and dark specular highlights, to make black visible
        gl.glMaterial(gl.GL_FRONT, gl.GL_SPECULAR, (.1, .1, .1, 1))
        gl.glMaterial(gl.GL_FRONT, gl.GL_SHININESS, 5)

        self.displist = gl.glGenLists(1)
        gl.glNewList(self.displist, gl.GL_COMPILE)
        self.draw_atoms(self.molecule)
        gl.glEndList()

        glut.glutMainLoop()
コード例 #6
0
ファイル: openGLTestbed.py プロジェクト: RSharman/psychopy
def main():
		global window
		# For now we just pass glutInit one empty argument. I wasn't sure what should or could be passed in (tuple, list, ...)
		# Once I find out the right stuff based on reading the PyOpenGL source, I'll address this.
		lutAsString = buildBitsLUT()
		GLUT.glutInit([])
		GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_ALPHA | GLUT.GLUT_DEPTH)
		
		# get a 640 x 480 window 
		GLUT.glutInitWindowSize(800, 600)
		
		# the window starts at the upper left corner of the screen 
		GLUT.glutInitWindowPosition(0, 0)
		
		window = GLUT.glutCreateWindow("Jeff Molofee's GL Code Tutorial ... NeHe '99")
		# glutFullScreen()
		#register callbacks
		GLUT.glutIdleFunc(DrawGLScene)		
		GLUT.glutReshapeFunc(ReSizeGLScene)
		GLUT.glutKeyboardFunc(keyPressed)
		GLUT.glutDisplayFunc(DrawGLScene)		

		InitGL(800, 600)

		GLUT.glutMainLoop()
コード例 #7
0
def main():
    global _projection, _rotation, _time_dif, _aspect_ratio
    # OpenGL initialization.
    glut.glutInit(sys.argv)
    # Initialize buffer and OpenGL settings.
    glut.glutInitDisplayMode(glut.GLUT_SINGLE | glut.GLUT_RGB
                             | glut.GLUT_DEPTH)
    init_window()
    # Initialize shaders.
    success = init_shaders()
    if not success:
        print('Failed to compile and link shader program.')
    # Initialize and create window, and set GLUT callback functions
    gl.glEnable(gl.GL_TEXTURE_2D)
    gl.glEnable(gl.GL_DEPTH_TEST)
    # gl.glEnable(gl.GL_LIGHTING)   # TODO: Leave light disabled for now
    # gl.glShadeModel(gl.GL_SMOOTH) #
    # set display callback function
    glut.glutDisplayFunc(draw)
    # set mouse motion callback funciton
    # glut.glutPassiveMotionFunc(mouse_motion_handler)
    # set idle callback function
    # glut.glutIdleFunc(idle)
    # create perspective transformation matrix
    _projection = glm.perspective(glm.radians(45.0), _aspect_ratio, 0.1, 100.0)
    euler = glm.vec3(-45.0, 0.0, 0.0, dtype=c_float)
    _rotation = quat.tquat(euler, dtype=c_float)
    init_test_object()
    # _time_dif = datetime.now()
    _time_dif = time.time()
    # Begin main loop.
    glut.glutMainLoop()
コード例 #8
0
def main():    
    GLUT.glutInit(argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH | GLUT.GLUT_MULTISAMPLE)
    larguraTela = GLUT.glutGet(GLUT.GLUT_SCREEN_WIDTH)
    alturaTela = GLUT.glutGet(GLUT.GLUT_SCREEN_HEIGHT)
    larguraJanela = round(2 * larguraTela / 3)
    alturaJanela = round(2 * alturaTela / 3)
    GLUT.glutInitWindowSize(larguraJanela, alturaJanela)
    GLUT.glutInitWindowPosition(round((larguraTela - larguraJanela) / 2), round((alturaTela - alturaJanela) / 2))
    GLUT.glutCreateWindow(janela)
    GLUT.glutDisplayFunc(draw)
    load()
    GL.glEnable(GL.GL_MULTISAMPLE)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glEnable(GL.GL_TEXTURE_2D)
    GL.glClearColor(*corFundo)
    GL.glClearDepth(1.0)
    GL.glDepthFunc(GL.GL_LESS)
    GL.glShadeModel(GL.GL_SMOOTH)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GLU.gluPerspective(-45, larguraJanela / alturaJanela, 0.1, 100.0)
    GL.glTranslatef(0.0, 0.0, -10)
    GL.glMatrixMode(GL.GL_MODELVIEW)
    GLUT.glutTimerFunc(10, timer, 1)
    GLUT.glutMainLoop()
コード例 #9
0
def main():
    light_position = (7, 2, 1)    
    GLUT.glutInit(argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH | GLUT.GLUT_MULTISAMPLE)
    larguraTela = GLUT.glutGet(GLUT.GLUT_SCREEN_WIDTH)
    alturaTela = GLUT.glutGet(GLUT.GLUT_SCREEN_HEIGHT)
    larguraJanela = round(2 * larguraTela / 3)
    alturaJanela = round(2 * alturaTela / 3)
    GLUT.glutInitWindowSize(larguraJanela, alturaJanela)
    GLUT.glutInitWindowPosition(round((larguraTela - larguraJanela) / 2), round((alturaTela - alturaJanela) / 2))
    GLUT.glutCreateWindow(janela)
    GLUT.glutReshapeFunc(reshape)
    GLUT.glutDisplayFunc(draw)
    GLUT.glutMouseFunc(clique)
    GL.glShadeModel(GL.GL_SMOOTH)
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, dados[0][0])
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, dados[0][1])
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, dados[0][2])
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_SHININESS, dados[0][3])
    GL.glEnable(GL.GL_LIGHTING)
    GL.glEnable(GL.GL_LIGHT0)
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_position)
    GL.glEnable(GL.GL_MULTISAMPLE)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glClearColor(*corFundo)
    GLU.gluPerspective(45, larguraJanela / alturaJanela, 0.1, 50.0)
    GLUT.glutTimerFunc(50, timer, 1)
    GLUT.glutMainLoop()
コード例 #10
0
def main():
    scanner = SimpleScanner()

    gl.glClearColor(0.1, 0.1, 0.2, 1.0)
    timer_msec = int(1000 / 60)  # 60 times per second
    renderer = Renderer()
    drawings_list = []
    fish_queue = Queue(
    )  # Queue to maintain order of the fish and kill the oldest ones
    fish_limit = 10  # Maximum amount of fish to draw
    scanned_fish_queue = Queue()
    draw_ocean(drawings_list)

    fish_shader_program = Renderer.create_shader(gl.GL_VERTEX_SHADER,
                                                 FISH_SHADER_CODE)
    bubble_texture = Renderer.create_texture_from_file(
        'ocean/images/bubble.png')
    load_fish_from_files(scanner, drawings_list, fish_queue,
                         fish_shader_program, bubble_texture)

    glut.glutDisplayFunc(partial(renderer.render, drawings_list))
    glut.glutIgnoreKeyRepeat(True)
    glut.glutKeyboardFunc(create_key_processor(scanner, scanned_fish_queue))
    glut.glutTimerFunc(
        timer_msec,
        create_animation_function(renderer, drawings_list, scanned_fish_queue,
                                  fish_queue, fish_limit, timer_msec,
                                  fish_shader_program, bubble_texture), 0)

    glut.glutMainLoop()
コード例 #11
0
def main():
    global calib, cyl

    src_dir = os.path.split(os.path.abspath(__file__))[0]
    data_dir = os.path.join(src_dir, '..', 'data')
    pmat = np.loadtxt(os.path.join(data_dir, 'cameramatrix.txt'))
    calib = decompose(pmat)
    width = 752
    height = 480

    glut.glutInit()
    glut.glutInitWindowSize(width, height)
    glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DEPTH | glut.GLUT_ACCUM
                             | glut.GLUT_DOUBLE)
    glut.glutCreateWindow("calib_test_pyopengl")

    cyl = PointCylinder()
    if 1:
        # compose view matrix
        r = get_gluLookAt(pmat)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
        glu.gluLookAt(*r['all_args'])
    gl.glDisable(gl.GL_DEPTH_TEST)
    glut.glutDisplayFunc(on_draw)
    on_resize(width, height)
    glut.glutMainLoop()
コード例 #12
0
ファイル: backend_glut.py プロジェクト: lordi/dantien
    def start(self):
        ''' Starts main loop. '''

        # Start timers
        for i in range(len(self._timer_stack)):
            def func(index):
                handler, fps = self._timer_stack[index]
                t = glut.glutGet(glut.GLUT_ELAPSED_TIME)
                dt = (t - self._timer_date[index])/1000.0
                self._timer_date[index] = t
                handler(dt)
                glut.glutTimerFunc(int(1000./fps), func, index)
                self._timer_date[index] = glut.glutGet(glut.GLUT_ELAPSED_TIME)
            fps = self._timer_stack[i][1]
            glut.glutTimerFunc(int(1000./fps), func, i)

        # Start idle only if necessary
        for item in self._event_stack:
            if 'on_idle' in item.keys():
                glut.glutIdleFunc(self._idle)

        # Dispatch init event
        self.dispatch_event('on_init')
        
        if not self._interactive:
            glut.glutMainLoop()
コード例 #13
0
ファイル: Testopengl.py プロジェクト: pluto16/python_cv
def main():
    glut.glutInit(sys.argv)
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH)
    glut.glutInitWindowSize(400,400)
    glut.glutCreateWindow("teapot")

    gl.glClearColor(0.,0.,0.,1.)
    gl.glShadeModel(gl.GL_SMOOTH)
    gl.glEnable(gl.GL_CULL_FACE)
    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glEnable(gl.GL_LIGHTING)
    lightZeroPosition = [10.,4.,10.,1.]
    lightZeroColor = [0.8,1.0,0.8,1.0] #green tinged
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, lightZeroPosition)
    gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, lightZeroColor)
    gl.glLightf(gl.GL_LIGHT0, gl.GL_CONSTANT_ATTENUATION, 0.1)
    gl.glLightf(gl.GL_LIGHT0, gl.GL_LINEAR_ATTENUATION, 0.05)
    gl.glEnable(gl.GL_LIGHT0)
    glut.glutDisplayFunc(display)
    gl.glMatrixMode(gl.GL_PROJECTION)
    glu.gluPerspective(40.,1.,1.,40.)
    gl.glMatrixMode(gl.GL_MODELVIEW)
    glu.gluLookAt(0,0,10,
                  0,0,0,
                  0,1,0)
    gl.glPushMatrix()
    glut.glutMainLoop()
    return
コード例 #14
0
ファイル: sharder_test.py プロジェクト: legokichi/py_sandbox
def initGLUT(vertex_shade_code, fragment_shader_code, texture_image):
    GLUT.glutInit(sys.argv) # argv,argcを渡す
    # 表示モード
    if texture_image.mode == 'RGB':
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGB | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)
    elif texture_image.mode == 'RGBA':
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)
    else:
        # 謎のモード
        print(texture_image.mode)
        exit()
    window_width, window_height = texture_image.size # テクスチャサイズ = ウィンドウサイズ
    GLUT.glutInitWindowSize( window_width, window_height )
    # the window starts at the upper left corner of the screen
    GLUT.glutInitWindowPosition(0, 0)
    GLUT.glutCreateWindow( sys.argv[0] )

    ## The main drawing function.
    def draw():
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        GL.glEnable( GL.GL_TEXTURE_2D )
        GL.glDrawElements( GL.GL_TRIANGLES, 6, GL.GL_UNSIGNED_SHORT, np.array( indices, np.uint16 ) )
        GL.glDisable(GL.GL_TEXTURE_2D)
        GLUT.glutSwapBuffers()

    GLUT.glutDisplayFunc(draw)
    GLUT.glutIdleFunc(drawGLScene) # When we are doing nothing, redraw the scene.
    
    initGL( vertex_shade_code, fragment_shader_code, texture_image ) # Initialize our window.

    GLUT.glutMainLoop() # Start Event Processing Engine
コード例 #15
0
ファイル: openGLTestbed.py プロジェクト: yvs/psychopy
def main():
    global window
    # For now we just pass glutInit one empty argument. I wasn't sure what should or could be passed in (tuple, list, ...)
    # Once I find out the right stuff based on reading the PyOpenGL source, I'll address this.
    lutAsString = buildBitsLUT()
    GLUT.glutInit([])
    GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE
                             | GLUT.GLUT_ALPHA | GLUT.GLUT_DEPTH)

    # get a 640 x 480 window
    GLUT.glutInitWindowSize(800, 600)

    # the window starts at the upper left corner of the screen
    GLUT.glutInitWindowPosition(0, 0)

    window = GLUT.glutCreateWindow(
        "Jeff Molofee's GL Code Tutorial ... NeHe '99")
    # glutFullScreen()
    #register callbacks
    GLUT.glutIdleFunc(DrawGLScene)
    GLUT.glutReshapeFunc(ReSizeGLScene)
    GLUT.glutKeyboardFunc(keyPressed)
    GLUT.glutDisplayFunc(DrawGLScene)

    InitGL(800, 600)

    GLUT.glutMainLoop()
コード例 #16
0
    def run(self):
        glut.glutInit(sys.argv)
        glut.glutInitWindowSize(500, 500)
        glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE
                                 | glut.GLUT_DEPTH)
        self.win = glut.glutCreateWindow(b'Molecular visualizer')

        glut.glutDisplayFunc(self.display)
        glut.glutReshapeFunc(self.reshape)
        glut.glutKeyboardFunc(self.keyboard)
        glut.glutMotionFunc(self.rotate)
        glut.glutMouseFunc(self.mouse)

        gl.glClearColor(0, 0, 0, 1)
        gl.glEnable(gl.GL_DEPTH_TEST)
        gl.glEnable(gl.GL_LIGHTING)
        gl.glEnable(gl.GL_LIGHT0)

        gl.glColorMaterial(gl.GL_FRONT, gl.GL_DIFFUSE)
        gl.glEnable(gl.GL_COLOR_MATERIAL)

        # very diffuse and dark specular highlights, to make black visible
        gl.glMaterial(gl.GL_FRONT, gl.GL_SPECULAR, (.1, .1, .1, 1))
        gl.glMaterial(gl.GL_FRONT, gl.GL_SHININESS, 5)

        self.displist = gl.glGenLists(1)
        gl.glNewList(self.displist, gl.GL_COMPILE)
        self.draw_atoms(self.molecule)
        gl.glEndList()

        glut.glutMainLoop()
コード例 #17
0
ファイル: visualizer.py プロジェクト: gbrouwer/Tensor
def visualizeGraph(V1,G1,C1,S1):


	#Assign
	global V
	global G
	global C
	global S
	V = V1
	G = G1
	C = C1
	S = S1

	#Take Log
	S = numpy.log(S + 1)


	#Init Glut
	glut.glutInit(sys.argv)
	glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH)
	glut.glutInitWindowSize(1024,1024)
	glut.glutCreateWindow("Visualize (GLUT)")
	glut.glutDisplayFunc(on_display)
	glut.glutKeyboardFunc(on_keyboard)
	glut.glutReshapeFunc(on_reshape);


	#Lookat	
	gluLookAt(0,12,0,  0,0,0,  0,0,1);
	

	#Idle function
	glut.glutIdleFunc(on_idle)
	glut.glutFullScreen()
	glut.glutMainLoop()
コード例 #18
0
ファイル: glut_window.py プロジェクト: ChsHub/GLImageViewer
    def __init__(self, title, path):
        self._init_glut(title)

        with Timer('INIT GL'):
            init_GL(self, path)

        glut.glutMainLoop()
コード例 #19
0
    def main(self): 
        self.location = np.array([0.0,0.0,1500.0])
        self.focus = np.array([0.0,0.0,0.0])
        self.up = np.array([1.0,0.0,0.0])

        self.mousex = 0
        self.mousey = 0
        self.mouse_drag = gl.GL_FALSE

        # Wire up GL
        glut.glutInit(sys.argv)

        glut.glutInitDisplayMode(glut.GLUT_RGB | glut.GLUT_DOUBLE | glut.GLUT_DEPTH)
        glut.glutInitWindowSize(500,500)
        glut.glutInitWindowPosition(10,10)
        glut.glutCreateWindow("Laspy+OpenGL Pointcloud")
        glut.glutDisplayFunc(self.display)
        glut.glutReshapeFunc(self.reshape)
        glut.glutMouseFunc(self.mouse)
        glut.glutMotionFunc(self.mouse_motion)
        glut.glutKeyboardFunc(self.keyboard)
        gl.glClearColor(0.0,0.0,0.0,1.0)
        glut.glutTimerFunc(10,self.timerEvent,1)

        glut.glutMainLoop()
        return 0
コード例 #20
0
    def thread_main(instance):
        # sys.stderr.write("Starting thread_main\n")
        GLUT.glutInit(sys.argv)
        GLUT.glutInitContextVersion(3, 3)
        GLUT.glutInitContextFlags(GLUT.GLUT_FORWARD_COMPATIBLE)
        GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE)
        GLUT.glutSetOption(GLUT.GLUT_ACTION_ON_WINDOW_CLOSE,
                           GLUT.GLUT_ACTION_GLUTMAINLOOP_RETURNS)
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE
                                 | GLUT.GLUT_DEPTH)

        # sys.stderr.write("Making default GLUT window.\n")
        GLUT.glutInitWindowSize(instance.width, instance.height)
        GLUT.glutInitWindowPosition(0, 0)
        instance.window = GLUT.glutCreateWindow(
            bytes(instance._title, encoding='UTF-8'))
        # Urgh.... according to the docs, I'm MUST register a display function
        #   for any GLUT window I create.  But... I don't want to do this until
        #   later (in self.__init__).  So, register a null function now,
        #   and hope that registering a new function is an OK thing to do.
        GLUT.glutDisplayFunc(lambda: None)

        # Not sure if I want this as a timer or an idle func
        GLUT.glutIdleFunc(lambda: GLUTContext.class_idle())
        # GLUT.glutTimerFunc(10, lambda val : GLUTContext.class_idle(), 0)
        sys.stderr.write("Going into GLUT.GLUT main loop.\n")
        GLUTContext._class_init = True

        GLUT.glutMainLoop()
コード例 #21
0
def main():
    global wmngr_glut

    ###################
    # GLUT Window Initialization
    glut.glutInit()
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB
                             | glut.GLUT_DEPTH)  # zBuffer
    glut.glutInitWindowSize(600, 600)
    glut.glutInitWindowPosition(100, 100)
    glut.glutCreateWindow("Simple GLUT")

    # Register callbacks
    glut.glutReshapeFunc(reshape)
    glut.glutDisplayFunc(display)
    glut.glutMouseFunc(mouse)
    glut.glutMotionFunc(motion)
    glut.glutKeyboardFunc(keyboard)
    glut.glutSpecialFunc(special)
    glut.glutIdleFunc(idle)

    wmngr_glut = dfm2.gl.glut.WindowManagerGLUT(0.3)

    dfm2.gl.setSomeLighting()

    ####
    # Turn the flow of control over to GLUT
    glut.glutMainLoop()
コード例 #22
0
ファイル: visualizer.py プロジェクト: mapleyustat/Tensor-4
def visualizeGraph(V1, G1, C1, S1):

    #Assign
    global V
    global G
    global C
    global S
    V = V1
    G = G1
    C = C1
    S = S1

    #Take Log
    S = numpy.log(S + 1)

    #Init Glut
    glut.glutInit(sys.argv)
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB
                             | glut.GLUT_DEPTH)
    glut.glutInitWindowSize(1024, 1024)
    glut.glutCreateWindow("Visualize (GLUT)")
    glut.glutDisplayFunc(on_display)
    glut.glutKeyboardFunc(on_keyboard)
    glut.glutReshapeFunc(on_reshape)

    #Lookat
    gluLookAt(0, 12, 0, 0, 0, 0, 0, 0, 1)

    #Idle function
    glut.glutIdleFunc(on_idle)
    glut.glutFullScreen()
    glut.glutMainLoop()
コード例 #23
0
    def run(self):
        GLUT.glutInit()
        GLUT.glutSetOption(GLUT.GLUT_MULTISAMPLE, 4)
        GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH
                                 | GLUT.GLUT_MULTISAMPLE)
        self.width = 1200
        self.height = 720

        GLUT.glutInitWindowSize(self.width, self.height)
        GLUT.glutInitWindowPosition(100, 100)

        self.window = GLUT.glutCreateWindow(self.title)

        self.init_program()

        self.clear()
        self.show_loading_screen()
        self.init_line_buffer()
        self.load_line_buffer()

        GLUT.glutDisplayFunc(self.display)
        GLUT.glutIdleFunc(self.idle)
        GLUT.glutReshapeFunc(self.reshape)
        GLUT.glutKeyboardFunc(self.keyboard)
        GLUT.glutSpecialFunc(self.special)
        GLUT.glutMouseFunc(self.mouse)
        GLUT.glutMotionFunc(self.motion)
        GLUT.glutPassiveMotionFunc(self.motion)

        GLUT.glutMainLoop()
コード例 #24
0
ファイル: sample_legacy.py プロジェクト: shirobu2400/mmdpy
def main():
    window_width = 600
    window_height = 600

    glut.glutInit(sys.argv)
    glut.glutInitDisplayMode(
        cast(int, glut.GLUT_RGB) | cast(int, glut.GLUT_SINGLE)
        | cast(int, glut.GLUT_DEPTH))
    glut.glutInitWindowSize(window_width, window_height)  # window size
    glut.glutInitWindowPosition(100, 100)  # window position
    glut.glutCreateWindow("mmdpy")  # show window
    glut.glutDisplayFunc(display)  # draw callback function
    # glut.glutIdleFunc(display)
    glut.glutReshapeFunc(reshape)  # resize callback function

    parser = argparse.ArgumentParser(description="MMD model viewer sample.")
    parser.add_argument("-p", type=str, help="MMD model file name.")
    parser.add_argument("-v", type=str, help="MMD motion file name.")
    parser.add_argument("--bone",
                        type=bool,
                        default=False,
                        help="Print bone informations.")
    args = parser.parse_args()

    model_name = args.p
    motion_name = args.v
    global bone_information
    bone_information = args.bone
    print(model_name)
    print(motion_name)
    init(window_width, window_height, model_name, motion_name)

    glut.glutTimerFunc(1000 // FPS, event, 0)
    glut.glutMainLoop()
コード例 #25
0
ファイル: glut.py プロジェクト: PolarNick239/OpenGLPrototypes
 def run(self):
     self.interval_ms = 0 if self.limit_fps <= 0 else 1000 / self.limit_fps
     if self.show_fps:
         self.previous_update_time = utils.current_time_ms()
         self.previous_fps_print = -1
     glut.glutTimerFunc(self.interval_ms, self.update, 0)
     glut.glutMainLoop()
コード例 #26
0
ファイル: glovelet3DDemo.py プロジェクト: hamsterz0/GloveLet
def main():
    global EVENT_MNGR, EVENT_DISP, EVENT_LIST,\
            PROJECTION_MTRX, LOOKAT_MTRX, ASPECT_RATIO
    atexit.register(on_exit)
    glut.glutInit(sys.argv)
    OpenGL.GLUT.freeglut.glutSetOption(OpenGL.GLUT.GLUT_ACTION_ON_WINDOW_CLOSE, OpenGL.GLUT.GLUT_ACTION_GLUTMAINLOOP_RETURNS)
    init_window()
    EVENT_DISP = GloveletSensorEventDispatcher('/dev/ttyACM0', 115200)
    EVENT_LIST = GloveletDemoController()
    EVENT_MNGR = EventDispatchManager(EVENT_DISP, EVENT_LIST)
    init_hand()
    glut.glutShowWindow()
    # Init shaders
    if not init_shaders():
        print('Failed to compile and link shader program.')
    # init OpenGL settings
    gl.glEnable(gl.GL_TEXTURE_2D)
    gl.glEnable(gl.GL_DEPTH_TEST)
    # set render callback
    glut.glutDisplayFunc(draw)
    glut.glutKeyboardFunc(keyboard_handler)
    # glut.glutPassiveMotionFunc(mouse_motion)
    # init perspective matrices
    PROJECTION_MTRX = glm.perspective(glm.radians(45.0), ASPECT_RATIO, 0.1, 100.0)
    LOOKAT_MTRX = glm.lookAt(glm.vec3((0.0, 2.0, -4.0), dtype='f'),  # eye
                             glm.vec3((0.0, 1.0, 0.0), dtype='f'),  # center
                             glm.vec3((0.0, 1.0, 0.0), dtype='f'))  # up
    # begin main loop
    EVENT_MNGR.deploy_dispatchers()
    glut.glutMainLoop()
    EVENT_MNGR.end_dispatchers()
    exit()
コード例 #27
0
ファイル: Visualization.py プロジェクト: signotheque/pycam
def Visualization(title, drawScene=DrawGLScene, width=320, height=200,
        handleKey=None):
    global window, _DrawCurrentSceneFunc, _KeyHandlerFunc
    GLUT.glutInit(sys.argv)

    _DrawCurrentSceneFunc = drawScene

    if handleKey:
        _KeyHandlerFunc = handleKey

    # Select type of Display mode:
    #  Double buffer
    #  RGBA color
    # Alpha components supported
    # Depth buffer
    GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE \
            | GLUT.GLUT_DEPTH)

    # get a 640 x 480 window
    GLUT.glutInitWindowSize(640, 480)

    # the window starts at the upper left corner of the screen
    GLUT.glutInitWindowPosition(0, 0)

    # Okay, like the C version we retain the window id to use when closing, but
    # for those of you new to Python (like myself), remember this assignment
    # would make the variable local and not global if it weren't for the global
    # declaration at the start of main.
    window = GLUT.glutCreateWindow(title)

    # Register the drawing function with glut, BUT in Python land, at least
    # using PyOpenGL, we need to set the function pointer and invoke a function
    # to actually register the callback, otherwise it would be very much like
    # the C version of the code.
    GLUT.glutDisplayFunc(DrawGLScene)

    # Uncomment this line to get full screen.
    # GLUT.glutFullScreen()

    # When we are doing nothing, redraw the scene.
    GLUT.glutIdleFunc(DrawGLScene)

    # Register the function called when our window is resized.
    GLUT.glutReshapeFunc(ReSizeGLScene)

    # Register the function called when the keyboard is pressed.
    GLUT.glutKeyboardFunc(keyPressed)

    # Register the function called when the mouse is pressed.
    GLUT.glutMouseFunc(mousePressed)

    # Register the function called when the mouse is pressed.
    GLUT.glutMotionFunc(mouseMoved)

    # Initialize our window.
    InitGL(640, 480)

    # Start Event Processing Engine
    GLUT.glutMainLoop()
コード例 #28
0
def main():
    glut.glutInit()
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
    glut.glutCreateWindow('Hello world!')
    glut.glutReshapeWindow(512, 512)
    glut.glutReshapeFunc(reshape)
    glut.glutDisplayFunc(display)
    glut.glutKeyboardFunc(keyboard)
    glut.glutMainLoop()
コード例 #29
0
ファイル: scene.py プロジェクト: fos/fos-pyglet
    def run(self):

        self.window()
        
        self.init()
        
        self.interaction()

        glut.glutMainLoop()
コード例 #30
0
ファイル: test1.py プロジェクト: oglearn/oglred
 def mainfunc(self):
     glut.glutInit()
     glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_3_2_CORE_PROFILE)
     glut.glutInitWindowSize(512, 512)
     #glut.glutInitContextVersion(4, 3)
     #glut.glutInitContextProfile(glut.GLUT_CORE_PROFILE)
     glut.glutCreateWindow('CH01_01')
     self.init()
     glut.glutDisplayFunc(self.disp)
     glut.glutMainLoop()
コード例 #31
0
ファイル: test1.py プロジェクト: oglearn/oglred
 def mainfunc(self):
     glut.glutInit()
     glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_3_2_CORE_PROFILE)
     glut.glutInitWindowSize(512, 512)
     #glut.glutInitContextVersion(4, 3)
     #glut.glutInitContextProfile(glut.GLUT_CORE_PROFILE)
     glut.glutCreateWindow('CH01_01')
     self.init()
     glut.glutDisplayFunc(self.disp)
     glut.glutMainLoop()
コード例 #32
0
ファイル: gl.py プロジェクト: mehdigorjian/image_processing
def main():
    glut.glutInit()

    glut.glutInitWindowSize(100, 100)
    glut.glutCreateWindow('Mehdi')

    init()
    glut.glutDisplayFunc(display)
    glut.glutReshapeFunc(resize(100, 100))

    glut.glutMainLoop()
コード例 #33
0
 def on(self):
     glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB)
     glut.glutInitWindowSize(self.ww, self.hh)
     glut.glutInitWindowPosition(300, 100)
     glut.glutInit(sys.argv)
     glut.glutCreateWindow(b"PCViewer")
     glut.glutDisplayFunc(self.__draw__)
     gl.glEnable(gl.GL_DEPTH_TEST)
     glut.glutReshapeFunc(self.__reshape__)
     glut.glutSpecialFunc(self.__specialkeys__)
     glut.glutMainLoop()
コード例 #34
0
    def __glInit(self):
        self.initTime = time.time()
        glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB)
        glut.glutInitWindowSize(1000, 1000)
        glut.glutInitWindowPosition(50, 50)
        glut.glutInit([])
        glut.glutCreateWindow(b"OpenGL Fractal Renderer")

        self.gpu_vendor = gl_v1.glGetString(gl.GL_VENDOR).decode("ascii")
        self.gpu_model = gl_v1.glGetString(gl.GL_RENDERER).decode("ascii")
        self.gpu_attrib_count = gl.glGetInteger(gl.GL_MAX_VERTEX_ATTRIBS)

        print(f"Found {self.gpu_vendor} {self.gpu_model}")
        print(f"GPU supports {self.gpu_attrib_count} vertex attributes")

        self.shaderProgram = gl.glCreateProgram()
        self.shaderVertex = self.__glCreateShader(
            gl.GL_VERTEX_SHADER, """
        #version 410
        layout(location = 0) in vec4 vertexPosition;
        //[0] - centerX, [1] - centerY, [2] - scaleH, [3] - width / height
        layout(location = 1) in vec4 centerAndScale;
        out mat2 pos;
        void main() {
            gl_Position = vertexPosition;
            float x = centerAndScale[0] + vertexPosition[0] / 2.0
             * centerAndScale[2] * centerAndScale[3];
            float y = centerAndScale[1] + vertexPosition[1] / 2.0
             * centerAndScale[2] ;
            pos = mat2(x,y,-y,x);
        }
        """)

        self.shaderSourceGenerator = GLFractalSourceGenerator()
        self.shaderSourceGenerator.generateSource(self.fractal)
        self.shaderSource = self.shaderSourceGenerator.getOneSourceString()
        self.shaderFragment = self.__glCreateFragmentShader(self.shaderSource)
        self.shaderSourceGenerator.printSource()

        gl.glAttachShader(self.shaderProgram, self.shaderVertex)
        gl.glAttachShader(self.shaderProgram, self.shaderFragment)
        gl.glLinkProgram(self.shaderProgram)

        linkStatus = gl.glGetProgramiv(self.shaderProgram, gl.GL_LINK_STATUS)
        if linkStatus != gl.GL_TRUE:
            error = gl.glGetProgramInfoLog(self.shaderProgram).decode("ascii")
            raise GLShaderLinkError(error)

        gl.glUseProgram(self.shaderProgram)
        self.__glSetupVarloc()
        glut.glutSpecialFunc(self.__glutSpecialKeyHandler)
        glut.glutDisplayFunc(self.__glDraw)
        glut.glutIdleFunc(self.__glDraw)
        glut.glutMainLoop()
コード例 #35
0
    def mainloop(self, interactive=False, namespace=globals()):
        '''Starts main loop
        '''

        # Start timers
        for i in range(len(self._timer_stack)):
            def func(index):
                handler, fps = self._timer_stack[index]
                t = glut.glutGet(glut.GLUT_ELAPSED_TIME)
                dt = (t - self._timer_date[index])/1000.0
                self._timer_date[index] = t
                handler(dt)
                glut.glutTimerFunc(int(1000./fps), func, index)
                self._timer_date[index] = glut.glutGet(glut.GLUT_ELAPSED_TIME)
            fps = self._timer_stack[i][1]
            glut.glutTimerFunc(int(1000./fps), func, i)

        # Start idle only if necessary
        for item in self._event_stack:
            if 'on_idle' in item.keys():
                glut.glutIdleFunc(self._idle)

        self.dispatch_event('on_init')

        # Starts non-interactive mode
        if not interactive:
            glut.glutMainLoop()
            sys.exit()

        # Starts interactive mode
        # Save tty mode on linux/darwin
        if sys.platform in ['linux2', 'darwin']:
            self.term_state = termios.tcgetattr(sys.stdin)
        namespace = namespace.copy()
        for key in namespace.keys():
            f = namespace[key]
            if key[:2] == 'gl' and isinstance(namespace[key], _ctypes.CFuncPtr):
                namespace[key] = proxy.Proxy(f,self)
        def session_start():
            self.shell = IPython.ipapi.make_session(namespace)
            self.shell.IP.interact() #mainloop()
            sys.exit()
        self.session = threading.Thread(target=session_start)
        self.session.start()

        @atexit.register
        def goodbye():
            self.shell.IP.ask_exit()
            # Restore tty state on linux/darwin
            if sys.platform in ['linux2', 'darwin']:
                termios.tcsetattr(sys.stdin, termios.TCSADRAIN, self.term_state)
            sys.stdout.write('\n')
        glut.glutTimerFunc(100, self._pop, 0)
        glut.glutMainLoop()
コード例 #36
0
ファイル: Window.py プロジェクト: raVgithub/raVEngine_python
 def initAndRunDevice(templateGlutSystem):
     glut.glutInit()
     glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
     glut.glutCreateWindow(b'raVEngine_py')
     glut.glutReshapeWindow(512, 512)
     glut.glutReshapeFunc(reshape)
     glut.glutDisplayFunc(templateGlutSystem.display)
     glut.glutKeyboardFunc(keyboard)
     glut.glutMotionFunc(mouse)
     glut.glutIdleFunc(templateGlutSystem.combineUpdateAndDisplay)
     glut.glutMainLoop()
コード例 #37
0
def main():
    GLUT.glutInit(sys.argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_SINGLE | GLUT.GLUT_RGBA
                             | GLUT.GLUT_DEPTH)
    GLUT.glutInitWindowSize(400, 400)
    GLUT.glutInitWindowPosition(200, 200)

    GLUT.glutCreateWindow("Grafica 2")
    """
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, [1.0, 1.0, 1.0, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, [1.0, 1.0, 1.0, 0.0])

    GL.glEnable(GL.GL_NORMALIZE)
    GL.glEnable(GL.GL_LIGHTING)
    GL.glEnable(GL.GL_LIGHT0)
    """

    GL.glDepthFunc(GL.GL_LEQUAL)
    GL.glEnable(GL.GL_DEPTH_TEST)
    GL.glClearDepth(1.0)
    GL.glClearColor(0.650, 0.780, 0.8, 0)
    GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glLoadIdentity()
    #GL.glOrtho(-20, 20, -20, 20, -20, 20)
    GL.glMatrixMode(GL.GL_MODELVIEW)

    GLU.gluPerspective(100, 1.0, 1.0, 100.0)
    GL.glTranslatef(0.0, 0.0, 0.0)
    GLU.gluLookAt(0, 10, 10, 0, 0, 0, 0, 1, 0)

    grid = GR.grid_gen()
    #grid.show()

    kid.morph(youngold, 100, True)

    while True:
        GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT)
        grid.plot()

        ########################################

        kid.morph(youngold, 100)

        ########################################

        GL.glFlush()
        GLUT.glutPostRedisplay()
        input("Pause")

    GLUT.glutMainLoop()
コード例 #38
0
def main():
    import sys
    global window

    if len(sys.argv) < 2:
        print "\nusage: python GLPainter.py filename\n"
        return

    p = GLPainter(glWindowWidth, glWindowHeight, sys.argv[1])

    print type(g_rs)
    glut.glutMainLoop()
コード例 #39
0
ファイル: GLPainter.py プロジェクト: gitter-badger/OpenPV
def main():
   import sys
   global window

   if len(sys.argv) < 2:
      print "\nusage: python GLPainter.py filename\n"
      return

   p = GLPainter(glWindowWidth, glWindowHeight, sys.argv[1])

   print type(g_rs)
   glut.glutMainLoop()
コード例 #40
0
def main():
    GLUT.glutInit(argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA
                             | GLUT.GLUT_DEPTH | GLUT.GLUT_MULTISAMPLE)

    # Creating a screen with good resolution proportions
    screen_width = GLUT.glutGet(GLUT.GLUT_SCREEN_WIDTH)
    screen_height = GLUT.glutGet(GLUT.GLUT_SCREEN_HEIGHT)

    window_width = round(2 * screen_width / 3)
    window_height = round(2 * screen_height / 3)

    GLUT.glutInitWindowSize(window_width, window_height)
    GLUT.glutInitWindowPosition(round((screen_width - window_width) / 2),
                                round((screen_height - window_height) / 2))
    GLUT.glutCreateWindow(window_name)

    # Reshape Function
    GLUT.glutReshapeFunc(reshape)

    # Drawing Function
    GLUT.glutDisplayFunc(draw)

    # Input Functions
    GLUT.glutSpecialFunc(special_key_pressed)
    GLUT.glutKeyboardFunc(key_pressed)
    GLUT.glutMouseFunc(mouse_click)
    GLUT.glutMotionFunc(mouse_move)

    #GL.glShadeModel(GL.GL_FLAT)
    GL.glShadeModel(GL.GL_SMOOTH)

    #First Material
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, materials[0][0])
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_DIFFUSE, materials[0][1])
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, materials[0][2])
    GL.glMaterialfv(GL.GL_FRONT, GL.GL_SHININESS, materials[0][3])

    light_position = (10, 0, 0)
    GL.glEnable(GL.GL_LIGHTING)
    GL.glEnable(GL.GL_LIGHT0)
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_position)

    GL.glEnable(GL.GL_MULTISAMPLE)
    GL.glEnable(GL.GL_DEPTH_TEST)

    GL.glClearColor(*background_color)

    # Pre-render camera positioning
    GLU.gluPerspective(45, window_width / window_height, 0.1, 50.0)

    GLUT.glutTimerFunc(50, timer, 1)
    GLUT.glutMainLoop()
コード例 #41
0
def main():

    GLUT.glutInit(sys.argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_SINGLE | GLUT.GLUT_RGB)
    GLUT.glutInitWindowSize(500, 500)
    GLUT.glutInitWindowPosition(50, 50)
    GLUT.glutCreateWindow("Plot points")

    init()
    GLUT.glutKeyboardFunc(keyPressed)
    GLUT.glutDisplayFunc(plotpoints)
    GLUT.glutMainLoop()
コード例 #42
0
def initGlut():
    glut.glutInit()
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA
                             | glut.GLUT_DEPTH)
    glut.glutInitWindowSize(canvasWidth, canvasHeight)
    glut.glutInitWindowPosition(100, 100)
    glut.glutCreateWindow('Particles')
    glut.glutDisplayFunc(displayCallback)
    glut.glutIdleFunc(displayCallback)
    glut.glutReshapeFunc(reshapeCallback)
    glut.glutKeyboardFunc(keyboardCallback)
    logging.info("Finished Setting Up Glut Loop")
    glut.glutMainLoop()
コード例 #43
0
ファイル: main.py プロジェクト: hoppfull/Learning-Python
 def run(self):
     # Create window:
     self.win = GLUT.glutCreateWindow(self.name)
     
     # Setup stuff for testing this time:
     self.mySetup()
     
     # Create update mechanism:
     GLUT.glutTimerFunc(30, self.update, 30)
     
     # Create redraw mechanism:
     GLUT.glutDisplayFunc(self.draw)
     GLUT.glutMainLoop()
コード例 #44
0
  def draw_loop(self,draw_func0):  

    # Register callbacks
    glut.glutReshapeFunc(self.reshape)
    glut.glutDisplayFunc(self.display)
    glut.glutMouseFunc(self.mouse)
    glut.glutMotionFunc(self.motion)
    glut.glutKeyboardFunc(self.keyboard)
    glut.glutSpecialFunc(self.special)
    glut.glutIdleFunc(self.idle)

    self.draw_func = draw_func0
    glut.glutMainLoop()
コード例 #45
0
ファイル: angleGui.py プロジェクト: Nhanbk/robotbuddy
    def initialize(self):
        glut.glutInit()
        glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE | glut.GLUT_DEPTH)
        glut.glutInitWindowSize(self.width,self.height)
        glut.glutInitWindowPosition(300,300)
        glut.glutCreateWindow("super black hole sunshine party")
        glut.glutDisplayFunc(self.paintGL)
        glut.glutIdleFunc(self.paintGL)
        glut.glutReshapeFunc(self.resizeGL)
        self.initGL()

        self.inputHandler.attachGLUT()

        glut.glutMainLoop()
コード例 #46
0
ファイル: main.py プロジェクト: hoppfull/Learning-Python
 def __init__(self):
     GLUT.glutInit(sys.argv)
     GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)
     GLUT.glutInitWindowSize(640, 480)
     self.win = GLUT.glutCreateWindow("PyOpenGL!!")
     
     # "glutTimerFunc" takes in three arguments
     GLUT.glutTimerFunc(
         20, # how long to wait
         self.update, # when initial wait, run this function
         20) # pass this value as argument to function
     
     # Called every frame:
     GLUT.glutDisplayFunc(self.draw)
     # application main loop:
     GLUT.glutMainLoop()
コード例 #47
0
 def run(self):
     # Create window:
     win = GLUT.glutCreateWindow(self.name)
     
     # Setup some OpenGL settings:
     GL.glEnable(GL.GL_CULL_FACE) # This isn't enabled by default
     GL.glFrontFace(GL.GL_CCW) # Standard, right hand rule
     GL.glCullFace(GL.GL_BACK)
     
     # Subclass setup:
     self.setup()
     
     # Create update mechanism:
     GLUT.glutTimerFunc(30, self.update, 30)
     # Create redraw mechanism:
     GLUT.glutDisplayFunc(self.draw)
     GLUT.glutMainLoop()
コード例 #48
0
ファイル: window.py プロジェクト: breckprog/drc
def init():
    GLUT.glutInit(sys.argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_SINGLE | GLUT.GLUT_RGB)
    GLUT.glutInitWindowSize(800, 600)
    GLUT.glutInitWindowPosition(100, 100)
    GLUT.glutCreateWindow("Something!")
    GL.glClearColor(0, 0, 0, 0)
    GL.glMatrixMode(GL.GL_PROJECTION)
    GL.glLoadIdentity()
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, [0.0, 0.0, 0.0, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, [1.0, 1.0, 1.0, 1.0])
    GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, [0.0, 3.0, 3.0, 0.0])
    GL.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, [0.2, 0.2, 0.2, 1.0])
    GL.glEnable(GL.GL_LIGHTING)
    GL.glEnable(GL.GL_LIGHT0)
    GLUT.glutDisplayFunc(update)
    GLUT.glutMainLoop()
コード例 #49
0
ファイル: gl_windows.py プロジェクト: bjedwards/python_lib
    def glinit(self):
        self._sock_thread = threading.Thread(target=self._comm_thread,args=(self,))
        self._sock_thread.start()
        
        GLUT.glutInit()
        GLUT.glutSetOption(GLUT.GLUT_ACTION_ON_WINDOW_CLOSE,
                           GLUT.GLUT_ACTION_GLUTMAINLOOP_RETURNS)
        # Some window attributes
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE)
        GLUT.glutInitWindowSize(self._width, self._height)
        GLUT.glutInitWindowPosition(0, 0)
        self._win = GLUT.glutCreateWindow(self.title)

        # OpenGL callbacks
        GLUT.glutDisplayFunc(self._draw(self._render_func))
        GLUT.glutKeyboardFunc(self._on_key)
        GLUT.glutMouseFunc(self._on_click)
        GLUT.glutMotionFunc(self._on_mouse_motion)
        GLUT.glutCloseFunc(self._on_exit)
        GLUT.glutTimerFunc(self.refresh, self._timer, self.refresh)

        #set up 2d or 3d viewport in nice orthographic projection
        GL.glViewport(0, 0, self._width, self._height)
        GL.glMatrixMode(GL.GL_PROJECTION)
        GL.glLoadIdentity()
        if self._dim==3:
            GL.glOrtho(-1.,1.,-1,1.,-1000.,1000.)
            GL.glMatrixMode(GL.GL_MODELVIEW)
        else:
            GL.glMatrixMode(GL.GL_PROJECTION)
            GL.glLoadIdentity()
            GLU.gluOrtho2D(-1.,1.,-1.,1.)
        #smooth the crap out of everything
        GL.glEnable(GL.GL_POINT_SMOOTH)
        GL.glEnable(GL.GL_LINE_SMOOTH)
        GL.glEnable(GL.GL_POLYGON_SMOOTH)
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_ONE,GL.GL_ONE_MINUS_SRC_ALPHA)
        GL.glHint(GL.GL_LINE_SMOOTH_HINT,GL.GL_NICEST)
        GL.glHint(GL.GL_POINT_SMOOTH_HINT,GL.GL_NICEST)
        GL.glHint(GL.GL_POLYGON_SMOOTH_HINT,GL.GL_NICEST)

        #Clear Everything and call the main loop
        GL.glClearColor(*self.background_color)
        self._window_open =True
        GLUT.glutMainLoop()
コード例 #50
0
ファイル: images3.py プロジェクト: Zackory/zackory-sandbox
    def __init__(self, width, height):
        self.width = width
        self.height = height
        self.shader = None

        self.triangleShadeProgram = None
        self.triangleBlueShadeProgram = None

        self.prepareGLUT()
        self.init()

        gl.glMatrixMode(gl.GL_PROJECTION)
        gl.glLoadIdentity()
        glu.gluOrtho2D(0, 1, 0, 1)
        # glu.gluOrtho2D(0, self.width, 0, self.height)

        glut.glutMainLoop()
コード例 #51
0
ファイル: demobase.py プロジェクト: caomw/FreenectFusion
 def run(self):
     glut.glutInit()
     glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE
                                 | glut.GLUT_ALPHA | glut.GLUT_DEPTH)
     glut.glutInitWindowSize(self.window_width, self.window_height)
     
     self.window = glut.glutCreateWindow("Point cloud test")
     
     glut.glutDisplayFunc(self.display_base)
     glut.glutIdleFunc(self.display_base)
     glut.glutReshapeFunc(self.resize_event)
     glut.glutKeyboardFunc(self.keyboard_press_event)
     glut.glutKeyboardUpFunc(self.keyboard_up_event)
     glut.glutMouseFunc(self.mouse_button_event)
     glut.glutMotionFunc(self.mouse_moved_event)
     
     self.init_gl(self.window_width, self.window_height)
     
     glut.glutMainLoop()
コード例 #52
0
ファイル: appbase.py プロジェクト: showa-yojyo/notebook
    def run(self, args):
        """Run a program."""

        self.init_glut(args)
        self.init_program()
        self.init_gl()
        self.init_mouse_event_handlers()
        self.init_texture()
        self.init_object()
        self.init_transform()

        return GLUT.glutMainLoop()
コード例 #53
0
ファイル: network.py プロジェクト: gbrouwer/Tensor
def visualizeGraph():


	#Init Glut
	glut.glutInit(sys.argv)
	glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH)
	glut.glutInitWindowSize(1024,1024)
	glut.glutCreateWindow(" Visualize (GLUT)")
	glut.glutDisplayFunc(on_display)
	glut.glutKeyboardFunc(on_keyboard)
	glut.glutReshapeFunc(on_reshape);


	#Lookat	
	gluLookAt(0,12,0,  0,0,0,  0,0,1);
	

	#Idle function
	glut.glutIdleFunc(on_idle)
	#glut.glutFullScreen()
	glut.glutMainLoop()
コード例 #54
0
ファイル: rubik.py プロジェクト: myme/PyCube
def main(argv):
    # Initialize glut for a nice main window
    glut.glutInit(argv)
    glut.glutInitDisplayMode(glut.GLUT_DEPTH | glut.GLUT_RGB | glut.GLUT_DOUBLE)
    glut.glutInitWindowSize(width, height)
    glut.glutInitWindowPosition(winX, winY)

    # Create the main window title
    glut.glutCreateWindow("Rubik's Cube!")

    # Initialize OpenGL
    initGL()

    size = globals()['size']

    # Set up the size of the cube
    if len(argv) == 1:
        print "No size given, assuming 3"
    elif len(argv) == 2:
        size = int(argv[1])
        globals()['size'] = size
        print "Creating a cube of size %d*%d*%d" % (size, size, size)
    else:
        print "%s [size]" % argv[0]

    # Create the cube
    globals()['cube'] = Cube(size)

    # Register callback functions
    glut.glutDisplayFunc(drawGLScene)
    glut.glutReshapeFunc(resizeGLScene)
    glut.glutKeyboardFunc(keyboard)
    glut.glutMouseFunc(mouseClick)
    glut.glutMotionFunc(mouseMove)

    print help

    # Run the main event loop
    glut.glutMainLoop()
コード例 #55
0
ファイル: viewer.py プロジェクト: bwesterb/py-sphere
    def run(self):
        """ Set up the viewer. """
        if self.running:
            raise RuntimeError("Already running")
        self.running = True

        GLUT.glutInit([])
        GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE |
                                 GLUT.GLUT_RGBA |
                                 GLUT.GLUT_ALPHA |
                                 GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(400, 400)
        GLUT.glutCreateWindow('sphere.viewer')
        
        GL.glClearColor(1, 1, 1, 1)
        GL.glShadeModel(GL.GL_SMOOTH)
        GL.glEnable(GL.GL_CULL_FACE)
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glEnable(GL.GL_BLEND)
        GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA)

        GL.glEnable(GL.GL_LIGHTING)
        GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, [5, 10, -10, 1])
        GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, [1, 1, 1, 1])
        GL.glLightf(GL.GL_LIGHT0, GL.GL_CONSTANT_ATTENUATION, 0.1)
        GL.glLightf(GL.GL_LIGHT0, GL.GL_LINEAR_ATTENUATION, 0.05)
        GL.glEnable(GL.GL_LIGHT0)

        GL.glMatrixMode(GL.GL_PROJECTION)
        GLU.gluPerspective(40, 1, 1, 40)
        GL.glMatrixMode(GL.GL_MODELVIEW)

        GLUT.glutKeyboardFunc(self.keyboard)
        GLUT.glutDisplayFunc(self.display)
        GLUT.glutWMCloseFunc(self.close)
        GLUT.glutTimerFunc(30, self.timer, None)

        GLUT.glutMainLoop()