コード例 #1
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()
コード例 #2
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()
コード例 #3
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()
コード例 #4
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()
コード例 #5
0
ファイル: renderer.py プロジェクト: david-svitov/fishscanner
    def __init__(self):
        """
        Initialize and create GLUT window
        """
        glut.glutInit(sys.argv)
        glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA
                                 | glut.GLUT_DEPTH)
        glut.glutCreateWindow("OpenGL")
        glut.glutFullScreen()

        gl.glEnable(gl.GL_TEXTURE_2D)
        gl.glDisable(gl.GL_LIGHTING)
        gl.glEnable(gl.GL_BLEND)
        gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
        gl.glEnableClientState(gl.GL_VERTEX_ARRAY)

        # Modify matrices for screen size
        width = glut.glutGet(glut.GLUT_SCREEN_WIDTH)
        height = glut.glutGet(glut.GLUT_SCREEN_HEIGHT)
        gl.glViewport(0, 0, width, height)
        gl.glMatrixMode(gl.GL_PROJECTION)
        aspect = width / height
        gl.glOrtho(-aspect, aspect, 1, -1, -1, 1)

        gl.glMatrixMode(gl.GL_MODELVIEW)
        gl.glLoadIdentity()
コード例 #6
0
ファイル: SceneGLUT.py プロジェクト: ezz666/AbstractViewer
 def __init__(self, parent):
     self.MakeCurrent()
     self.V = viewer.Viewer3D()
     glut.glutInitDisplayMode(glut.GLUT_RGBA|glut.GLUT_DOUBLE|glut.GLUT_DEPTH)
     #glut.glutInitWindowSize(self.V.get_width(), self.V.get_height())# window should go to Frame class instead.
     #glut.glutCreateWindow("viewer")
     self._needs_update = False
コード例 #7
0
ファイル: canvas.py プロジェクト: krieghan/game_common
    def __init__(self,
                 world,
                 title='',
                 height=500,
                 width=500):
        self.world = world
        self.time_interval = 10
        GLUT.glutInit(sys.argv)
        self.lastTime = GLUT.glutGet(GLUT.GLUT_ELAPSED_TIME)
        GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | 
                                 GLUT.GLUT_RGB | 
                                 GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(height, width)
        GLUT.glutCreateWindow(title)
        GLUT.glutDisplayFunc(self.render)
        GLUT.glutReshapeFunc(self.onSize)

        self.init = False
        
        #initialized to actual values in setupView
        self.viewport_left = 0
        self.viewport_bottom = 0
        self.viewport_height = 0
        self.viewport_width = 0
        
        self.timeStep = 1
        self.timeElapsed = self.time_interval / 1000.0
コード例 #8
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()
コード例 #9
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
コード例 #10
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()
コード例 #11
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()
コード例 #12
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)
コード例 #13
0
def glInit(): 
  OGLUT.glutInit()  # initialize the GLUT library.
  OGLUT.glutInitDisplayMode(OGLUT.GLUT_DOUBLE | OGLUT.GLUT_RGB |OGLUT.GLUT_DEPTH) # initial display mode
  OGL.glShadeModel(OGL.GL_SMOOTH) # Enable Smooth Shading
  OGL.glClearColor(0.0, 0.0, 0.0, 0.0) # Black Background
	
  OGL.glClearDepth(1.0) # Depth Buffer Setup
  OGL.glEnable(OGL.GL_DEPTH_TEST) # Enables Depth Testing
  OGL.glDepthFunc(OGL.GL_LEQUAL) # The Type Of Depth Testing To Do
  OGL.glHint(OGL.GL_PERSPECTIVE_CORRECTION_HINT, OGL.GL_NICEST) # Really Nice Perspective Calculations
	
  objCamera.Position_Camera(10, 4, 12,   9, 4, 12,   0, 1, 0) # Set Camera Position
	
  LoadVertices()
	
  OGL.glViewport(0,0,SCREEN_SIZE[0],SCREEN_SIZE[1]) # Reset The Current Viewport
  OGL.glMatrixMode(OGL.GL_PROJECTION)
  OGL.glLoadIdentity()
	
  # Calculate The Aspect Ratio Of The Window
  OGLU.gluPerspective(45.0, SCREEN_SIZE[0]/SCREEN_SIZE[1], 0.1, 100.0)
  OGL.glMatrixMode(OGL.GL_MODELVIEW)
	
  OGL.glCullFace(OGL.GL_BACK) # Don't draw the back sides of polygons
  OGL.glEnable(OGL.GL_CULL_FACE) # Turn on culling
コード例 #14
0
ファイル: __init__.py プロジェクト: mulderg/physical-python
    def init(self):
        if not self.__is_initialized:
            self.__is_initialized = True
            sys.argv = glut.glutInit(sys.argv)
            glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH)
            self.__windowsize = (400,400)
            glut.glutInitWindowSize(self.__windowsize[0],self.__windowsize[1])
            glut.glutCreateWindow(self.__name)

            gl.glShadeModel(gl.GL_SMOOTH)
            gl.glEnable(gl.GL_CULL_FACE)
            gl.glEnable(gl.GL_DEPTH_TEST)
            gl.glEnable(gl.GL_LIGHTING)

            glut.glutDisplayFunc(self.__display)
            glut.glutMouseFunc(self.__onMouse)
            glut.glutMotionFunc(self.__onMouseMotion)
            glut.glutMouseWheelFunc(self.__onWheel)
            glut.glutReshapeFunc(self.__onReshape)

            self.__onReshape(400,400)
            def sleep_forever():
                self.__am_slow = False
                if not self._window_closed:
                    print('program complete, but still running visualization...')
                    while True:
                        glut.glutMainLoopEvent()
            atexit.register(sleep_forever)
コード例 #15
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()
コード例 #16
0
    def __init__(self):
        """
        Basic GLUT init and glut function definition.

        Notes
        -----
        `self.render_obj` is initialized here, which is then being used and drawn in `self.display`
        """

        glut.glutInit()
        glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE
                                 | glut.GLUT_DEPTH | glut.GLUT_MULTISAMPLE)
        glut.glutCreateWindow('Frightened Glut Rabbit')
        glut.glutReshapeWindow(Global.WIDTH, Global.HEIGHT)
        glut.glutReshapeFunc(self.reshape)
        glut.glutDisplayFunc(self.display)
        glut.glutKeyboardFunc(self.keyboard)
        glut.glutMouseFunc(self.glutMousePressEvent)
        glut.glutMotionFunc(self.glutMouseMoveEvent)
        glut.glutTimerFunc(Global.REFRESH_TIMER, self.onTimer,
                           Global.REFRESH_TIMER)

        self.buildProgram()

        self.reshape(Global.WIDTH, Global.HEIGHT)

        # set object to be rendered
        self.render_obj = default_obj()

        # For checking if need to swap
        self.standalone = True
コード例 #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
ファイル: 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()
コード例 #19
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()
コード例 #20
0
ファイル: __init__.py プロジェクト: adamlwgriffiths/omgl-old
def setUpModule():
    global window
    if not window:
        GLUT.glutInit(sys.argv)
        GLUT.glutInitDisplayMode(GLUT.GLUT_DOUBLE | GLUT.GLUT_RGBA | GLUT.GLUT_DEPTH)
        GLUT.glutInitWindowSize(1024, 768)
        window = GLUT.glutCreateWindow("OMGL (GLUT)")
コード例 #21
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()
コード例 #22
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()
コード例 #23
0
    def __init__(self, cam_model_files: Tuple[str, str],
                 tracked_cam_parameters: data3d.CameraParameters,
                 tracked_cam_track: List[data3d.Pose],
                 point_cloud: data3d.PointCloud):
        """
        Initialize CameraTrackRenderer. Load camera model, create buffer objects, load textures,
        compile shaders, e.t.c.
        :param cam_model_files: path to camera model obj file and texture. The model consists of
        triangles with per-point uv and normal attributes
        :param tracked_cam_parameters: tracked camera field of view and aspect ratio. To be used
        for building tracked camera frustrum
        :param point_cloud: colored point cloud
        """

        self._point_cloud_renderer = _PointCloudRenderer(point_cloud)
        self._cam_track_line_renderer = _CameraTrackLineRenderer(
            tracked_cam_track)
        self._cam_renderer = _CameraRenderer(cam_model_files,
                                             tracked_cam_parameters,
                                             tracked_cam_track)

        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE
                                 | GLUT.GLUT_DEPTH)
        GL.glEnable(GL.GL_DEPTH_TEST)
        GL.glEnable(GL.GL_PROGRAM_POINT_SIZE)
コード例 #24
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
コード例 #25
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()
コード例 #26
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()
コード例 #27
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
コード例 #28
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()
コード例 #29
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()
コード例 #30
0
ファイル: view.py プロジェクト: Joishi/Python
    def initOpenGLMatrix(self):
        # FROM http://code.activestate.com/recipes/325391-open-a-glut-window-and-draw-a-sphere-using-pythono/
        glut.glutInit(sys.argv)
        glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE | glut.GLUT_DEPTH)
        glut.glutInitWindowSize(400, 400)
        glut.glutCreateWindow(b'PyTowerDefense')

        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)
        gl.lightZeroPosition = [100., 40., 100., 1.]
        gl.lightZeroColor = [0.8, 1.0, 0.8, 1.0] #green tinged
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_POSITION, gl.lightZeroPosition)
        gl.glLightfv(gl.GL_LIGHT0, gl.GL_DIFFUSE, gl.lightZeroColor)
        gl.glLightf(gl.GL_LIGHT0, gl.GL_CONSTANT_ATTENUATION, 0.01)
        gl.glLightf(gl.GL_LIGHT0, gl.GL_LINEAR_ATTENUATION, 0.005)
        gl.glEnable(gl.GL_LIGHT0)
        glut.glutDisplayFunc(self.paint)
        glut.glutIdleFunc(self.repaint)
        gl.glMatrixMode(gl.GL_PROJECTION)
        glu.gluPerspective(30., 1., 1., 1000.)
        gl.glMatrixMode(gl.GL_MODELVIEW)
        self._eyePosition = Point3D("Camera Eye Location").translate(0, 0, 400)
        self._watchingPosition = Point3D("Camera Watching Position")
        self._upVector = Point3D("Camera Up Vector").translate(0, 1, 0)
        glu.gluLookAt(self._eyePosition.x, self._eyePosition.y, self._eyePosition.z,
                      self._watchingPosition.x, self._watchingPosition.y, self._watchingPosition.z,
                      self._upVector.x, self._upVector.y, self._upVector.z)
        gl.glPushMatrix()
        return
コード例 #31
0
ファイル: renderer.py プロジェクト: KatyaKos/computer_vision
    def __init__(self, cam_model_files: Tuple[str, str],
                 tracked_cam_parameters: data3d.CameraParameters,
                 tracked_cam_track: List[data3d.Pose],
                 point_cloud: data3d.PointCloud):
        """
        Initialize CameraTrackRenderer. Load camera model, create buffer objects, load textures,
        compile shaders, e.t.c.

        :param cam_model_files: path to camera model obj file and texture. The model consists of
        triangles with per-point uv and normal attributes
        :param tracked_cam_parameters: tracked camera field of view and aspect ratio. To be used
        for building tracked camera frustrum
        :param point_cloud: colored point cloud
        """
        self._program = _build_program()
        self._objects_program = _build_objects_program()
        self._tracked_cam_parameters = tracked_cam_parameters
        self._tracked_cam_track = tracked_cam_track
        self._cam_points = np.array(
            [point.t_vec for point in tracked_cam_track], dtype=np.float32)

        self._points_size = len(point_cloud.ids)
        self._points = vbo.VBO(
            point_cloud.points.reshape(-1).astype(np.float32))
        self._colors = vbo.VBO(
            point_cloud.colors.reshape(-1).astype(np.float32))

        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE
                                 | GLUT.GLUT_DEPTH)
        GL.glEnable(GL.GL_DEPTH_TEST)
コード例 #32
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()
コード例 #33
0
    def __init__(self,
                 cam_model_files: Tuple[str, str],
                 tracked_cam_parameters: data3d.CameraParameters,
                 tracked_cam_track: List[data3d.Pose],
                 point_cloud: data3d.PointCloud):
        """
        Initialize CameraTrackRenderer. Load camera model, create buffer objects, load textures,
        compile shaders, e.t.c.

        :param cam_model_files: path to camera model obj file and texture. The model consists of
        triangles with per-point uv and normal attributes
        :param tracked_cam_parameters: tracked camera field of view and aspect ratio. To be used
        for building tracked camera frustrum
        :param point_cloud: colored point cloud
        """

        self._camera_parameters = tracked_cam_parameters
        self._camera_track_positions = np.array([pose.t_vec for pose in tracked_cam_track], dtype=np.float32)
        self._camera_track_rotations = np.array([pose.r_mat for pose in tracked_cam_track], dtype=np.float32)

        self._cloud_ids = point_cloud.ids
        self._n_cloud_points = len(point_cloud.ids)
        self._cloud_points_buffer = self._bufferize(point_cloud.points)
        self._cloud_colors_buffer = self._bufferize(point_cloud.colors)

        self._vertex_program = _build_vertex_color_program()
        self._fragment_program = _build_fragment_color_program()

        camera_vertices = self._load_obj_file(cam_model_files[0])
        self._camera_vertices = camera_vertices
        self._n_camera_vertices = len(camera_vertices)

        GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)
        GL.glEnable(GL.GL_DEPTH_TEST)
コード例 #34
0
ファイル: _glut.py プロジェクト: kif/vispy
def _init_glut():
    # HiDPI support for retina display
    # This requires glut from
    # http://iihm.imag.fr/blanch/software/glut-macosx/
    if sys.platform == 'darwin':
        try:
            glutInitDisplayString = platform.createBaseFunction(
                'glutInitDisplayString', dll=platform.GLUT,
                resultType=None, argTypes=[ctypes.c_char_p],
                doc='glutInitDisplayString(  ) -> None', argNames=())
            text = ctypes.c_char_p("rgba stencil double samples=8 hidpi")
            glutInitDisplayString(text)
        except Exception:
            pass
    glut.glutInit(['vispy'.encode('ASCII')])  # todo: allow user to give args?
    mode = (glut.GLUT_RGBA | glut.GLUT_DOUBLE |
            glut.GLUT_STENCIL | glut.GLUT_DEPTH)
    if bool(glut.glutInitDisplayMode):
        glut.glutInitDisplayMode(mode)
    # Prevent exit when closing window
    try:
        glut.glutSetOption(glut.GLUT_ACTION_ON_WINDOW_CLOSE,
                           glut.GLUT_ACTION_CONTINUE_EXECUTION)
    except Exception:
        pass
    return glut
コード例 #35
0
 def setUp(self):
     glut.glutInit()
     glut.glutInitDisplayMode(glut.GLUT_RGBA | glut.GLUT_DOUBLE
                              | glut.GLUT_DEPTH)
     glut.glutInitWindowSize(20, 20)
     self.window_id = glut.glutCreateWindow(self.__class__.__name__)
     self.test_data_path = os.path.join(testDir, 'test_data')
コード例 #36
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()
コード例 #37
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()
コード例 #38
0
ファイル: _glut.py プロジェクト: dengemann/vispy
 def _vispy_get_native_app(self):
     # HiDPI support for retina display
     # This requires glut from
     # http://iihm.imag.fr/blanch/software/glut-macosx/
     if sys.platform == 'darwin':
         try:
             glutInitDisplayString = platform.createBaseFunction(
                 'glutInitDisplayString',
                 dll=platform.GLUT,
                 resultType=None,
                 argTypes=[
                     ctypes.c_char_p],
                 doc='glutInitDisplayString(  ) -> None',
                 argNames=())
             text = ctypes.c_char_p("rgba stencil double samples=8 hidpi")
             glutInitDisplayString(text)
         except:
             pass
     if not self._initialized:
         glut.glutInit()  # todo: maybe allow user to give args?
         glut.glutInitDisplayMode(glut.GLUT_RGBA |
                                  glut.GLUT_DOUBLE |
                                  glut.GLUT_STENCIL |
                                  glut.GLUT_DEPTH)
         self._initialized = True
     return glut
コード例 #39
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
コード例 #40
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()
コード例 #41
0
 def __init__(self, name, width, height):
     self.name = name
     self.width = width
     self.height = height
     # Setup window:
     GLUT.glutInit()
     GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA | GLUT.GLUT_DOUBLE | GLUT.GLUT_DEPTH)
     GLUT.glutInitWindowSize(self.width, self.height)
コード例 #42
0
ファイル: images3.py プロジェクト: Zackory/zackory-sandbox
 def prepareGLUT(self):
     glut.glutInit(sys.argv)
     glut.glutInitWindowSize(self.width, self.height)
     glut.glutCreateWindow('Sample Shader Heatmap')
     glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGB)
     # glut.glutInitDisplayMode(glut.GLUT_RGB)
     glut.glutDisplayFunc(self.display)
     glut.glutKeyboardFunc(self.keyPressed)
コード例 #43
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")
コード例 #44
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)
コード例 #45
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)
コード例 #46
0
ファイル: test_context.py プロジェクト: kwohlfahrt/GLPy
	def setUp(self):
		self.window_size = (400, 400)
		GLUT.glutInit()
		GLUT.glutInitContextVersion(3, 3)
		GLUT.glutInitContextProfile(GLUT.GLUT_CORE_PROFILE)
		GLUT.glutInitDisplayMode(GLUT.GLUT_RGBA)
		GLUT.glutInitWindowSize(*self.window_size)
		self.window = GLUT.glutCreateWindow("GLPy Test")
コード例 #47
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)
コード例 #48
0
ファイル: gl_backend.py プロジェクト: JJendryka/PhasedArray
 def init_glut(self):
     glut.glutInit()
     glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
     glut.glutCreateWindow('')
     glut.glutReshapeWindow(self.resolution[0], self.resolution[1])
     glut.glutReshapeFunc(self.reshape)
     glut.glutDisplayFunc(self.display)
     glut.glutKeyboardFunc(self.keyboard)
     glut.glutTimerFunc(0, self.timer, 0)
コード例 #49
0
ファイル: hello-world.py プロジェクト: CUXIDUMDUM/reference
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()
コード例 #50
0
ファイル: connectctct.py プロジェクト: fgroes/connectctct
    def __init__(self, geos, vertex_code, fragment_code):
        self.time = time.time()
        num_vertices = np.sum([len(g) for g in geos])
        data = np.zeros(num_vertices, [("position", np.float32, 2),
                                       ("color", np.float32, 4)])
        cs = []
        vs = []
        for g in geos:
            for c in g.colors:
                cs.append(c)
            for v in g.vertices:
                vs.append(v)
        data["color"] = cs
        data["position"] = vs
        data["position"] = 0.5 * data["position"]
        self.data = data
        glut.glutInit()
        glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
        glut.glutCreateWindow("Hello world!")
        glut.glutReshapeWindow(512, 512)
        glut.glutReshapeFunc(self.reshape)
        glut.glutDisplayFunc(self.display)
        glut.glutIdleFunc(self.idle)
        glut.glutKeyboardFunc(self.keyboard)
        glut.glutMouseFunc(self.mouse)

        program = gl.glCreateProgram()
        vertex = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        fragment = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        gl.glShaderSource(vertex, vertex_code)
        gl.glShaderSource(fragment, fragment_code)
        gl.glCompileShader(vertex)
        gl.glCompileShader(fragment)
        gl.glAttachShader(program, vertex)
        gl.glAttachShader(program, fragment)
        gl.glLinkProgram(program)
        gl.glDetachShader(program, vertex)
        gl.glDetachShader(program, fragment)
        gl.glUseProgram(program)
        self.buffer = gl.glGenBuffers(1)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffer)
        gl.glBufferData(gl.GL_ARRAY_BUFFER, self.data.nbytes, self.data,
                        gl.GL_DYNAMIC_DRAW)
        stride = self.data.strides[0]
        offset = ctypes.c_void_p(0)
        loc = gl.glGetAttribLocation(program, "position")
        gl.glEnableVertexAttribArray(loc)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffer)
        gl.glVertexAttribPointer(loc, 2, gl.GL_FLOAT, False, stride, offset)

        offset = ctypes.c_void_p(self.data.dtype["position"].itemsize)
        loc = gl.glGetAttribLocation(program, "color")
        gl.glEnableVertexAttribArray(loc)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffer)
        gl.glVertexAttribPointer(loc, 4, gl.GL_FLOAT, False, stride, offset)
        loc = gl.glGetUniformLocation(program, "scale")
        gl.glUniform1f(loc, 1.0)
コード例 #51
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)
コード例 #52
0
ファイル: connectctct.py プロジェクト: fgroes/connectctct
    def __init__(self, geos, vertex_code, fragment_code):
        self.time = time.time()
        num_vertices = np.sum([len(g) for g in geos])
        data = np.zeros(num_vertices, [("position", np.float32, 2),
                            ("color",    np.float32, 4)])
        cs = []
        vs = []
        for g in geos:
            for c in g.colors:
                cs.append(c)
            for v in g.vertices:
                vs.append(v)
        data["color"] = cs
        data["position"] = vs
        data["position"] = 0.5 * data["position"]
        self.data = data
        glut.glutInit()
        glut.glutInitDisplayMode(glut.GLUT_DOUBLE | glut.GLUT_RGBA)
        glut.glutCreateWindow("Hello world!")
        glut.glutReshapeWindow(512,512)
        glut.glutReshapeFunc(self.reshape)
        glut.glutDisplayFunc(self.display)
        glut.glutIdleFunc(self.idle)
        glut.glutKeyboardFunc(self.keyboard)
        glut.glutMouseFunc(self.mouse)

        program  = gl.glCreateProgram()
        vertex   = gl.glCreateShader(gl.GL_VERTEX_SHADER)
        fragment = gl.glCreateShader(gl.GL_FRAGMENT_SHADER)
        gl.glShaderSource(vertex, vertex_code)
        gl.glShaderSource(fragment, fragment_code)
        gl.glCompileShader(vertex)
        gl.glCompileShader(fragment)
        gl.glAttachShader(program, vertex)
        gl.glAttachShader(program, fragment)
        gl.glLinkProgram(program)
        gl.glDetachShader(program, vertex)
        gl.glDetachShader(program, fragment)
        gl.glUseProgram(program)
        self.buffer = gl.glGenBuffers(1)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffer)
        gl.glBufferData(gl.GL_ARRAY_BUFFER, self.data.nbytes, self.data, gl.GL_DYNAMIC_DRAW)
        stride = self.data.strides[0]
        offset = ctypes.c_void_p(0)
        loc = gl.glGetAttribLocation(program, "position")
        gl.glEnableVertexAttribArray(loc)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffer)
        gl.glVertexAttribPointer(loc, 2, gl.GL_FLOAT, False, stride, offset)

        offset = ctypes.c_void_p(self.data.dtype["position"].itemsize)
        loc = gl.glGetAttribLocation(program, "color")
        gl.glEnableVertexAttribArray(loc)
        gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self.buffer)
        gl.glVertexAttribPointer(loc, 4, gl.GL_FLOAT, False, stride, offset)
        loc = gl.glGetUniformLocation(program, "scale")
        gl.glUniform1f(loc, 1.0)
コード例 #53
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()
コード例 #54
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()
コード例 #55
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)
コード例 #56
0
ファイル: inputhook.py プロジェクト: Carreau/ipython
    def enable(self, app=None):
        """DEPRECATED since IPython 5.0

        Enable event loop integration with GLUT.

        Parameters
        ----------

        app : ignored
            Ignored, it's only a placeholder to keep the call signature of all
            gui activation methods consistent, which simplifies the logic of
            supporting magics.

        Notes
        -----

        This methods sets the PyOS_InputHook for GLUT, which allows the GLUT to
        integrate with terminal based applications like IPython. Due to GLUT
        limitations, it is currently not possible to start the event loop
        without first creating a window. You should thus not create another
        window but use instead the created one. See 'gui-glut.py' in the
        docs/examples/lib directory.
        
        The default screen mode is set to:
        glut.GLUT_DOUBLE | glut.GLUT_RGBA | glut.GLUT_DEPTH
        """
        warn(
            "This function is deprecated since IPython 5.0 and will be removed in future versions.",
            DeprecationWarning,
            stacklevel=2,
        )

        import OpenGL.GLUT as glut
        from IPython.lib.inputhookglut import glut_display_mode, glut_close, glut_display, glut_idle, inputhook_glut

        if GUI_GLUT not in self.manager.apps:
            glut.glutInit(sys.argv)
            glut.glutInitDisplayMode(glut_display_mode)
            # This is specific to freeglut
            if bool(glut.glutSetOption):
                glut.glutSetOption(glut.GLUT_ACTION_ON_WINDOW_CLOSE, glut.GLUT_ACTION_GLUTMAINLOOP_RETURNS)
            glut.glutCreateWindow(sys.argv[0])
            glut.glutReshapeWindow(1, 1)
            glut.glutHideWindow()
            glut.glutWMCloseFunc(glut_close)
            glut.glutDisplayFunc(glut_display)
            glut.glutIdleFunc(glut_idle)
        else:
            glut.glutWMCloseFunc(glut_close)
            glut.glutDisplayFunc(glut_display)
            glut.glutIdleFunc(glut_idle)
        self.manager.set_inputhook(inputhook_glut)
コード例 #57
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)