コード例 #1
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
コード例 #2
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()
コード例 #3
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()
コード例 #4
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()
コード例 #5
0
ファイル: window.py プロジェクト: victorveiga/house-pyopengl
    def __init__(self,
                 width: int,
                 height: int,
                 title: str,
                 camera: bool = False):
        self.__Daytime = True
        self.__enableCamera = camera

        glut.glutInit()
        glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
        glut.glutInitWindowSize(width, height)
        glut.glutInitWindowPosition(0, 0)
        glut.glutCreateWindow(title)
        glut.glutReshapeFunc(self.__window_resize)
        glut.glutDisplayFunc(self.__display)
        glut.glutKeyboardFunc(self.__keyboardDown)
        glut.glutKeyboardUpFunc(self.__keyboardUp)
        glut.glutMotionFunc(self.__mouse_look_clb)

        self._create_shader()
        self.setSky(True)
        glEnable(GL_DEPTH_TEST)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

        self.__ElementsList = []
        self.__camera = Camera()
        self.__lastX = width / 2
        self.__lastY = height / 2
        self.__first_mouse = True
        self.__left = False
        self.__right = False
        self.__forward = False
        self.__backward = False
コード例 #6
0
    def gl_init(self):
        # sys.stderr.write("Starting GLUTContext.gl_init\n")
        if self is not GLUTContext._default_instance:
            # sys.stderr.write("Making a GLUT window.\n")
            GLUT.glutInitWindowSize(self._width, self._height)
            GLUT.glutInitWindowPosition(0, 0)
            self.window = GLUT.glutCreateWindow(
                bytes(self._title, encoding="UTF-8"))
        GLUT.glutSetWindow(self.window)
        GLUT.glutMouseFunc(lambda button, state, x, y: self.
                           mouse_button_handler(button, state, x, y))
        GLUT.glutReshapeFunc(
            lambda width, height: self.resize2d(width, height))
        GLUT.glutDisplayFunc(lambda: self.draw())
        GLUT.glutVisibilityFunc(
            lambda state: self.window_visibility_handler(state))
        # Right now, the timer just prints FPS
        GLUT.glutTimerFunc(0, lambda val: self.timer(val), 0)
        GLUT.glutCloseFunc(lambda: self.cleanup())

        for coltype in object_collection.GLObjectCollection.collection_classes:
            self.object_collections.append(
                object_collection.GLObjectCollection.
                collection_classes[coltype](self))
        # self.object_collections.append(object_collection.SimpleObjectCollection(self))
        # self.object_collections.append(object_collection.CurveCollection(self))

        self.window_is_initialized = True
        GLUTContext._instances.append(self)
コード例 #7
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()
コード例 #8
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
コード例 #9
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()
コード例 #10
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()
コード例 #11
0
ファイル: glut.py プロジェクト: marcan/blitzloop
 def __init__(self, width=640, height=480, fullscreen=False, aspect=None):
     self.gl = gl
     glut.glutInit(sys.argv)
     glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH)
     glut.glutInitWindowPosition(0, 0)
     glut.glutCreateWindow(b"BlitzLoop Karaoke")
     if not fullscreen:
         glut.glutReshapeWindow(width, height)
     else:
         glut.glutSetCursor(glut.GLUT_CURSOR_NONE)
     BaseDisplay.__init__(self, width, height, fullscreen, aspect)
     self._on_reshape(width, height)
     if fullscreen:
         self.saved_size = (width, height)
         glut.glutFullScreen()
     glut.glutDisplayFunc(self._render)
     glut.glutIdleFunc(self._render)
     glut.glutReshapeFunc(self._on_reshape)
     glut.glutKeyboardFunc(self._on_keyboard)
     glut.glutSpecialFunc(self._on_keyboard)
     try:
         glut.glutSetOption(glut.GLUT_ACTION_ON_WINDOW_CLOSE, glut.GLUT_ACTION_GLUTMAINLOOP_RETURNS)
         print("Using FreeGLUT mainloop return feature")
     except:
         pass
     self._initialize()
コード例 #12
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()
コード例 #13
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()
コード例 #14
0
 def __init__(self, width=640, height=480, fullscreen=False, aspect=None):
     self.gl = gl
     glut.glutInit(sys.argv)
     glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB
                              | glut.GLUT_DEPTH)
     glut.glutInitWindowPosition(0, 0)
     glut.glutCreateWindow(b"BlitzLoop Karaoke")
     if not fullscreen:
         glut.glutReshapeWindow(width, height)
     else:
         glut.glutSetCursor(glut.GLUT_CURSOR_NONE)
     BaseDisplay.__init__(self, width, height, fullscreen, aspect)
     self._on_reshape(width, height)
     if fullscreen:
         self.saved_size = (width, height)
         glut.glutFullScreen()
     glut.glutDisplayFunc(self._render)
     glut.glutIdleFunc(self._render)
     glut.glutReshapeFunc(self._on_reshape)
     glut.glutKeyboardFunc(self._on_keyboard)
     glut.glutSpecialFunc(self._on_keyboard)
     try:
         glut.glutSetOption(glut.GLUT_ACTION_ON_WINDOW_CLOSE,
                            glut.GLUT_ACTION_GLUTMAINLOOP_RETURNS)
         print("Using FreeGLUT mainloop return feature")
     except:
         pass
     self._initialize()
コード例 #15
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()
コード例 #16
0
    def __init__(self, wWidth, wHeight, filename):
        global g_rs, g_nx, g_ny, g_msecs

        g_rs = PVReadSparse(filename)
        g_nx = g_rs.nx
        g_ny = g_rs.ny

        glut.glutInit(sys.argv)
        glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE
                                 | glut.GLUT_DEPTH)
        glut.glutInitWindowSize(wWidth, wHeight)
        glut.glutInitWindowPosition(0, 0)
        window = glut.glutCreateWindow("PetaVision Activity")
        gl.glTranslatef(-1.0, 1.0, -2.5)

        # register callbacks
        glut.glutReshapeFunc(reSizeGLScene)
        glut.glutTimerFunc(g_msecs, getNextRecord, 1)
        glut.glutDisplayFunc(drawGLScene)
        glut.glutKeyboardFunc(keyPressed)

        print "nx==", g_nx
        print "ny==", g_ny

        self.initGL(wWidth, wHeight)
コード例 #17
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()
コード例 #18
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()
コード例 #19
0
ファイル: picking_test.py プロジェクト: arokem/Fos
def window(w=800,h=800,title='light',px=100,py=100):

    #glut init
    glut.glutInit(sys.argv)
    glut.glutInitDisplayMode (glut.GLUT_DOUBLE | glut.GLUT_RGB)
    glut.glutInitWindowSize (w, h)
    glut.glutInitWindowPosition (px, py)
    glut.glutCreateWindow (title)
コード例 #20
0
def window(w=800, h=800, title='light', px=100, py=100):

    #glut init
    glut.glutInit(sys.argv)
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB)
    glut.glutInitWindowSize(w, h)
    glut.glutInitWindowPosition(px, py)
    glut.glutCreateWindow(title)
コード例 #21
0
 def __init__(self,view_height,winsize=(400,300)):
   self.wm = WindowManagerGLUT(view_height)
   self.draw_func = None
   glut.glutInit()
   glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH)  # zBuffer
   glut.glutInitWindowSize(winsize[0], winsize[1])
   glut.glutInitWindowPosition(100, 100)
   glut.glutCreateWindow("Visualizzatore_2.0")
コード例 #22
0
    def window(self):

        glut.glutInit(sys.argv)
        glut.glutInitDisplayMode(self.disp_mode)
        w, h = self.win_size
        glut.glutInitWindowSize(w, h)
        px, py = self.win_pos
        glut.glutInitWindowPosition(px, py)
        glut.glutCreateWindow(self.win_title)
コード例 #23
0
ファイル: scene.py プロジェクト: arokem/Fos
    def window(self):

        glut.glutInit(sys.argv)
        glut.glutInitDisplayMode (self.disp_mode)
        w,h=self.win_size
        glut.glutInitWindowSize (w,h)
        px,py=self.win_pos
        glut.glutInitWindowPosition (px,py)
        glut.glutCreateWindow (self.win_title)
コード例 #24
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()
コード例 #25
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()
コード例 #26
0
 def init_glut(self):
     """
         Set up window and main callback functions
     """
     GLUT.glutInit(['Galaxy Renderer'])
     GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGB)
     GLUT.glutInitWindowSize(_WINDOW_SIZE[0], _WINDOW_SIZE[1])
     GLUT.glutInitWindowPosition(_WINDOW_POSITION[0], _WINDOW_POSITION[1])
     GLUT.glutCreateWindow(str.encode("Galaxy Renderer"))
     GLUT.glutDisplayFunc(self.render)
     GLUT.glutIdleFunc(self.update_positions)
コード例 #27
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()
コード例 #28
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()
コード例 #29
0
ファイル: main.py プロジェクト: jpkell05/hyperdim
def initGLWindow(width, height):
	# init GL window
	GLUT.glutInit(sys.argv)
	GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_ALPHA | GLUT.GLUT_DEPTH)
	GLUT.glutInitWindowSize(width, height)
	GLUT.glutInitWindowPosition(0, 0)
	GLUT.glutCreateWindow("Hyper Dimensions v1.0 (beta)")
	# set callback functions
	GLUT.glutDisplayFunc(drawGLScene)	# rendering function
	GLUT.glutIdleFunc(drawGLScene)		# idle function
	GLUT.glutTimerFunc(10, updateScene, 1);
	GLUT.glutPassiveMotionFunc(mousePassiveMotion)
コード例 #30
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()
コード例 #31
0
ファイル: glut.py プロジェクト: PolarNick239/OpenGLPrototypes
    def __init__(self, limit_fps=100, show_fps=True, window_name='GlutWindow', size=np.asarray([768, 512])):
        self.limit_fps = limit_fps
        self.show_fps = show_fps
        self.window_name = window_name
        self.window_size = size

        glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
        glut.glutInitWindowPosition(*GlutWindow.allocate_window_position(self.window_size))
        self.window_handle = glut.glutCreateWindow(self.window_name)
        glut.glutReshapeWindow(*self.window_size)
        glut.glutReshapeFunc(self.reshape)
        glut.glutDisplayFunc(self.display)
        glut.glutKeyboardFunc(self.keyboard)
コード例 #32
0
 def _glut_init(self):
     glut.glutInit(sys.argv)
     glut.glutInitDisplayMode(glut.GLUT_RGB | glut.GLUT_SINGLE)
     glut.glutInitWindowSize(self.window_size, self.window_size)
     glut.glutInitWindowPosition(0, 0)
     glut.glutCreateWindow(sys.argv[0])
     glut.glutDisplayFunc(self._display)
     glut.glutSpecialFunc(self._on_key_press)
     glut.glutMouseFunc(self._on_mouse_click)
     glut.glutMotionFunc(self._on_mouse_move)
     glut.glutReshapeFunc(self._on_window_resize)
     glut.glutIdleFunc(self._on_idle)
     glut.glutMainLoop()
コード例 #33
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()
コード例 #34
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()
コード例 #35
0
def createGLUTWindow(windowTitle):
    GLUT.glutInit(sys.argv)
    GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)

    GLUT.glutInitWindowSize(1024, 768)
    GLUT.glutInitWindowPosition(120, 120)
    GLUT.glutCreateWindow(windowTitle)

    GLUT.glutDisplayFunc(onDrawGL)
    GLUT.glutIdleFunc(onDrawGL)
    GLUT.glutReshapeFunc(resizeGL)
    GLUT.glutKeyboardFunc(keyPressed)

    initGL()
    createShaderGL()
コード例 #36
0
    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()
コード例 #37
0
ファイル: push_window.py プロジェクト: kniranjankumar/DartEnv
    def run(self, ):
        # Init glut
        GLUT.glutInit(())
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE
                                 | GLUT.GLUT_ALPHA | GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(*self.window_size)
        GLUT.glutInitWindowPosition(0, 0)
        self.window = GLUT.glutCreateWindow(self.title)

        GLUT.glutDisplayFunc(self.drawGL)
        GLUT.glutReshapeFunc(self.resizeGL)
        GLUT.glutKeyboardFunc(self.mykeyboard)
        GLUT.glutMouseFunc(self.mouseFunc)
        GLUT.glutMotionFunc(self.motionFunc)
        self.initGL(*self.window_size)
コード例 #38
0
ファイル: btvizGL.py プロジェクト: sanjayankur31/btmorph_v2
    def main(self,
             neuronObject,
             displaysize=(800, 600),
             radius=5,
             poly=True,
             fast=False,
             multisample=True,
             graph=True):

        self.poly = poly
        self.displaysize = displaysize
        self.graph = graph

        title = 'btmorph OpenGL Viewer'

        GLUT.glutInit(sys.argv)
        if multisample:
            GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE)
        else:
            GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE
                                     | GLUT.GLUT_MULTISAMPLE)
        GLUT.glutInitWindowSize(self.displaysize[0], self.displaysize[1])
        GLUT.glutInitWindowPosition(50, 50)
        GLUT.glutCreateWindow(title)
        GLUT.glutDisplayFunc(self.display)
        GLUT.glutReshapeFunc(self.reshape)
        GLUT.glutMouseFunc(self.mouse)
        GLUT.glutMotionFunc(self.mouseMove)
        GLUT.glutMouseWheelFunc(self.mouseWheel)
        GLUT.glutKeyboardFunc(self.keyDown)
        GLUT.glutKeyboardUpFunc(self.keyUp)

        mb = modelbuilder()
        self.root, self.vertices_gl, self.colors_gl, self.Neuron = \
            mb.build(neuronObject, self.poly, 100, fast)
        if graph:
            self.gb = graphbuilder()
            self.Graph, mid = \
                self.gb.build(neuronObject, scalefactor=100)

        self.initGL(multisample)
        self.camera.rad = radius
        self.camera.focus = mid

        while self.running:
            GLUT.glutMainLoopEvent()

        GLUT.glutDestroyWindow(GLUT.glutGetWindow())
コード例 #39
0
    def __init__(self, size=(1200, 900), connected=False):
        self.size = size
        self.connected = connected

        GLUT.glutInit([])
        GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGB
                                 | GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(*size)
        GLUT.glutInitWindowPosition(0, 0)
        GLUT.glutCreateWindow("Render")

        self.vertex_shader = shaders.compileShader(PLAIN_VERTEX_SHADER,
                                                   GL.GL_VERTEX_SHADER)

        self.fragment_shader = shaders.compileShader(CUBEMAP_FRAGMENT_SHADER,
                                                     GL.GL_FRAGMENT_SHADER)
コード例 #40
0
ファイル: glviewer.py プロジェクト: schnorr/tupan
 def init_window(self):
     glut.glutInit(sys.argv)
     glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_ALPHA | glut.GLUT_DEPTH)
     glut.glutInitWindowPosition(
         (glut.glutGet(glut.GLUT_SCREEN_WIDTH) - self.window_width) // 2,
         (glut.glutGet(glut.GLUT_SCREEN_HEIGHT) - self.window_height) // 2,
     )
     glut.glutSetOption(glut.GLUT_ACTION_ON_WINDOW_CLOSE, glut.GLUT_ACTION_CONTINUE_EXECUTION)
     glut.glutInitWindowSize(self.window_width, self.window_height)
     self.window_handle = glut.glutCreateWindow(WINDOW_TITLE_PREFIX)
     glut.glutDisplayFunc(self.render_func)
     glut.glutReshapeFunc(self.resize_func)
     glut.glutMouseFunc(self.mouse)
     glut.glutMotionFunc(self.mouse_motion)
     glut.glutKeyboardFunc(self.keyboard)
     glut.glutSpecialFunc(self.keyboard_s)
コード例 #41
0
ファイル: steampak_demo.py プロジェクト: idlesign/steampak
    def __init__(self, app_id, fullscreen=False):
        glut.glutInit()
        glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)

        if fullscreen:
            glut.glutGameModeString('1920x1080:32@60')
            glut.glutEnterGameMode()
        else:
            glut.glutInitWindowPosition(100, 100)
            glut.glutInitWindowSize(1024, 768)
            glut.glutCreateWindow('steampak demo')

        glut.glutDisplayFunc(self.redraw)
        glut.glutIdleFunc(self.redraw)
        glut.glutKeyboardFunc(self.keypress)

        self.api = SteamApi(LIBRARY_PATH, app_id=app_id)
コード例 #42
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()
コード例 #43
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()
コード例 #44
0
ファイル: appbase.py プロジェクト: showa-yojyo/notebook
    def init_glut(self, args):
        """Initialize the GLUT state."""

        # Initialize GLUT.
        GLUT.glutInit(args)

        GLUT.glutInitContextVersion(
            self.context_version[0], self.context_version[1])
        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)

        # Initialize and create the main window.
        GLUT.glutInitDisplayMode(
            GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(
            self.window_size[0], self.window_size[1])
        GLUT.glutInitWindowPosition(
            self.window_position[0], self.window_position[1])
        GLUT.glutCreateWindow(self.window_title)

        GLUT.glutDisplayFunc(self.render)
        GLUT.glutIdleFunc(self.idle)
        GLUT.glutReshapeFunc(self.resize)
        GLUT.glutKeyboardFunc(self.keyboard)
        GLUT.glutTimerFunc(0, self.timer, 0)
        GLUT.glutMouseFunc(self.mouse)
        GLUT.glutMotionFunc(self.motion)
        GLUT.glutCloseFunc(self.cleanup)

        aspects = [('Vendor', GL.GL_VENDOR),
                   ('Renderer', GL.GL_RENDERER),
                   ('Version', GL.GL_VERSION),]
        if self.context_version[0] > 1:
            aspects.append(('GLSL', GL.GL_SHADING_LANGUAGE_VERSION))

        for i in aspects:
            print('{}: {}'.format(i[0],
                                  GL.glGetString(i[1]).decode()),
                  file=sys.stderr, flush=True)
コード例 #45
0
ファイル: btvizGL.py プロジェクト: btorboist/btmorph_v2
    def main(self, neuronObject, displaysize=(800, 600), radius=5, poly=True,
             fast=False, multisample=True, graph=True):

        self.poly = poly
        self.displaysize = displaysize
        self.graph = graph

        title = 'btmorph OpenGL Viewer'

        GLUT.glutInit(sys.argv)
        if multisample:
            GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE)
        else:
            GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA |
                                     GLUT.GLUT_DOUBLE |
                                     GLUT.GLUT_MULTISAMPLE)
        GLUT.glutInitWindowSize(self.displaysize[0], self.displaysize[1])
        GLUT.glutInitWindowPosition(50, 50)
        GLUT.glutCreateWindow(title)
        GLUT.glutDisplayFunc(self.display)
        GLUT.glutReshapeFunc(self.reshape)
        GLUT.glutMouseFunc(self.mouse)
        GLUT.glutMotionFunc(self.mouseMove)
        GLUT.glutMouseWheelFunc(self.mouseWheel)
        GLUT.glutKeyboardFunc(self.keyDown)
        GLUT.glutKeyboardUpFunc(self.keyUp)

        mb = modelbuilder()
        self.root, self.vertices_gl, self.colors_gl, self.Neuron = \
            mb.build(neuronObject, self.poly, 100, fast)
        if graph:
            self.gb = graphbuilder()
            self.Graph, mid = \
                self.gb.build(neuronObject, scalefactor=100)

        self.initGL(multisample)
        self.camera.rad = radius
        self.camera.focus = mid

        while self.running:
            GLUT.glutMainLoopEvent()

        GLUT.glutDestroyWindow(GLUT.glutGetWindow())
コード例 #46
0
ファイル: GlutViewer.py プロジェクト: microy/MeshToolkit
	def __init__( self, mesh, width=1024, height=768 ) :
		# Initialise OpenGL / GLUT
		glut.glutInit()
		glut.glutInitDisplayMode( glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH | glut.GLUT_MULTISAMPLE )
		glut.glutInitWindowSize( width, height )
		glut.glutInitWindowPosition( 100, 100 )
		glut.glutCreateWindow( mesh.name )
		# Mesh viewer
		self.meshviewer = mtk.MeshViewer()
		self.meshviewer.InitialiseOpenGL( width, height )
		self.meshviewer.LoadMesh( mesh )
		self.antialiasing = True
		# GLUT function binding
		glut.glutCloseFunc( self.meshviewer.Close )
		glut.glutDisplayFunc( self.Display )
		glut.glutIdleFunc( self.Idle )
		glut.glutKeyboardFunc( self.Keyboard )
		glut.glutMouseFunc( self.Mouse )
		glut.glutMotionFunc( self.meshviewer.trackball.MouseMove )
		glut.glutReshapeFunc( self.meshviewer.Resize )
コード例 #47
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()
コード例 #48
0
ファイル: graphics.py プロジェクト: abeaumont/blitzloop
	def __init__(self, width=640, height=480, fullscreen=False, aspect=None):
		self.kbd_handler = None
		self.win_width = width
		self.win_height = height
		glut.glutInit(sys.argv)
		glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB | glut.GLUT_DEPTH)
		glut.glutInitWindowPosition(0, 0)
		glut.glutCreateWindow("Karaoke")
		if not fullscreen:
			glut.glutReshapeWindow(width, height)
		else:
			glut.glutSetCursor(glut.GLUT_CURSOR_NONE)
		self.win_width = width
		self.win_height = height
		self.set_aspect(aspect)
		self._on_reshape(width, height)
		if fullscreen:
			glut.glutFullScreen()
		glut.glutDisplayFunc(self._render)
		glut.glutIdleFunc(self._render)
		glut.glutReshapeFunc(self._on_reshape)
		glut.glutKeyboardFunc(self._on_keyboard)
		glut.glutSpecialFunc(self._on_keyboard)
コード例 #49
0
ファイル: evoluo.py プロジェクト: ktulhy-kun/project_evoluo
    def __init__(self,layers,layers_lock):
        """ Инициализирует экран и запускает его, потом всю программу """
        Screen.__init__(self,"OpenGL",layers,layers_lock)

        self.window = 0
        self.quad = None
        self.keypress = []

        print("F**k")
        # self.infoScreen = ScreenCursesInfo()
        self.infoScreen = ScreenStandartInfo()
        GLUT.glutInit(sys.argv)
        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_ALPHA | GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(640, 480)
        GLUT.glutInitWindowPosition(400, 400)
        self.window = GLUT.glutCreateWindow(b"Project Evoluo alpha")
        GLUT.glutDisplayFunc(self._loop) # Функция, отвечающая за рисование
        GLUT.glutIdleFunc(self._loop) # При простое перерисовывать
        GLUT.glutReshapeFunc(self._resize) # изменяет размеры окна
        GLUT.glutKeyboardFunc(self._keyPressed) # Обрабатывает нажатия
        self._initGL(640, 480)
        field_params(640, 480)
        print("F**k")
コード例 #50
0
ファイル: testpyopengl.py プロジェクト: fean9r/FeaCL
    def __init__(self):
        self.makeMovie = False
        self.mouse_down = False
        self.mouse_old = [0., 0.]
        self.rotate = [0., 0., 0.]
        self.translate = [0., 0., 0.]
        self.initrans = [0., 0., -2.]
        self.dt = np.float32(.001)
        self.size = 2
        print self.size **3
        size = self.size
        self.randarr = np.random.rand(self.size, self.size, self.size)
        self.randarr = np.require(self.randarr, 'f')
        arr = [(float(x)/(size-1)-.5,float(y)/(size-1)-.5,float(z)/(size-1)-.5,1.0) for x in xrange(size) for y in xrange(size) for z in xrange(size)]
        print len(arr)
        self.arr = np.require(arr, 'f')
        colarr = [(.5-float(x)/size+.2,float(y)/size-.5+.2,float(z)/size-.5+.2,1.0) for x in xrange(size) for y in xrange(size) for z in xrange(size)]
        self.colarr = np.require(colarr, 'f')
        if self.makeMovie:
            self.curimage = np.zeros((self.height, self.width, 3),dtype=np.uint8)
            self.curindex = 0

        glut.glutInit()
        glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE | glut.GLUT_DEPTH)
        glut.glutInitWindowSize(self.width, self.height)
        glut.glutInitWindowPosition(0, 0)
        self.win = glut.glutCreateWindow("Testing...")
        glut.glutDisplayFunc(self.draw)
        glut.glutKeyboardFunc(self.on_key)
        glut.glutMouseFunc(self.on_click)
        glut.glutMotionFunc(self.on_mouse_motion)
        glut.glutTimerFunc(10, self.timer, 10)
        self.glinit()
        self.clinit()
        self.loadProgram("kernel.cl")
        self.loadclData()
コード例 #51
0
ファイル: GLPainter.py プロジェクト: gitter-badger/OpenPV
   def __init__ (self, wWidth, wHeight, filename):
      global g_rs, g_nx, g_ny, g_msecs

      g_rs = PVReadSparse(filename)
      g_nx = g_rs.nx
      g_ny = g_rs.ny

      glut.glutInit(sys.argv)
      glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE | glut.GLUT_DEPTH)
      glut.glutInitWindowSize(wWidth, wHeight)
      glut.glutInitWindowPosition(0, 0)
      window = glut.glutCreateWindow("PetaVision Activity")
      gl.glTranslatef( -1.0 , 1.0 , -2.5)
      
      # register callbacks
      glut.glutReshapeFunc(reSizeGLScene)
      glut.glutTimerFunc(g_msecs, getNextRecord, 1)
      glut.glutDisplayFunc(drawGLScene)
      glut.glutKeyboardFunc(keyPressed)
      
      print "nx==", g_nx
      print "ny==", g_ny

      self.initGL(wWidth, wHeight)
コード例 #52
0
ファイル: triangle.py プロジェクト: devforfu/pyogldev
def tiny_glut(args):
    global vertex_code, fragment_code
    scale = 0.01

    def display():
        CAMERA.render()
        gl.glClear(gl.GL_COLOR_BUFFER_BIT)

        nonlocal scale
        scale_location = gl.glGetUniformLocation(program, "gScale")
        assert scale_location != 0xffffffff
        world_location = gl.glGetUniformLocation(program, "gWorld")
        assert world_location != 0xffffffff

        scale += 0.01

        pipeline = Pipeline(rotation=[0.0, 30*scale, 0.0],
                            # scaling=[math.sin(scale)] * 3,
                            translation=[0, 0, 6],
                            projection=ProjParams(WINDOW_WIDTH, WINDOW_HEIGHT, 1.0, 100.0, 60.0))
        pipeline.set_camera(CAMERA)

        gl.glUniformMatrix4fv(world_location, 1, gl.GL_TRUE, pipeline.get_wvp())
        gl.glDrawElements(gl.GL_TRIANGLES, 18, gl.GL_UNSIGNED_INT, ctypes.c_void_p(0))
        glut.glutSwapBuffers()
        # glut.glutPostRedisplay()

    def mouse(x, y):
        CAMERA.mouse(x, y)

    def keyboard(key, x, y):
        if key == glut.GLUT_KEY_F1:
            sys.exit(0)
        elif key == glut.GLUT_KEY_HOME:
            CAMERA.setup()
        else:
            CAMERA.keyboard(key)

    glut.glutInit(args)
    glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_3_2_CORE_PROFILE)
    glut.glutInitWindowSize(WINDOW_WIDTH, WINDOW_HEIGHT)
    glut.glutInitWindowPosition(400, 100)
    # glut.glutCreateWindow("Camera Tutorial")
    glut.glutGameModeString("1920x1200@32")
    glut.glutEnterGameMode()

    # callbacks initialization
    glut.glutDisplayFunc(display)
    glut.glutIdleFunc(display)
    # glut.glutKeyboardFunc(keyboard)
    glut.glutPassiveMotionFunc(mouse)
    glut.glutSpecialFunc(keyboard)

    gl.glEnable(gl.GL_DEPTH_TEST)
    gl.glDepthFunc(gl.GL_LESS)
    gl.glClearColor(0, 0, 0, 0)

    vertices = np.array([
        -1, -1, 0,
        0, -1, -1,
        1, -1, 0,
        0, -1, 1,
        0, 1, 0
    ], dtype=np.float32)

    indexes = np.array([
        0, 1, 2,
        1, 2, 3,
        0, 1, 4,
        1, 2, 4,
        2, 3, 4,
        3, 0, 4
    ], dtype=np.uint32)

    vertex_shader = gl.glCreateShader(gl.GL_VERTEX_SHADER)
    gl.glShaderSource(vertex_shader, vertex_code)
    gl.glCompileShader(vertex_shader)

    if not gl.glGetShaderiv(vertex_shader, gl.GL_COMPILE_STATUS):
        info = gl.glGetShaderInfoLog(vertex_shader)
        print("vertex shader error occurred")
        print(bytes.decode(info))
        return

    fragment_shader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
    gl.glShaderSource(fragment_shader, fragment_code)
    gl.glCompileShader(fragment_shader)

    if not gl.glGetShaderiv(fragment_shader, gl.GL_COMPILE_STATUS):
        info = gl.glGetShaderInfoLog(fragment_shader)
        print("fragment shader error occurred")
        print(bytes.decode(info))
        return

    program = gl.glCreateProgram()
    gl.glAttachShader(program, vertex_shader)
    gl.glAttachShader(program, fragment_shader)
    gl.glLinkProgram(program)
    gl.glUseProgram(program)

    vao = gl.glGenVertexArrays(1)
    gl.glBindVertexArray(vao)

    vbo = gl.glGenBuffers(1)
    gl.glBindBuffer(gl.GL_ARRAY_BUFFER, vbo)
    gl.glBufferData(gl.GL_ARRAY_BUFFER, vertices.nbytes, vertices, gl.GL_STATIC_DRAW)
    gl.glEnableVertexAttribArray(0)
    gl.glVertexAttribPointer(0, 3, gl.GL_FLOAT, gl.GL_FALSE, 0, ctypes.c_void_p(0))

    ibo = gl.glGenBuffers(1)
    gl.glBindBuffer(gl.GL_ELEMENT_ARRAY_BUFFER, ibo)
    gl.glBufferData(gl.GL_ELEMENT_ARRAY_BUFFER, indexes.nbytes, indexes, gl.GL_STATIC_DRAW)
    glut.glutMainLoop()
コード例 #53
0
ファイル: gl_windows.py プロジェクト: caosuomo/rads
    def __init__(self,
                 dim=3,
                 width=800,
                 height=800,
                 title="",
                 refresh=15,
                 background_color = (0.,0.,0.,0.),
                 render_func=lambda window: None,
                 rf_args=(),
                 rf_kwargs = {},
                 save_file='./',
                 save_file_type=None):
        
        pid = os.fork() # Hack to get interpetor back
        if not pid==0:
            return None
        self.mouse_down = False
        self.mouse_old = [0., 0.]
        self.rotate = [0., 0., 0.]
        self.translate = [0., 0., 0.]
        self.scale = 1.0
        self.dim=dim

        # grab the file extension if its there.
        split_path_ext = os.path.splitext(save_file)
        self.save_file = split_path_ext[0]
        if save_file_type is None:
            self.save_file_ext = split_path_ext[1]
            if self.save_file_ext == '':
                self.save_file_ext = '.png'
        else:
            self.save_file_ext = save_file_type
        self.save_count = 0

        self.width = width
        self.height = height
        self.lights = False
        
         

        GLUT.glutInit()

        # 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(title)

        # OpenGL callbacks
        GLUT.glutDisplayFunc(self.draw(render_func,*rf_args,**rf_kwargs))
        GLUT.glutKeyboardFunc(self.on_key)
        GLUT.glutMouseFunc(self.on_click)
        GLUT.glutMotionFunc(self.on_mouse_motion)
        try:
            GLUT.glutCloseFunc(self.on_exit)
        # JJB - 6/6/12 -- 
        except GLUT.error.NullFunctionError:
            GLUT.glutWMCloseFunc(self.on_exit)
        GLUT.glutTimerFunc(refresh, self.timer, refresh)

        self.glinit()
        # Clean the slate
        GL.glClearColor(*background_color)
        # and start
        GLUT.glutMainLoop()
コード例 #54
0
ファイル: etapa_2.py プロジェクト: Colbacon/inf_grafica
	ratio = width / height

	gl.glMatrixMode(gl.GL_PROJECTION)
	gl.glLoadIdentity();
	gl.glViewport(0,0,width,height)
	if ratio >= 1:
		gl.glOrtho (-2.0*ratio,2.0*ratio, -2.0,2.0, -1.0, 1.0)
	else:
		gl.glOrtho (-2.0,2.0, -2.0/ratio,2.0/ratio, -1.0, 1.0)
	gl.glMatrixMode(gl.GL_MODELVIEW)



glut.glutInit()
# Indicamos como ha de ser la nueva ventana
glut.glutInitWindowPosition (100,100)
glut.glutInitWindowSize (W_WIDTH, W_HEIGHT)
glut.glutInitDisplayMode (glut.GLUT_RGBA | glut.GLUT_DOUBLE)

glut.glutCreateWindow ("Etapa 2")

# Indicamos cuales son las funciones de redibujado e idle
glut.glutDisplayFunc(Display)
glut.glutIdleFunc(Idle)
glut.glutReshapeFunc(Reshape)

#El color de fondo sera el negro (RGBA, RGB + Alpha channel)
gl.glClearColor (1.0, 1.0, 1.0, 1.0)
gl.glMatrixMode(gl.GL_PROJECTION)
gl.glLoadIdentity()
gl.glOrtho (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0)
コード例 #55
0
import OpenGL.GLUT as glut
import OpenGL.GLU as glu

"""Woking gameloop implemented using glutDisplayFunc(). also initializes a opengl window. """

window =0
width,height = 800,500
name=b"test"

def draw():
	"""skeleton function"""
	gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT) #clear screen
	gl.glLoadIdentity() #reset postition


	glut.glutSwapBuffers() #allows doouble buffering




#initialization

glut.glutInit()
glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE | glut.GLUT_ALPHA | glut.GLUT_DEPTH)
glut.glutInitWindowSize(width,height)
glut.glutInitWindowPosition(0,0)
window = glut.glutCreateWindow(name)
glut.glutDisplayFunc(draw) #calls function draw on user action, ie keyboard or mouseclick.
glut.glutIdleFunc(draw) #substitute for gameloop. calls function draw all the time
glut.glutMainLoop() #starts everything going.
コード例 #56
0
ファイル: test.py プロジェクト: Shootfast/py2dgui
		#if now - self.lastPrinted > 5:
			#self.lastPrinted = now
			#print "FPS: %s" % self.fps
		
	def resize(self, w, h):
		glViewport(0,0,w,h)
		super(MyStage, self).resize(w,h)
	  
	  
if __name__ == "__main__":
	
	width, height = (640, 480)
	GLUT.glutInit(sys.argv)
	GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)
	GLUT.glutInitWindowSize(width, height)
	GLUT.glutInitWindowPosition(0,0)
	
	window = GLUT.glutCreateWindow("py2dgui Test Window")
	
	stage = MyStage(width, height)
	
	GLUT.glutDisplayFunc(stage.render)
	GLUT.glutIdleFunc(stage.render)
	GLUT.glutReshapeFunc(stage.resize)
	
	
	# Make a shape
	#shape = BorderedSquare(color=Color(0.3, 0.3, 0.3), border_width=2)
	#shape.translate(Point(320, 240))
	#shape.scale(Point(.2,.8,.2))
	#shape.rotate(Point(z=15))
コード例 #57
0
    elif key == 'p':
        running = not running

#the mouse is used to control the camera
def mouse(button, state, x, y):
    if button == GLUT.GLUT_LEFT_BUTTON:
        if (state == GLUT.GLUT_DOWN):
            GLUT.glutIdleFunc(forward)
        elif (state == GLUT.GLUT_UP):
            GLUT.glutIdleFunc(Calculations)
    elif button == GLUT.GLUT_RIGHT_BUTTON:
        if (state == GLUT.GLUT_DOWN):
            GLUT.glutIdleFunc(backward)
        elif (state == GLUT.GLUT_UP):
            GLUT.glutIdleFunc(Calculations)

GLUT.glutInit(sys.argv)
GLUT.glutInitDisplayMode (GLUT.GLUT_DOUBLE | GLUT.GLUT_RGB | GLUT.GLUT_DEPTH)
GLUT.glutInitWindowSize (1024, 576)
GLUT.glutInitWindowPosition (100, 100)
GLUT.glutCreateWindow('Lorentz Attractor')
init()
GL.glEnable(GL.GL_TEXTURE_2D)
GLUT.glutDisplayFunc(display)
GLUT.glutReshapeFunc(reshape)
GLUT.glutKeyboardFunc(keyboard)
GLUT.glutMouseFunc(mouse)
GLUT.glutPassiveMotionFunc(motion)
GLUT.glutMotionFunc(motion)
GLUT.glutIdleFunc(Calculations)
GLUT.glutMainLoop()